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.11.0-SNAPSHOT</version.unleash-scm-provider-api>

- ScmProviderGit.java:
  - method tag(TagRequest request):
    - prepend the PreTagCommitMessage with scmMessagePrefix
      if this is set.

- update CHANGELOG.md
  • Loading branch information
mhoffrog committed Feb 18, 2024
1 parent 041a82c commit ad51be3
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 6 deletions.
20 changes: 19 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,23 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- TBD


## [2.3.1]
<!-- !!! Align version in badge URLs as well !!! -->
[![2.3.1 Badge](https://img.shields.io/nexus/r/io.github.mavenplugins/unleash-scm-provider-git?server=https://s01.oss.sonatype.org&label=Maven%20Central&queryOpt=:v=2.3.1)](https://central.sonatype.com/artifact/io.github.mavenplugins/unleash-scm-provider-git/2.3.1)

### Summary
- Enhance the tag comment to prepend with scmMessagePrefix if this is set - #2

### Updates
- pom.xml:
- refer to `unleash-scm-provider-api 2.11.0`

- ScmProviderGit.java:
- method tag(TagRequest request):
- prepend the PreTagCommitMessage with scmMessagePrefix
if this is set.


## [2.3.0]
<!-- !!! Align version in badge URLs as well !!! -->
[![2.3.0 Badge](https://img.shields.io/nexus/r/io.github.mavenplugins/unleash-scm-provider-git?server=https://s01.oss.sonatype.org&label=Maven%20Central&queryOpt=:v=2.3.0)](https://central.sonatype.com/artifact/io.github.mavenplugins/unleash-scm-provider-git/2.3.0)
Expand Down Expand Up @@ -100,5 +117,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- This is just a dummy placeholder to make the parser of GHCICD/release-notes-from-changelog@v1 happy!
-->

[Unreleased]: https://github.com/mavenplugins/unleash-scm-provider-git/compare/v2.3.0..HEAD
[Unreleased]: https://github.com/mavenplugins/unleash-scm-provider-git/compare/v2.3.1..HEAD
[2.3.1]: https://github.com/mavenplugins/unleash-scm-provider-git/compare/v2.3.0..v2.3.1
[2.3.0]: https://github.com/mavenplugins/unleash-scm-provider-git/releases/tag/v2.3.0
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.11.0-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 ad51be3

Please sign in to comment.