summaryrefslogtreecommitdiff
path: root/internal/sync/git_operations.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/sync/git_operations.go')
-rw-r--r--internal/sync/git_operations.go16
1 files changed, 13 insertions, 3 deletions
diff --git a/internal/sync/git_operations.go b/internal/sync/git_operations.go
index 1acfb95..e5c68d9 100644
--- a/internal/sync/git_operations.go
+++ b/internal/sync/git_operations.go
@@ -36,10 +36,20 @@ func checkForMergeConflicts(repoPath string) (bool, string, error) {
return hasConflicts, statusStr, nil
}
-// stashChanges stashes uncommitted changes
-func stashChanges(repoPath string) error {
+// stashChanges stashes uncommitted changes.
+// Returns true only when a stash entry was created.
+func stashChanges(repoPath string) (bool, error) {
fmt.Println(" Stashing uncommitted changes...")
- return gitCommand(repoPath, "stash", "push", "-m", "gitsyncer-auto-stash").Run()
+ output, err := gitCommand(repoPath, "stash", "push", "-m", "gitsyncer-auto-stash").CombinedOutput()
+ if err != nil {
+ return false, err
+ }
+
+ if strings.Contains(string(output), "No local changes to save") {
+ return false, nil
+ }
+
+ return true, nil
}
// popStash attempts to pop the stash (used in defer)