Skip to content

Commit

Permalink
Fetch before checkout
Browse files Browse the repository at this point in the history
  • Loading branch information
aledbf committed Sep 19, 2022
1 parent d2ba552 commit dd21a39
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions components/content-service/pkg/initializer/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,12 @@ func (ws *GitInitializer) realizeCloneTarget(ctx context.Context) (err error) {
log.WithError(err).WithField("remoteURI", ws.RemoteURI).WithField("branch", ws.CloneTarget).Error("Remote branch doesn't exist.")
return err
}

if err := ws.Git(ctx, "fetch", "origin/"+ws.CloneTarget); err != nil {
log.WithError(err).WithField("remoteURI", ws.RemoteURI).WithField("branch", ws.CloneTarget).Error("Cannot fetch remote branch")
return err
}

// create local branch based on specific remote branch
if err := ws.Git(ctx, "checkout", "-B", ws.CloneTarget, "origin/"+ws.CloneTarget); err != nil {
log.WithError(err).WithField("remoteURI", ws.RemoteURI).WithField("branch", ws.CloneTarget).Error("Cannot checkout remote branch.")
Expand Down

0 comments on commit dd21a39

Please sign in to comment.