MCPcopy
hub / github.com/cli/cli / hasCommits

Function hasCommits

pkg/cmd/repo/create/create.go:753–772  ·  view source on GitHub ↗

check if local repository has committed changes

(gitClient *git.Client)

Source from the content-addressed store, hash-verified

751
752// check if local repository has committed changes
753func 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
774type repoType int
775

Callers 1

createFromLocalFunction · 0.85

Calls 3

CommandMethod · 0.80
OutputMethod · 0.65
ExitCodeMethod · 0.65

Tested by

no test coverage detected