Skip to content

Commit

Permalink
fix: migrate as code default branch (#4478)
Browse files Browse the repository at this point in the history
  • Loading branch information
sguiheux committed Jul 22, 2019
1 parent 7437ccc commit d1bc77d
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions engine/repositories/processor_push.go
Expand Up @@ -17,19 +17,6 @@ func (s *Service) processPush(op *sdk.Operation) error {
if err != nil {
return sdk.WrapError(err, "unable to process gitclone")
}
//Check is repo has diverged
hasDiverged, err := gitRepo.HasDiverged()
if err != nil {
log.Error("Repositories> processPush> HasDiverged> [%s] Error: %v", op.UUID, err)
return sdk.WrapError(err, "HasDiverged> [%s] Error: %v", op.UUID, err)
}

if hasDiverged {
if err := gitRepo.ResetHard("origin/" + currentBranch); err != nil {
log.Error("Repositories> processPush> ResetHard> [%s] Error: %v", op.UUID, err)
return sdk.WrapError(err, "ResetHard> [%s] Error: %v", op.UUID, err)
}
}

if op.Setup.Push.ToBranch == "" {
op.Setup.Push.ToBranch = op.RepositoryInfo.DefaultBranch
Expand All @@ -43,6 +30,12 @@ func (s *Service) processPush(op *sdk.Operation) error {
}
}

// Reset hard default branch
if err := gitRepo.ResetHard("origin/" + op.RepositoryInfo.DefaultBranch); err != nil {
log.Error("Repositories> processPush> ResetHard> [%s] Error: %v", op.UUID, err)
return err
}

// Create new branch
if err := gitRepo.CheckoutNewBranch(op.Setup.Push.FromBranch); err != nil {
log.Error("Repositories> processPush> Create new branch %s> [%s] error %v", op.Setup.Push.FromBranch, op.UUID, err)
Expand Down

0 comments on commit d1bc77d

Please sign in to comment.