You are browsing as a guest. Sign up (or log in) to start making projects!

27m 33s logged

Got basic stuff working!!

This session, I added the core non-UI logic behind gitscope: a read-only git data layer, a line-level diff parser, and a pure branch graph layout engine. The goal was to make the app capable of reading repository history while keeping git access, parsing, and graph computation testable outside the terminal UI.

Git Data Layer

Added a GitBackend abstraction around the local git binary. It is the only place application code should shell out to git.

The backend can now:

  • Discover the current repository root.
  • Validate that a path is inside a git work tree.
  • Report the repository path.
  • Read current HEAD details: full SHA, short SHA, and current branch.
  • List HEAD, local branches, and tags.
  • Load commit pages for HEAD or a specific ref.
  • Load commit pages across local branches.
  • Load the patch for a selected commit.

The backend deliberately stays read-only. It does not expose staging, committing, checkout, reset, merge, rebase, push, pull, fetch, clone, or branch mutation.

Data Models

Added typed records for the main data flowing through the app:

  • Commit
  • GitRef
  • HeadInfo
  • DiffLine
  • GraphRow
  • GraphCell
  • GraphConnection

These keep git output, parsed diffs, and graph layout results explicit instead of passing around loosely structured dictionaries or strings.

Diff Parsing

Added a pure parse_diff() function for line-level git diff output.

It classifies:

  • file headers
  • metadata lines
  • hunk headers
  • added lines
  • removed lines
  • context lines
  • no-newline markers

It also tracks old and new line numbers inside hunks so the UI can render a readable diff view later.

Graph Layout

Added a pure layout_graph() function that takes newest-first commits and parent SHAs, then returns lane and connector metadata for each row.

It handles:

  • empty history
  • root commits
  • linear history
  • merge commits
  • multiple active lanes
  • detached-style history

The graph logic is independent of Textual. It returns data that a terminal UI can render, but it does not depend on terminal widgets or screen state.

Testing

Added tests for:

  • backend command construction
  • backend parsing
  • unsafe refs and SHAs
  • unsupported git command shapes
  • non-work-tree validation
  • a real temporary git repository with commits, a branch, a tag, logs, refs, and diffs
  • diff classification and line numbering
  • empty diffs
  • root, linear, merge, multi-lane, and detached-style graph histories
  • graph collision checks

Verification

  • py -m pytest passed with 22 tests.
  • py -m pip install . completed successfully.
  • gitscope --version returned gitscope 0.1.0.
  • Source scans confirmed parser/layout/model modules do not depend on Textual, subprocess, or direct git commands.

Notes

  • Git access intentionally uses the installed git CLI rather than libgit2 bindings or direct object parsing.
  • The graph layout is a first practical implementation intended to be refined once it is exercised by the live UI.
  • Wiring this logic into the Textual interface is covered by the next devlog.
0
0

Comments 0

No comments yet. Be the first!