check if local repository has committed changes
(gitClient *git.Client)
| 751 | |
| 752 | // check if local repository has committed changes |
| 753 | func hasCommits(gitClient *git.Client) (bool, error) { |
| 754 | hasCommitsCmd, err := gitClient.Command(context.Background(), "rev-parse", "HEAD") |
| 755 | if err != nil { |
| 756 | return false, err |
| 757 | } |
| 758 | _, err = hasCommitsCmd.Output() |
| 759 | if err == nil { |
| 760 | return true, nil |
| 761 | } |
| 762 | |
| 763 | var execError *exec.ExitError |
| 764 | if errors.As(err, &execError) { |
| 765 | exitCode := int(execError.ExitCode()) |
| 766 | if exitCode == 128 { |
| 767 | return false, nil |
| 768 | } |
| 769 | return false, err |
| 770 | } |
| 771 | return false, nil |
| 772 | } |
| 773 | |
| 774 | type repoType int |
| 775 |
no test coverage detected