repo sync: clearer error message with actionable hint (#7110)

Co-authored-by: Mislav Marohnić <mislav@github.com>
This commit is contained in:
Marco Carvalho 2023-03-28 13:43:31 -05:00 committed by GitHub
parent 1f0e53319e
commit 3b23978114
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View file

@ -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
}

View file

@ -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",