From 3b2397811400a6bc5d98f9e66cd95d34c377bb0e Mon Sep 17 00:00:00 2001 From: Marco Carvalho Date: Tue, 28 Mar 2023 13:43:31 -0500 Subject: [PATCH] repo sync: clearer error message with actionable hint (#7110) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Mislav Marohnić --- pkg/cmd/repo/sync/sync.go | 2 +- pkg/cmd/repo/sync/sync_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/cmd/repo/sync/sync.go b/pkg/cmd/repo/sync/sync.go index eebec4389..1f734b543 100644 --- a/pkg/cmd/repo/sync/sync.go +++ b/pkg/cmd/repo/sync/sync.go @@ -256,7 +256,7 @@ func executeLocalRepoSync(srcRepo ghrepo.Interface, remote string, opts *SyncOpt } if currentBranch == branch { if isDirty, err := git.IsDirty(); err == nil && isDirty { - return fmt.Errorf("can't sync because there are local changes; please stash them before trying again") + return fmt.Errorf("refusing to sync due to uncommitted/untracked local changes\ntip: use `git stash --all` before retrying the sync and run `git stash pop` afterwards") } else if err != nil { return err } diff --git a/pkg/cmd/repo/sync/sync_test.go b/pkg/cmd/repo/sync/sync_test.go index 9e7e5b5b1..90a216607 100644 --- a/pkg/cmd/repo/sync/sync_test.go +++ b/pkg/cmd/repo/sync/sync_test.go @@ -229,7 +229,7 @@ func Test_SyncRun(t *testing.T) { mgc.On("IsDirty").Return(true, nil).Once() }, wantErr: true, - errMsg: "can't sync because there are local changes; please stash them before trying again", + errMsg: "refusing to sync due to uncommitted/untracked local changes\ntip: use `git stash --all` before retrying the sync and run `git stash pop` afterwards", }, { name: "sync local repo with parent - existing branch, non-current",