summaryrefslogtreecommitdiff
path: root/internal/sync/git_operations_test.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-07-22 09:54:49 +0300
committerPaul Buetow <paul@buetow.org>2026-07-22 09:54:49 +0300
commitea3b3b2ffc4a1d3c335994e22056a957cd962d21 (patch)
tree601aecf10b5d4a4721e895698d64e97b47561b5f /internal/sync/git_operations_test.go
parent813077134132a62d0c9c73c7020ed734ff9add0b (diff)
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 <noreply@anthropic.com>
Diffstat (limited to 'internal/sync/git_operations_test.go')
-rw-r--r--internal/sync/git_operations_test.go46
1 files changed, 46 insertions, 0 deletions
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")