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

git.branch character replacer #138

Closed
taorg opened this issue Nov 23, 2014 · 7 comments
Closed

git.branch character replacer #138

taorg opened this issue Nov 23, 2014 · 7 comments

Comments

@taorg
Copy link

taorg commented Nov 23, 2014

If you work with git-flow, branches get names like this "feature/feature_name"
It would be nice to create jar o ear names with finalNames like this ${epack}-${git.commit.id.describe}-${git.commit.time}-${git.branch}

But the caracter "/" is not valid as filename, it would be nice to have the possibility to replace this character.

@ktoso
Copy link
Collaborator

ktoso commented Nov 24, 2014

Hm... interesting use case. I guess it shouldn't bee too hard too add - more like an output filter with possible aded filters from configuration.

If you'd be up to implementing this I'd love to see a PR with this feature :-)

@taorg
Copy link
Author

taorg commented Nov 24, 2014

Ok, you are right. I'll give it a try.
;-)
Bit busy, but I'll do it.

@troinine
Copy link

We have similar issues with other fields thus it would be nice to be able to filter any of the git properties, not just git.branch. We use the commit message field and therefore someone can easily end up putting some special characters like double quotes which will fail in our case (Spring Boot app with YAML properties).

@TheSnoozer
Copy link
Collaborator

From a plugin perspective...what comes close to this feature is:
https://code.google.com/archive/p/maven-replacer-plugin/

The Build Helper Mojo also has something similar:
http://www.mojohaus.org/build-helper-maven-plugin/regex-property-mojo.html#replacement
However I would separate the concerns of validation and replacement...

It might be even useful to restrict the replacement to a specific property:

<replacement>
    <property>git.branch</property>
    <token>(?:[^\/]|\/\/)+</token>
    <value>$1-$2</value>
</replacement>

Not sure if it would be smarter to include another Mojo or execute it inside the git-commit-id-plugin.
However there should be something like ```failOnUnableToReplacePropertyInfo``

TheSnoozer pushed a commit to TheSnoozer/git-commit-id-maven-plugin that referenced this issue Jul 29, 2017
@TheSnoozer
Copy link
Collaborator

I have implemented this feature and it will be available in version 2.2.3.

Example:

<replacementProperties>
  <replacementProperty>
    <property>git.branch</property>
    <token>^([^\/]*)\/([^\/]*)$</token>
    <value>$1-$2</value>
  </replacementProperty>
</replacementProperties>

Please checkout the readme for additional details!

TheSnoozer pushed a commit that referenced this issue Jul 29, 2017
 allow to replace certain characters with regex #138
@TheSnoozer TheSnoozer added this to the 2.2.3 milestone Jul 29, 2017
@berniefitz82
Copy link

I'm having a similar issue where local machines git.branch returns just the branch name but during CI/CD it returns origin/branch-name

@TheSnoozer
Copy link
Collaborator

please create a new issue with all relevant details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants