Skip to content

Commit 8e3da16

Browse files
authored
feat: check if there are changes found in the git tree (#3)
1 parent f79180b commit 8e3da16

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

main.go

+9
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,15 @@ func run(c config) error {
8484
return xerrors.Errorf("unable to get a worktree based on the given fs: %w", err)
8585
}
8686

87+
s, err := w.Status()
88+
if err != nil {
89+
return xerrors.Errorf("unable to get the working tree status: %w", err)
90+
}
91+
92+
if !s.IsClean() {
93+
return xerrors.New("the repository is dirty: commit all changes before running 'cob'")
94+
}
95+
8796
err = w.Reset(&git.ResetOptions{Commit: *prev, Mode: git.HardReset})
8897
if err != nil {
8998
return xerrors.Errorf("failed to reset the worktree to a previous commit: %w", err)

0 commit comments

Comments
 (0)