Skip to content

Commit

Permalink
Move runAfterPush into GitActions and out of ChangelogPlugin.
Browse files Browse the repository at this point in the history
  • Loading branch information
nedtwigg committed Jul 6, 2024
1 parent 1ac58b7 commit 8d8d5e2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019-2023 DiffPlug
* Copyright (C) 2019-2024 DiffPlug
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -116,6 +116,21 @@ public void tagBranchPush() throws GitAPIException {
push(cfg.branch, RemoteRefUpdate.Status.OK);
}

public void runAfterPush() {
if (cfg.runAfterPush == null) {
return;
}
try (var runner = new ProcessRunner()) {
var result = runner.shell(formatTagMessage(cfg.runAfterPush));
System.out.write(result.stdOut());
System.out.flush();
System.err.write(result.stdErr());
System.err.flush();
} catch (IOException | InterruptedException e) {
throw new RuntimeException("runAfterPush failed: " + formatTagMessage(cfg.runAfterPush), e);
}
}

private String formatCommitMessage(final String commitMessage) {
return commitMessage.replace(GitCfg.COMMIT_MESSAGE_VERSION, model.versions().next());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,17 +247,7 @@ public void push() throws IOException, GitAPIException {
GitActions git = data.gitCfg.withChangelog(data.changelogFile, data.model());
git.addAndCommit();
git.tagBranchPush();
if (data.gitCfg.runAfterPush != null) {
try (var runner = new ProcessRunner()) {
var result = runner.shell(data.gitCfg.runAfterPush);
System.out.write(result.stdOut());
System.out.flush();
System.err.write(result.stdErr());
System.err.flush();
} catch (IOException | InterruptedException e) {
throw new GradleException("runAfterPush failed: " + data.gitCfg.runAfterPush, e);
}
}
git.runAfterPush();
}
}
}

0 comments on commit 8d8d5e2

Please sign in to comment.