From c69b612e9d0d393c4efd27484e660d082e75058a Mon Sep 17 00:00:00 2001 From: Ellie Pratt Date: Thu, 29 Oct 2026 12:41:13 +1100 Subject: [PATCH 1/4] feat: Introduce a basic/default header for auto commited commits This should close https://github.com/GitJournal/git-auto-sync/issues/27 --- common/commit.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/common/commit.go b/common/commit.go index e6d4a30..ffcd885 100644 --- a/common/commit.go +++ b/common/commit.go @@ -63,6 +63,13 @@ func commit(repoConfig RepoConfig) error { sort.Strings(commitMsg) msg := strings.Join(commitMsg, "\n") + rawConfig, err := repo.Storer.Config() + autoSyncSection := rawConfig.Raw.Section("auto-sync") + header := autoSyncSection.Options.Get("header") + if header == "" { // Concerning that an explicit "" is getting overridden... + header = "Git Auto Sync" + } + msg = header+"\n"+msg if !hasChanges { return nil @@ -106,8 +113,7 @@ func GitCommand(repoConfig RepoConfig, args []string) (bytes.Buffer, error) { } func toEnvString(repoConfig RepoConfig) []string { - vals := repoConfig.Env - vals = append(vals, repoConfig.Env...) + vals := append([]string(nil), repoConfig.Env...) for _, s := range os.Environ() { parts := strings.Split(s, "=") From 6852cf7eeedf62f69a0bb8bd537e40af87a78a1c Mon Sep 17 00:00:00 2001 From: Ellie Pratt Date: Sun, 1 Nov 2026 14:15:46 +1100 Subject: [PATCH 2/4] build: Install to GOPATH with sudo This ensure's that the make process itself doesn't get root which is a security issue, but the files can still be moved into the appropriate directory even if only root has access to it. --- Makefile | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 1ab51ac..6e059cb 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ .PHONY: lint - + lint: golangci-lint run @@ -7,6 +7,7 @@ test: go test ./... install: - go install . + go build -o git-auto-sync . cd daemon && go build -o git-auto-sync-daemon . - cd daemon && mv git-auto-sync-daemon ${GOPATH}/bin/ + sudo mv git-auto-sync ${GOPATH} + cd daemon && sudo mv git-auto-sync-daemon ${GOPATH} From de067fd98ed9929ff1e96cf278aad11ed8e4bc27 Mon Sep 17 00:00:00 2001 From: Ellie Pratt Date: Sun, 1 Nov 2026 14:16:34 +1100 Subject: [PATCH 3/4] fix: Remove incorrect warning about SSH_AUTH_SOCK --- common/commit.go | 5 ----- 1 file changed, 5 deletions(-) diff --git a/common/commit.go b/common/commit.go index ffcd885..6aa1b75 100644 --- a/common/commit.go +++ b/common/commit.go @@ -2,7 +2,6 @@ package common import ( "bytes" - "fmt" "os" "os/exec" "sort" @@ -100,10 +99,6 @@ func GitCommand(repoConfig RepoConfig, args []string) (bytes.Buffer, error) { statusCmd.Env = toEnvString(repoConfig) err := statusCmd.Run() - if hasEnvVariable(os.Environ(), "SSH_AUTH_SOCK") && !hasEnvVariable(repoConfig.Env, "SSH_AUTH_SOCK") { - fmt.Println("WARNING: SSH_AUTH_SOCK env variable isn't being passed") - } - if err != nil { fullCmd := "git " + strings.Join(args, " ") err := tracerr.Errorf("%w: Command: %s\nEnv: %s\nStdOut: %s\nStdErr: %s", err, fullCmd, statusCmd.Env, outb.String(), errb.String()) From c595f764e716f117aecdbaeca5ff8d109271fc82 Mon Sep 17 00:00:00 2001 From: Ellie Pratt Date: Sun, 1 Nov 2026 14:17:54 +1100 Subject: [PATCH 4/4] feat: Add an -e / --env flag for the git-auto-sync watch command --- main.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/main.go b/main.go index 11ef3f1..874139f 100644 --- a/main.go +++ b/main.go @@ -25,6 +25,13 @@ func main() { Name: "watch", Aliases: []string{"monitor", "w", "m"}, Usage: "Monitor a folder for changes", + Flags: []cli.Flag{ + &cli.StringSliceFlag{ + Name: "env", + Aliases: []string{"e"}, + Usage: "Env variables to pass", + }, + }, Action: func(ctx *cli.Context) error { repoPath, err := os.Getwd() if err != nil { @@ -40,6 +47,7 @@ func main() { if err != nil { return tracerr.Wrap(err) } + cfg.Env = append(cfg.Env, ctx.StringSlice("env")...) return common.WatchForChanges(cfg) },