Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not use pull in merge bot #401

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -226,7 +226,7 @@ public boolean concurrentWith(WorkItem other) {
public void run(Path scratchPath) {
try {
var sanitizedUrl =
URLEncoder.encode(target.webUrl().toString(), StandardCharsets.UTF_8);
URLEncoder.encode(fork.webUrl().toString(), StandardCharsets.UTF_8);
var dir = storage.resolve(sanitizedUrl);

Repository repo = null;
@@ -241,12 +241,6 @@ 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) {
@@ -268,8 +262,11 @@ public void run(Path scratchPath) {
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());
repo.checkout(toBranch, false);
var remoteBranch = new Branch(repo.upstreamFor(toBranch).orElseThrow(() ->
new IllegalStateException("Could not get remote branch name for " + toBranch.name())
));
repo.merge(remoteBranch); // should always be a fast-forward merge

// Check if merge conflict pull request is present
var shouldMerge = true;
@@ -102,6 +102,7 @@ Hash amend(String message,
void delete(Branch b) throws IOException;
void rebase(Hash hash, String committerName, String committerEmail) throws IOException;
void merge(Hash hash) throws IOException;
void merge(Branch branch) throws IOException;
void merge(Hash hash, String strategy) throws IOException;
void abortMerge() throws IOException;
void addRemote(String name, String path) throws IOException;
@@ -916,19 +916,28 @@ public Repository copyTo(Path destination) throws IOException {

@Override
public void merge(Hash h) throws IOException {
merge(h, null);
merge(h.hex(), null);
}

@Override
public void merge(Branch b) throws IOException {
merge(b.name(), null);
}

@Override
public void merge(Hash h, String strategy) throws IOException {
merge(h.hex(), strategy);
}

private void merge(String ref, String strategy) throws IOException {
var cmd = new ArrayList<String>();
cmd.addAll(List.of("git", "-c", "user.name=unused", "-c", "user.email=unused",
"merge", "--no-commit"));
if (strategy != null) {
cmd.add("-s");
cmd.add(strategy);
}
cmd.add(h.hex());
cmd.add(ref);
try (var p = capture(cmd)) {
await(p);
}
@@ -857,15 +857,24 @@ public Repository copyTo(Path destination) throws IOException {

@Override
public void merge(Hash h) throws IOException {
merge(h, null);
merge(h.hex(), null);
}

@Override
public void merge(Hash h, String stragegy) throws IOException {
public void merge(Branch b) throws IOException {
merge(b.name(), null);
}

@Override
public void merge(Hash h, String strategy) throws IOException {
merge(h.hex(), strategy);
}

private void merge(String ref, String strategy) throws IOException {
var cmd = new ArrayList<String>();
cmd.addAll(List.of("hg", "merge", "--rev=" + h.hex()));
if (stragegy != null) {
cmd.add("--tool=" + stragegy);
cmd.addAll(List.of("hg", "merge", "--rev=" + ref));
if (strategy != null) {
cmd.add("--tool=" + strategy);
}
try (var p = capture(cmd)) {
await(p);