Skip to content
This repository has been archived by the owner on Apr 17, 2019. It is now read-only.

Commit

Permalink
mungegithub: Fixes #422
Browse files Browse the repository at this point in the history
At least attempts to fix one or two of the problems in #422.

Refresh the pull-request after we've done the tests to:
- Make sure it is still mergeable (doesn't have do-no-merge label or
still has lgtm label)
- The SHA hasn't changed, so that we don't commit something we haven't
tested
  • Loading branch information
Antoine Pelisse committed Nov 8, 2016
1 parent 6575026 commit 9d89f52
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion mungegithub/mungers/submit-queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -798,6 +798,7 @@ const (
ghE2ERunning = "Running github e2e tests a second time."
ghE2EFailed = "Second github e2e run failed."
unmergeableMilestone = "Milestone is for a future release and cannot be merged"
headCommitChanged = "This PR has changed since we ran the tests"
)

func getEarliestApprovedTime(obj *github.MungeObject) *time.Time {
Expand Down Expand Up @@ -1157,6 +1158,12 @@ func (sq *SubmitQueue) doGithubE2EAndMerge(obj *github.MungeObject) bool {
return true
}

sha, _, ok := obj.GetHeadAndBase()
if !ok {
glog.Errorf("%d: Unable to get SHA", *obj.Issue.Number)
sq.SetMergeStatus(obj, unknown)
return true
}
if interruptedObj != nil {
if interruptedObj.hasSHAChanged() {
// This PR will have to be rested.
Expand All @@ -1165,10 +1172,35 @@ func (sq *SubmitQueue) doGithubE2EAndMerge(obj *github.MungeObject) bool {
}
glog.Infof("Skipping retest since head and base sha match previous attempt!")
atomic.AddInt32(&sq.retestsAvoided, 1)
} else if sq.retestPR(obj) {
} else {
if sq.retestPR(obj) {
return true
}

err := obj.Refresh()
if err != nil {
glog.Errorf("%d: unknown err: %v", *obj.Issue.Number, err)
sq.SetMergeStatus(obj, unknown)
return true
}
}

// We shouldn't merge if it's not valid anymore
if !sq.validForMerge(obj) {
glog.Errorf("%d: Not mergeable anymore. Do not merge.", *obj.Issue.Number)
return true
}

if newSha, _, ok := obj.GetHeadAndBase(); !ok {
glog.Errorf("%d: Unable to get SHA", *obj.Issue.Number)
sq.SetMergeStatus(obj, unknown)
return true
} else if newSha != sha {
glog.Errorf("%d: Changed while running the test. Do not merge.", *obj.Issue.Number)
sq.SetMergeStatus(obj, headCommitChanged)
return false
}

if !sq.e2eStable(true) {
if sq.validForMerge(obj) {
sq.interruptedObj = newInterruptedObject(obj)
Expand Down

0 comments on commit 9d89f52

Please sign in to comment.