summaryrefslogtreecommitdiff
path: root/internal/config
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2025-07-03 22:38:37 +0300
committerPaul Buetow <paul@buetow.org>2025-07-03 22:38:37 +0300
commit64095a2c8d5a3a72c55d7bd0737c5542a5aeee09 (patch)
tree0af2501374550e8fdadd4df00d245c6260c0305d /internal/config
parent0c072d964d4d07e69d1c0af1f3b09f9adc543571 (diff)
feat: add SSH backup locations with --backup flagv0.2.0
- Add support for SSH backup locations (e.g., paul@server:git/) - Backup locations are one-way only (push only, never pull) - Automatic bare repository creation on SSH servers - Add --backup flag to opt-in to backup syncing - Backup locations are disabled by default for offline resilience - Update version to 0.2.0 This allows users to maintain private backups on home servers that may be offline without affecting regular sync operations. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Diffstat (limited to 'internal/config')
-rw-r--r--internal/config/config.go24
1 files changed, 18 insertions, 6 deletions
diff --git a/internal/config/config.go b/internal/config/config.go
index ef8e3b6..7dedee7 100644
--- a/internal/config/config.go
+++ b/internal/config/config.go
@@ -10,10 +10,11 @@ import (
// Organization represents a git organization with its host and name
type Organization struct {
- Host string `json:"host"`
- Name string `json:"name"`
- GitHubToken string `json:"github_token,omitempty"`
- CodebergToken string `json:"codeberg_token,omitempty"`
+ Host string `json:"host"`
+ Name string `json:"name"`
+ GitHubToken string `json:"github_token,omitempty"`
+ CodebergToken string `json:"codeberg_token,omitempty"`
+ BackupLocation bool `json:"backupLocation,omitempty"` // Mark this as a backup-only destination
}
// Config holds the application configuration
@@ -83,8 +84,8 @@ func (c *Config) Validate() error {
if org.Host == "" {
return fmt.Errorf("organization %d: missing host", i)
}
- // Name can be empty for file:// URLs
- if org.Name == "" && !strings.HasPrefix(org.Host, "file://") {
+ // Name can be empty for file:// URLs or SSH backup locations
+ if org.Name == "" && !strings.HasPrefix(org.Host, "file://") && !org.IsSSH() {
return fmt.Errorf("organization %d: missing name", i)
}
}
@@ -94,6 +95,10 @@ func (c *Config) Validate() error {
// GetGitURL returns the git URL for an organization
func (o *Organization) GetGitURL() string {
+ // For SSH backup locations with empty name, just return the host
+ if o.IsSSH() && o.Name == "" {
+ return o.Host
+ }
return fmt.Sprintf("%s:%s", o.Host, o.Name)
}
@@ -137,3 +142,10 @@ func (c *Config) FindGitHubOrg() *Organization {
return nil
}
+// IsSSH checks if the organization is a plain SSH location
+func (o *Organization) IsSSH() bool {
+ // Check if it's not a known git hosting service and contains SSH-like syntax
+ return !o.IsGitHub() && !o.IsCodeberg() && !strings.HasPrefix(o.Host, "file://") &&
+ (strings.Contains(o.Host, "@") || strings.Contains(o.Host, ":"))
+}
+