Skip to content

Commit

Permalink
fail if tree is dirty
Browse files Browse the repository at this point in the history
  • Loading branch information
joelanford committed Dec 6, 2019
1 parent 1a93711 commit 899400d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# IDE files
/.idea
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Flags:
--compare-imports Compare exported API differences of the imports in the repo.
-h, --help help for go-apidiff
--print-compatible Print compatible API changes
--repo-path string Path to root of git repository to compare (default "/home/joe/projects/work/kubernetes-sigs/controller-runtime")
--repo-path string Path to root of git repository to compare (default "/home/myuser/myproject")
```

## Example
Expand Down
7 changes: 7 additions & 0 deletions pkg/diff/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ func Run(opts Options) (*Diff, error) {
return nil, fmt.Errorf("failed to get git worktree: %w", err)
}


if stat, err := wt.Status(); err != nil {
return nil, fmt.Errorf("failed to get git status: %w", err)
} else if !stat.IsClean() {
return nil, fmt.Errorf("cannot compare with dirty git tree")
}

origRef, err := repo.Head()
if err != nil {
return nil, fmt.Errorf("failed to get current HEAD reference: %w", err)
Expand Down

0 comments on commit 899400d

Please sign in to comment.