Skip to content

Commit

Permalink
Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
walkowif committed Apr 24, 2024
1 parent 168e1b2 commit 136d94d
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions cmd/mirror.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,16 +244,19 @@ func GitPlainClone(gitDirectory string, cloneOptions *git.CloneOptions, reposito
func GitFetchBranches(sourceRemote *git.Remote, sourceAuthentication Authentication, repositoryName string) error {
gitFetchOptions := GetFetchOptions("refs/heads/*:refs/heads/*", sourceAuthentication)
err := sourceRemote.Fetch(gitFetchOptions)
if err == gittransport.ErrAuthenticationRequired {
switch err {
case gittransport.ErrAuthenticationRequired:
log.Error("[", repositoryName, "] Authentication required.")
return backoff.Permanent(err)
} else if err == git.NoErrAlreadyUpToDate {
case git.NoErrAlreadyUpToDate:
// Terminate backoff with no error in case the branch is already up-to-date.
// This can occur if source or destination repository has only one branch.
log.Info("[", repositoryName, "] Repository up-to-date.")
return nil
} else if err != nil {
default:
log.Warn("[", repositoryName, "] Retrying fetching branches because the following error occurred: ", err)
return err
}
return err
}

// PushRefs pushes refs defined in refSpecString to destination remote and is retried in case of error.
Expand Down Expand Up @@ -379,7 +382,9 @@ func MirrorRepository(messages chan MirrorStatus, source, destination string, so
pushTagsBackoff := backoff.NewExponentialBackOff()
pushTagsBackoff.MaxElapsedTime = time.Minute
err = backoff.Retry(
func() error { return PushRefs(repository, destinationAuth, "+"+refTagPrefix+"*:"+refTagPrefix+"*", destination) },
func() error {
return PushRefs(repository, destinationAuth, "+"+refTagPrefix+"*:"+refTagPrefix+"*", destination)
},
pushTagsBackoff,
)
ProcessError(err, "pushing all tags to ", destination, &allErrors)
Expand Down

0 comments on commit 136d94d

Please sign in to comment.