fix(diff): track upstream revision for reviewed diffs

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
github-actions[bot]andCopilot authored and GitHub committed 2026-08-11 01:26:40 +00:00
1 parent 328f4b4939
commit 8b302a2c7a
2 files changed
+19 -3

No files matched your search

+3 -3
View File
@@ -160,12 +160,12 @@ func getLastSeenHash(ctx context.Context, cmdBuilder exe.ICmdBuilder, dir string
return gitEmptyTree, nil
}
// Update the AUR_SEEN ref to HEAD. We use this ref to determine which diff were
// reviewed by the user.
// Update the AUR_SEEN ref to the upstream HEAD. We use this ref to determine
// which upstream diff was reviewed by the user, excluding local commits.
func gitUpdateSeenRef(ctx context.Context, cmdBuilder exe.ICmdBuilder, dir string) error {
_, stderr, err := cmdBuilder.Capture(
cmdBuilder.BuildGitCmd(ctx,
dir, "update-ref", gitDiffRefName, "HEAD"))
dir, "update-ref", gitDiffRefName, "HEAD@{upstream}"))
if err != nil {
return fmt.Errorf("%s %w", stderr, err)
}
+16
View File
@@ -88,6 +88,22 @@ func TestShowPkgbuildDiffHelpers(t *testing.T) {
require.Equal(t, "deadbeef", ref)
}
func TestGitUpdateSeenRefTracksUpstream(t *testing.T) {
t.Parallel()
var gotArgs []string
builder := &fakeMenusCmdBuilder{
captureFn: func(cmd *exec.Cmd) (string, string, error) {
gotArgs = cmd.Args
return "", "", nil
},
}
require.NoError(t, gitUpdateSeenRef(context.Background(), builder, "/tmp"))
require.Equal(t, []string{"git", "update-ref", gitDiffRefName, "HEAD@{upstream}"}, gotArgs)
}
type fakeMenusCmdBuilder struct {
captureFn func(*exec.Cmd) (string, string, error)
captureCnt int