Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@

- Reject Windows Task Scheduler intervals above 1439 minutes during planning instead of producing unsupported minute-mode commands.

- Avoid rebasing and retrying mirror pushes rejected by server policy or authentication; retry only explicit branch-divergence failures.

## 0.18.0 - 2026-11-15

**Highlights:** Add verified private backup transfers and shared seed APIs, fix scheduler and archive-path handling, and include the Go security fix for GO-2026-6859.
Expand Down
4 changes: 4 additions & 0 deletions docs/packages.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ pathspec magic are not expanded. Use `.` to commit the whole archive.
`mirror.CleanSQLiteSidecars` preserves whitespace in the selected root path;
it rejects an empty or whitespace-only root instead of selecting another tree.

Mirror branch and snapshot pushes rebase and retry only when Git reports
non-fast-forward or fetch-first divergence. Other rejections, including server
hooks and authentication failures, return without a sync attempt.

Managed sidecar trees reject overlapping source and destination roots, including
mixed relative and absolute paths. Configured root symlinks remain supported;
symlink directories inside a destination copy path are rejected so copying and
Expand Down
3 changes: 1 addition & 2 deletions mirror/mirror.go
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,5 @@ func redactGitURLs(text string) string {
func isNonFastForward(out string) bool {
lower := strings.ToLower(out)
return strings.Contains(lower, "non-fast-forward") ||
strings.Contains(lower, "fetch first") ||
strings.Contains(lower, "failed to push some refs")
strings.Contains(lower, "fetch first")
}
68 changes: 68 additions & 0 deletions mirror/mirror_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,74 @@ func TestPushWritesCurrentBranchToOrigin(t *testing.T) {
}
}

func TestNonFastForwardRequiresDivergence(t *testing.T) {
for _, tc := range []struct {
output string
want bool
}{
{"! [rejected] main -> main (non-fast-forward)\nerror: failed to push some refs", true},
{"! [rejected] main -> main (fetch first)\nerror: failed to push some refs", true},
{"! [remote rejected] main -> main (pre-receive hook declined)\nerror: failed to push some refs", false},
{"fatal: Authentication failed\nerror: failed to push some refs", false},
{"error: failed to push some refs", false},
} {
if got := isNonFastForward(tc.output); got != tc.want {
t.Errorf("divergence classification for %q = %v, want %v", tc.output, got, tc.want)
}
}
}

func TestPushDoesNotRetryServerRejection(t *testing.T) {
if runtime.GOOS == "windows" {
t.Skip("POSIX server hook fixture")
}
for _, mode := range []string{"branch", "snapshot", "current snapshot"} {
t.Run(mode, func(t *testing.T) {
ctx := context.Background()
dir := t.TempDir()
remote := filepath.Join(dir, "remote.git")
if err := run(ctx, "", "git", "init", "--bare", remote); err != nil {
t.Fatal(err)
}
opts := Options{RepoPath: filepath.Join(dir, "publisher"), Remote: remote, Branch: "main"}
if err := EnsureRemote(ctx, opts); err != nil {
t.Fatal(err)
}
writeTestCommit(t, ctx, opts, "manifest.json", "base\n", "base")
if err := Push(ctx, opts); err != nil {
t.Fatal(err)
}
writeTestCommit(t, ctx, opts, "manifest.json", "next\n", "next")
if _, err := CreateImmutableTag(ctx, opts, "snapshot/rejected"); err != nil {
t.Fatal(err)
}
hook := "#!/bin/sh\necho attempt >> push-attempts\necho 'synthetic server policy rejection' >&2\nexit 1\n"
if err := os.WriteFile(filepath.Join(remote, "hooks", "pre-receive"), []byte(hook), 0o700); err != nil {
t.Fatal(err)
}
if err := run(ctx, remote, "git", "config", "core.hooksPath", filepath.Join(remote, "hooks")); err != nil {
t.Fatal(err)
}
var err error
switch mode {
case "branch":
err = Push(ctx, opts)
case "snapshot":
err = PushSnapshot(ctx, opts, "snapshot/rejected")
case "current snapshot":
err = PushCurrentSnapshot(ctx, opts, "snapshot/rejected")
}
if err == nil || !strings.Contains(err.Error(), "synthetic server policy rejection") {
t.Fatalf("server rejection not reported: %v", err)
}
attempts, err := os.ReadFile(filepath.Join(remote, "push-attempts"))
if err != nil || string(attempts) != "attempt\n" {
t.Fatalf("push attempts = %q, %v; want exactly one", attempts, err)
}
})
}
}

func TestCommitPathsDoesNotStageUnrelatedFiles(t *testing.T) {
ctx := context.Background()
repo := filepath.Join(t.TempDir(), "share")
Expand Down
Loading