MCPcopy Create free account
hub / github.com/cli/cli / hasCommits

Function hasCommits

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

check if local repository has committed changes

(gitClient *git.Client)

Source from the content-addressed store, hash-verified

752
753// check if local repository has committed changes
754func 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
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