Repository navigation
Hardening, tests, and new features (diff, .gitignore, sharded storage) - #1
Merged
Merged
Conversation
- Shard objects by the first two hex chars of their hash (objects/ab/cdef...). - Compress stored objects with zlib; add ReadObject to decompress. - Add WriteFileAtomic (temp file + rename) so ref/index writes can't corrupt. - Add ObjectPath and IsInitialized helpers; simplify HashContent to Sum256.
Correctness fixes:
- remove: match the exact index path so 'remove foo' can't drop 'foobar'.
- checkout: delete stale files, reset the index, add --force and short-hash
resolution; refuse to discard uncommitted changes without --force.
- status: report committed files modified in the working tree.
- save: fix broken Println("%w") messages; keep multi-word messages; warn on
non-tip commits.
- init/log: check errors instead of reporting false success; stop cleanly.
Structural changes:
- Convert commands to cobra RunE so failures exit non-zero with clean messages
(SilenceUsage on the root); add Args validation.
- Route ref/index writes through atomic writes.
- Add shared repo helpers (repo.go): ensureRepo, .gitignore matcher, getLatest,
writeIndex, resolveHash.
- Drop the dead --toggle flag; add --version wired to an ldflags-injectable var.
Show line-level differences between the working tree and a commit (HEAD by default, or a hash / 'latest') using a dependency-free LCS line diff. New and deleted files are shown against /dev/null.
- New unit tests for save, status, checkout, diff, ignore, hash resolution and repo helpers, plus utils object/round-trip tests. - Regression tests covering every review fix (prefix remove, checkout cleanup, status modified detection, non-tip warning, repo guards, short hashes, force). - New e2e/ package that builds the binary and drives it as a subprocess, asserting real stdout/stderr and exit codes. - Shared test helpers (runCmd/runCmdErr, captureOutput, setupTestRepo).
- CI: build/vet/test across ubuntu/macos/windows x Go 1.21-1.23, plus a race job. - Lint: gofmt, go vet and golangci-lint (config relaxes errcheck in tests). - Release: GoReleaser builds cross-platform archives + checksums on v* tags, injecting the version via ldflags.
- README: install/quick-start, diff & checkout --force docs, short-hash notes, a 'How it works' storage section, and reality-matched feature list. - Add CONTRIBUTING.md and a Makefile (build/test/race/cover/lint/install). - .gitignore: ignore .DS_Store, the built binary and the dist/ release dir.
- ignore matcher: normalize paths to forward slashes and use slash-based glob matching (path.Match) so .gitignore/built-in ignores work on Windows. - init test: skip the 0755 permission assertion on Windows (no Unix perm bits). - CI matrix: exclude macos-latest with Go 1.21/1.22, whose linker output the macOS 26 runner rejects (dyld: missing LC_UUID); macOS is covered on 1.23.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
Hardens MicroGit end-to-end and fills in the missing features, taking it from a
working prototype to a tested, releasable CLI. Started from a
/code-review,then worked through five phases. All changes: build clean,
go vetclean,staticcheckclean,gofmtclean, 58 tests passing, coverage 80.5%(cmd) / 61.4% (utils).
What changed, by phase
Correctness fixes (from code review)
removematched index lines by prefix —remove fooalso droppedfoobar. Now matches the exact path.checkoutleft stale files and a stale index, and silently lost commits. Now deletes files absent from the target, resets the index, and warns/guards against data loss.statusnever reported committed files modified in the working tree. Fixed.saveprinted brokenPrintln("...%w")messages and truncated unquoted multi-word messages. Fixed.init/logignored errors / printed bogus entries. Fixed.Phase 2 — error handling & exit codes
RunE: failures return cleanError:messages and exit non-zero; success exits 0.Argsvalidation,--version, and dropped the dead--toggleflag.Phase 3 — features
microgit diff— dependency-free LCS line diff (working tree vs any commit)..gitignoresupport inadd .andstatus.checkout/diff(with ambiguity detection).Phase 4 — storage depth
objects/ab/cdef…), zlib-compressed object storage, like git.checkout --forceguard against discarding uncommitted work.Phase 5 — docs & tooling
CONTRIBUTING.md,Makefile.CI / release
golangci-lint+ gofmt/vet workflow.v*tags (version injected via ldflags).Testing
e2e/suite that builds the binary and drives it as a subprocess (stdout/stderr + exit codes).Notes
.microgitrepos created by older builds are not readable. Acceptable for a pre-1.0
educational tool.
docs) rather than strictly chronological, since files were touched across
phases; each commit builds on the previous.