From ea3b3b2ffc4a1d3c335994e22056a957cd962d21 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Wed, 22 Jul 2026 09:54:49 +0300 Subject: feat(sync): make backup fail-fast per-destination and add forcePush/descriptionSync creation support Backup failures now disable retries only for the failing remote instead of the whole session, add an opt-in forcePush flag for backup organizations, and allow repository creation to go through descriptionSyncHost/Root when configured so the git remote endpoint can stay restricted. Also fixes the AI release-notes cache being bypassed by --force, which is meant to control sync scheduling, not cache invalidation. Co-Authored-By: Claude Sonnet 5 --- internal/sync/git_operations_test.go | 46 ++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'internal/sync/git_operations_test.go') diff --git a/internal/sync/git_operations_test.go b/internal/sync/git_operations_test.go index 4ca630d..ba40525 100644 --- a/internal/sync/git_operations_test.go +++ b/internal/sync/git_operations_test.go @@ -4,8 +4,11 @@ import ( "os" "os/exec" "path/filepath" + "reflect" "strings" "testing" + + "codeberg.org/snonux/gitsyncer/internal/config" ) func TestGitCommand_SetsDir(t *testing.T) { @@ -24,6 +27,49 @@ func TestGitCommand_LeavesDirEmptyForGlobalCommands(t *testing.T) { } } +func TestPushBranchArgs(t *testing.T) { + t.Parallel() + + tests := []struct { + name string + setUpstream bool + org *config.Organization + want []string + }{ + { + name: "regular backup push", + org: &config.Organization{BackupLocation: true}, + want: []string{"push", "backup", "main", "--tags"}, + }, + { + name: "forced backup push", + org: &config.Organization{BackupLocation: true, ForcePush: true}, + want: []string{"push", "backup", "main", "--tags", "--force"}, + }, + { + name: "forced backup push with upstream", + setUpstream: true, + org: &config.Organization{BackupLocation: true, ForcePush: true}, + want: []string{"push", "-u", "backup", "main", "--tags", "--force"}, + }, + { + name: "force ignored for primary remote", + org: &config.Organization{ForcePush: true}, + want: []string{"push", "backup", "main", "--tags"}, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + t.Parallel() + got := pushBranchArgs("backup", "main", tt.setUpstream, tt.org) + if !reflect.DeepEqual(got, tt.want) { + t.Fatalf("pushBranchArgs() = %#v, want %#v", got, tt.want) + } + }) + } +} + func TestParseTagHashOutput_EmptyOutput(t *testing.T) { for _, in := range [][]byte{nil, []byte(""), []byte(" \n\t \n")} { hash, err := parseTagHashOutput(in, "v1.0.0", "origin") -- cgit v1.2.3