fix: improve fetching commit SHAs (#5312)

Signed-off-by: Alexander Matyushentsev <AMatyushentsev@gmail.com>
This commit is contained in:
Alexander Matyushentsev 2021-01-25 23:13:27 -08:00 committed by GitHub
parent dbadd74b42
commit d8b545d107
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -263,8 +263,9 @@ func (m *nativeGitClient) IsLFSEnabled() bool {
// Fetch fetches latest updates from origin
func (m *nativeGitClient) Fetch(revision string) error {
var err error
if revision != "" {
err = m.runCredentialedCmd("git", "fetch", "origin", revision)
// Some git providers don't support fetching commit sha
if revision != "" && !IsCommitSHA(revision) && !IsTruncatedCommitSHA(revision) {
err = m.runCredentialedCmd("git", "fetch", "origin", revision, "--tags", "--force")
} else {
err = m.runCredentialedCmd("git", "fetch", "origin", "--tags", "--force")
}