Skip to content
Permalink
Browse files
Fix git issues with merge bot
Reviewed-by: rwestberg
  • Loading branch information
edvbld committed Feb 5, 2020
1 parent 6cc53a0 commit 28d695bab04a36a89614827a6c9c9da6c48c2b79
Showing with 14 additions and 3 deletions.
  1. +14 −3 bots/merge/src/main/java/org/openjdk/skara/bots/merge/MergeBot.java
@@ -241,13 +241,22 @@ public void run(Path scratchPath) {
});
}


// Must set up user.name and user.email for pull to work
var username = fork.forge().currentUser().userName();
repo.config("user", "name", username, false);
repo.config("user", "email", username + "@openjdk.org", false);

// Sync personal fork
var remoteBranches = repo.remoteBranches(target.url().toString());
for (var branch : remoteBranches) {
var fetchHead = repo.fetch(target.url(), branch.hash().hex());
repo.push(fetchHead, fork.url(), branch.name());
}

// Must fetch once to update refs/heads
repo.fetchAll();

var prs = target.pullRequests();
var currentUser = target.forge().currentUser();

@@ -256,7 +265,7 @@ public void run(Path scratchPath) {
var fromRepo = spec.fromRepo();
var fromBranch = spec.fromBranch();

log.info("Trying to merge " + fromRepo.name() + ":" + fromBranch.name() + " to " + toBranch.name());
log.info("Deciding whether to merge " + fromRepo.name() + ":" + fromBranch.name() + " to " + toBranch.name());

// Checkout the branch to merge into
repo.pull(fork.url().toString(), toBranch.name());
@@ -273,11 +282,11 @@ public void run(Path scratchPath) {
var lines = pr.body().split("\n");
var head = new Hash(lines[1].substring(5, 45));
if (repo.contains(toBranch, head)) {
log.info("Closing resolved merge conflict PR " + pr.id());
log.info("Closing resolved merge conflict PR " + pr.id() + ", will try merge");
pr.addComment("Merge conflicts have been resolved, closing this PR");
pr.setState(PullRequest.State.CLOSED);
} else {
log.info("Outstanding unresolved merge already present");
log.info("Outstanding unresolved merge already present, will not merge");
shouldMerge = false;
}
break;
@@ -357,9 +366,11 @@ public void run(Path scratchPath) {
}

if (!shouldMerge) {
log.info("Will not merge " + fromRepo.name() + ":" + fromBranch.name() + " to " + toBranch.name());
continue;
}

log.info("Merging " + fromRepo.name() + ":" + fromBranch.name() + " to " + toBranch.name());
log.info("Fetching " + fromRepo.name() + ":" + fromBranch.name());
var fetchHead = repo.fetch(fromRepo.url(), fromBranch.name());
var head = repo.resolve(toBranch.name()).orElseThrow(() ->

0 comments on commit 28d695b

Please sign in to comment.