check if local repository has committed changes
(gitClient *git.Client)
| 752 | |
| 753 | // check if local repository has committed changes |
| 754 | func hasCommits(gitClient *git.Client) (bool, error) { |
| 755 | hasCommitsCmd, err := gitClient.Command(context.Background(), "rev-parse", "HEAD") |
| 756 | if err != nil { |
| 757 | return false, err |
| 758 | } |
| 759 | _, err = hasCommitsCmd.Output() |
| 760 | if err == nil { |
| 761 | return true, nil |
| 762 | } |
| 763 | |
| 764 | if execError, ok := errors.AsType[*exec.ExitError](err); ok { |
| 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