go-git
go-git copied to clipboard
Best way to check if repo has any remote commits?
Currently i have been using :
// Check the remote commit history for a Git repository
func repoHasRemoteCommits(r *git.Repository) bool {
var hasRemoteCommits bool
revision := "origin/master"
_, err := r.ResolveRevision(plumbing.Revision(revision))
hasRemoteCommits = err == nil
return hasRemoteCommits
}
Does this approach cover all edge cases? wondering if there is a better way as well.