Skip to content

Commit

Permalink
move print and fetch outside of the if clause
Browse files Browse the repository at this point in the history
  • Loading branch information
cooperspencer committed Aug 30, 2024
1 parent b0e321c commit 36fd205
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions local/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,8 @@ func updateRepository(reponame string, auth transport.AuthMethod, dry bool, l ty
return err
}
}
sub.Info().
Msgf("pulling %s", types.Green(reponame))
if !l.Bare {
w, err := r.Worktree()
if err != nil {
Expand All @@ -358,24 +360,17 @@ func updateRepository(reponame string, auth transport.AuthMethod, dry bool, l ty
return err
}
}
sub.Info().
Msgf("pulling %s", types.Green(reponame))

err = w.Pull(&git.PullOptions{Auth: auth, RemoteName: "origin", SingleBranch: false})
if err == git.NoErrAlreadyUpToDate {
err = nil
} else {
return err
}
// if everything was ok, fetch everything
err = r.Fetch(&git.FetchOptions{Auth: auth, RemoteName: "origin", RefSpecs: []config.RefSpec{"+refs/*:refs/*"}})
if err != nil {
return err
}
} else {
sub.Info().
Msgf("pulling %s", types.Green(reponame))
err = r.Fetch(&git.FetchOptions{Auth: auth, RemoteName: "origin", RefSpecs: []config.RefSpec{"+refs/*:refs/*"}})
}
// if everything was ok, fetch everything
err = r.Fetch(&git.FetchOptions{Auth: auth, RemoteName: "origin", RefSpecs: []config.RefSpec{"+refs/*:refs/*"}})
if err != nil {
return err
}
}
}
Expand Down

0 comments on commit 36fd205

Please sign in to comment.