go-git icon indicating copy to clipboard operation
go-git copied to clipboard

Best way to check if repo has any remote commits?

Open rnag opened this issue 4 years ago • 0 comments

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.

rnag avatar Dec 02 '19 19:12 rnag