Skip to content

Commit

Permalink
#2: Enhance the tag comment to prepend with scmMessagePrefix if this …
Browse files Browse the repository at this point in the history
…is set

- pom.xml:
  - refer to <version.unleash-scm-provider-api>2.10.1-SNAPSHOT</version.unleash-scm-provider-api>

- ScmProviderGit.java:
  - method tag(TagRequest request):
    - prepend the PreTagCommitMessage with scmMessagePrefix
      if this is set.
  • Loading branch information
mhoffrog committed Feb 18, 2024
1 parent 041a82c commit edf30dc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
<version.junit>4.12</version.junit>
<version.mockito-all>1.10.19</version.mockito-all>
<version.slf4j>1.7.2</version.slf4j>
<version.unleash-scm-provider-api>2.10.0</version.unleash-scm-provider-api>
<version.unleash-scm-provider-api>2.10.1-SNAPSHOT</version.unleash-scm-provider-api>
</properties>

<dependencies>
Expand Down Expand Up @@ -106,7 +106,7 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.github.mavenplugins</groupId>
<groupId>${groupId.unleash-maven-plugin}</groupId>
<artifactId>unleash-scm-provider-api</artifactId>
<version>${version.unleash-scm-provider-api}</version>
</dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ public String push(PushRequest request) throws ScmException {
if (failureStatus != null) {
StringBuilder message = new StringBuilder(
"Could not push local changes to the remote repository due to the following error: [").append(failureStatus)
.append("] ");
.append("] ");
if (reason != null) {
message.append(reason);
}
Expand Down Expand Up @@ -528,6 +528,8 @@ public String tag(TagRequest request) throws ScmException {
StringBuilder message = new StringBuilder(LOG_PREFIX).append("Tag info:\n");
message.append("\t- WORKING_DIR: ").append(this.workingDir.getAbsolutePath()).append('\n');
message.append("\t- TAG_NAME: ").append(request.getTagName()).append('\n');
message.append("\t- PRE_TAG_COMMIT_MESSAGE: ").append(request.getPreTagCommitMessage()).append('\n');
message.append("\t- SCM_MESSAGE_PREFIX: ").append(request.getScmMessagePrefix()).append('\n');
message.append("\t- USE_WORKING_COPY: ").append(request.tagFromWorkingCopy()).append('\n');
if (request.tagFromWorkingCopy()) {
message.append("\t- COMMIT_BEFORE_TAGGING: ").append(request.commitBeforeTagging()).append('\n');
Expand All @@ -541,8 +543,13 @@ public String tag(TagRequest request) throws ScmException {

if (request.tagFromWorkingCopy()) {
// 1. commit the changes (no merging because we stay local!)
String preTagCommitMessage = request.getPreTagCommitMessage()
.or("Preparation for tag creation (Tag name: '" + request.getTagName() + "').");
final StringBuilder defaultPreTagCommitMessage = new StringBuilder(
"Preparation for tag creation (Tag name: '" + request.getTagName() + "').");
// prepend scmMessagePrefix if needed
if (request.getScmMessagePrefix().isPresent()) {
defaultPreTagCommitMessage.insert(0, request.getScmMessagePrefix().get());
}
String preTagCommitMessage = request.getPreTagCommitMessage().or(defaultPreTagCommitMessage.toString());
Builder builder = CommitRequest.builder().message(preTagCommitMessage);
if (request.includeUntrackedFiles()) {
builder.includeUntrackedFiles();
Expand Down

0 comments on commit edf30dc

Please sign in to comment.