package git import "strconv" // GetHash returns the commit hash for the current HEAD func (g *Git) GetHash() (string, error) { out, err := g.Execute("rev-parse", "HEAD") if err != nil { return "", err } return out, nil } // GetCommitRemote returns the commit hash for the current HEAD on the remote func (g *Git) GetCommitRemote() (string, error) { out, err := g.Execute("ls-remote", "origin", "HEAD") if err != nil { return "", err } return out, nil } // GetCommitsAhead returns the number of commits ahead of main func (g *Git) GetCommitsAhead() (int, error) { out, err := g.Execute("rev-list", "--count", "HEAD", "^"+g.MainBranch) if err != nil { return 0, err } return strconv.Atoi(out) }