From cf7dbf5bee89af1b755f9b930dc8183fe26d07cf Mon Sep 17 00:00:00 2001 From: lew Date: Wed, 11 Feb 2026 17:49:02 +0000 Subject: [PATCH] feat(sync): adds --message flag for manual commit message --- README.md | 3 +++ cmd/sync.go | 19 +++++++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 7042449..8eabc32 100644 --- a/README.md +++ b/README.md @@ -322,6 +322,9 @@ If you're ahead of your Git repo, syncing will add your changes, commit them, an ```bash # Sync with Git pda sync + +# With a custom commit message. +pda sync -m "added production credentials" ``` `pda!` supports some automation via its config. There are options for `git.auto_commit`, `git.auto_fetch`, and `git.auto_push`. Any of these operations will slow down `pda!` because it means versioning with every change, but it does effectively guarantee never managing to desync oneself and requiring manual fixes, and reduces the frequency with which one will need to manually run the sync command. diff --git a/cmd/sync.go b/cmd/sync.go index 510a5dd..de0c233 100644 --- a/cmd/sync.go +++ b/cmd/sync.go @@ -34,15 +34,17 @@ var syncCmd = &cobra.Command{ Short: "Manually sync your stores with Git", SilenceUsage: true, RunE: func(cmd *cobra.Command, args []string) error { - return sync(true) + msg, _ := cmd.Flags().GetString("message") + return sync(true, msg) }, } func init() { + syncCmd.Flags().StringP("message", "m", "", "Custom commit message (defaults to timestamp)") rootCmd.AddCommand(syncCmd) } -func sync(manual bool) error { +func sync(manual bool, customMsg string) error { repoDir, err := ensureVCSInitialized() if err != nil { return err @@ -62,7 +64,13 @@ func sync(manual bool) error { return err } if changed { - msg := fmt.Sprintf("sync: %s", time.Now().UTC().Format(time.RFC3339)) + msg := customMsg + if msg == "" { + msg = fmt.Sprintf("sync: %s", time.Now().UTC().Format(time.RFC3339)) + if manual { + printHint("use -m to set a custom commit message") + } + } if err := runGit(repoDir, "commit", "-m", msg); err != nil { return err } @@ -109,6 +117,9 @@ func sync(manual bool) error { } } + if manual { + okf("in sync!") + } return nil } @@ -119,5 +130,5 @@ func autoSync() error { if _, err := ensureVCSInitialized(); err != nil { return nil } - return sync(false) + return sync(false, "") }