summaryrefslogtreecommitdiff
path: root/internal/config
diff options
context:
space:
mode:
Diffstat (limited to 'internal/config')
-rw-r--r--internal/config/config.go4
-rw-r--r--internal/config/config_test.go18
2 files changed, 22 insertions, 0 deletions
diff --git a/internal/config/config.go b/internal/config/config.go
index afccf33..024513f 100644
--- a/internal/config/config.go
+++ b/internal/config/config.go
@@ -19,6 +19,7 @@ type Organization struct {
GitHubToken string `json:"github_token,omitempty"`
CodebergToken string `json:"codeberg_token,omitempty"`
BackupLocation bool `json:"backupLocation,omitempty"` // Mark this as a backup-only destination
+ ForcePush bool `json:"forcePush,omitempty"` // Force-update branches and tags at this backup destination
DescriptionSyncHost string `json:"descriptionSyncHost,omitempty"` // SSH host with shell access for updating backup descriptions
DescriptionSyncRoot string `json:"descriptionSyncRoot,omitempty"` // Filesystem path on DescriptionSyncHost where bare repos live
}
@@ -116,6 +117,9 @@ func (c *Config) Validate() error {
if org.Name == "" && !strings.HasPrefix(org.Host, "file://") && !org.IsSSH() {
return fmt.Errorf("organization %d: missing name", i)
}
+ if org.ForcePush && !org.BackupLocation {
+ return fmt.Errorf("organization %d: forcePush requires backupLocation", i)
+ }
hasDescriptionSyncHost := strings.TrimSpace(org.DescriptionSyncHost) != ""
hasDescriptionSyncRoot := strings.TrimSpace(org.DescriptionSyncRoot) != ""
if hasDescriptionSyncHost != hasDescriptionSyncRoot {
diff --git a/internal/config/config_test.go b/internal/config/config_test.go
index eb81626..da700ca 100644
--- a/internal/config/config_test.go
+++ b/internal/config/config_test.go
@@ -49,6 +49,24 @@ func TestValidate_DescriptionSyncFieldsMustBePaired(t *testing.T) {
}
}
+func TestValidate_ForcePushRequiresBackupLocation(t *testing.T) {
+ t.Parallel()
+
+ cfg := &Config{
+ Organizations: []Organization{
+ {Host: "git@github.com", Name: "test-user", ForcePush: true},
+ },
+ }
+
+ err := cfg.Validate()
+ if err == nil {
+ t.Fatal("Validate() error = nil, want forcePush validation error")
+ }
+ if !strings.Contains(err.Error(), "forcePush requires backupLocation") {
+ t.Fatalf("Validate() error = %q, want forcePush context", err)
+ }
+}
+
func TestFindOrganization_ReturnsPointerToStoredElement(t *testing.T) {
t.Parallel()