Skip to content
Permalink
Browse files
cli: add --atomic and --manual to git-pr-integrate
Reviewed-by: rwestberg
  • Loading branch information
edvbld committed Mar 18, 2021
1 parent e6502c8 commit 60eb3a6e02b360c68e2cbff7f69912346444644e
Showing with 28 additions and 1 deletion.
  1. +28 −1 cli/src/main/java/org/openjdk/skara/cli/pr/GitPrIntegrate.java
@@ -45,6 +45,14 @@ public class GitPrIntegrate {
.fullname("atomic")
.helptext("Integrate the pull request atomically")
.optional(),
Switch.shortcut("")
.fullname("auto")
.helptext("Configure the pull request for automatic integration")
.optional(),
Switch.shortcut("")
.fullname("manual")
.helptext("Configure the pull request for manual integration")
.optional(),
Switch.shortcut("")
.fullname("verbose")
.helptext("Turn on verbose output")
@@ -69,12 +77,27 @@ public class GitPrIntegrate {
public static void main(String[] args) throws IOException, InterruptedException {
var parser = new ArgumentParser("git-pr", flags, inputs);
var arguments = parse(parser, args);

var isAtomic = getSwitch("atomic", "integrate", arguments);
var isAuto = getSwitch("auto", "integrate", arguments);
var isManual = getSwitch("manual", "integrate", arguments);
if (isAuto && isManual) {
exit("error: cannot use both --auto and --manual");
}
if (isAtomic) {
if (isAuto) {
exit("error: cannot use both --atomic and --auto");
}
if (isManual) {
exit("error: cannot use both --atomic and --manual");
}
}

var repo = getRepo();
var uri = getURI(repo, arguments);
var host = getForge(uri, repo, arguments);
var id = pullRequestIdArgument(repo, arguments);
var pr = getPullRequest(uri, repo, host, id);
var isAtomic = getSwitch("atomic", "integrate", arguments);

var message = "/integrate";
if (isAtomic) {
@@ -85,6 +108,10 @@ public static void main(String[] args) throws IOException, InterruptedException
var sourceHash = repo.fetch(pr.repository().webUrl(), pr.fetchRef());
var mergeBase = repo.mergeBase(sourceHash, targetHash.get());
message += " " + mergeBase.hex();
} else if (isAuto) {
message += " auto";
} else if (isManual) {
message += " manual";
}

var integrateComment = pr.addComment(message);

1 comment on commit 60eb3a6

@openjdk-notifier
Copy link

@openjdk-notifier openjdk-notifier bot commented on 60eb3a6 Mar 18, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.