Skip to content

fix: reflect manual runs in status - #3

Merged
sdougbrown merged 1 commit into
mainfrom
fix/manual-run-status
Aug 12, 2026
Merged

fix: reflect manual runs in status#3
sdougbrown merged 1 commit into
mainfrom
fix/manual-run-status

Conversation

@sdougbrown

Copy link
Copy Markdown
Owner

Summary

  • Make explicit git tend run requests bypass read-write debounce.
  • Persist results from explicit git tend run commands without allowing stale daemon snapshots to overwrite them.
  • Convert CLI repo paths to absolute paths so run . updates the scanned repository entry.

Testing

  • go test ./...
  • go test -race ./internal/status ./internal/sync ./cmd/git-tend ./internal/daemon ./internal/paths
  • go vet ./...

@sdougbrown
sdougbrown marked this pull request as ready for review August 12, 2026 03:31

@umpire-bot umpire-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is marked... FOUL BALL. 👉

}
}

func TestAtomicWriteNoTmpFile(t *testing.T) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test name no longer matches implementation (T2). The test at line 89–92 only verifies that path + ".tmp" never appears, which is now trivially always true. Rename to reflect the actual invariant (no stale temp files after atomic write) and consider asserting the status file content is correct.

Comment thread cmd/git-tend/run_test.go
repo := setupRunRepo(t)
stateDir := paths.StateDir()
if err := os.MkdirAll(stateDir, 0755); err != nil {
t.Fatal(err)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Integration test uses removeStuckFlag (defined in unstick.go:66) as a test helper, creating a cross-file implementation dependency. If removeStuckFlag changes its error behavior or side effects, this test breaks even though it's testing runRepo behavior. Consider defining the helper directly in the test file or using only exported APIs.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Declined. That's the point of an integration test!

Comment thread cmd/git-tend/run_test.go
return repo
}

func TestRunAfterUnstickBypassesDebounceAndPreservesStatus(t *testing.T) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TestRunAfterUnstickBypassesDebounceAndPreservesStatus is an expensive end-to-end test (multiple exec.Command("git", ...) calls, real git repos, filesystem state). The "preserves status" portion tests MergeAndWrite behavior, which could be verified with a cheaper unit test on the status package. The unstick + run interaction is valid to test end-to-end, but the test name and scope are overloaded.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

End to end tests are like that by nature

}
}

func TestAtomicWriteNoTmpFile(t *testing.T) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

newerOrEqual (status.go:144) has no dedicated unit test. This is the core comparison function for the merge-and-write stale-snapshot protection. Its behavior — handling empty strings, invalid timestamps, and exact-equal timestamps — is only tested implicitly through TestMergeAndWritePreservesNewerForegroundResult. A dedicated unit test would catch regressions in the comparison logic without spinning up a full status file.

Comment thread cmd/git-tend/run.go
return fmt.Errorf("sync failed (%s): %s", result.State, result.Error)
}

func recordRunStatus(statusPath, repoPath, mode string, result sync.SyncResult) error {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

recordRunStatus (run.go:56) has no dedicated unit test. The function's "offline" and "stuck" switch branches are production code that modifies RepoStatus fields (sets LastError, increments ConsecutiveOfflineFailures, sets OfflineSince/StuckSince timestamps). Only the "ok" path is indirectly tested via the integration test. A unit test with a mock RepoStatus update function would verify each branch independently.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Testing via an integration test is superior

@sdougbrown
sdougbrown merged commit 9662738 into main Aug 12, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant