We have a use case where we would like to execute some custom actions when the "Merge" button is pushed in the Stash user interface. The end-goal is to update a version number that we can use in our gradle build scripts to be stamped in any builds done in our code.
Outside of Stash, we currently achieve this with pre-commit hooks, that modify our version number in a properties file. We have also tested and are considering using git tags instead. However, now that we've moved to stash. The "Merge" is handled outside of our local repos and thus our git hooks do not run. So I'm looking for some guidance. In Stash,
I hope my questions are clear! Thanks!
Hi Jeremy. Glad to hear it. :)
Hello, sorry for the delayed response. We did in the end go with a more automated version calculation using tags and git describe. The suggestion was good, put us on the right path. Our version number is tagged on releases and otherwise fully calculated via git describe.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jeremy,
How did you go with git describe?
I have to second Jason's suggestion. And perhaps to elaborate checking in the version into Git, while convenient for builds, is something that is going to be difficult to implement and is largely redundant given the information Git has. It should be possible to write a very simple plugin or build script that attaches a tag on each pull request merge, which will then assist your git describe (or whatever) to work out the minor version.
Here are some examples of people using git tags in Gradle.
https://github.com/palantir/gradle-gitsemver
http://ryanharter.com/blog/2013/07/30/automatic-versioning-with-git-and-gradle/
Good luck,
Charles
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
We do want our version number to change/increment with every merge to our main branch, but not necessarily every actual commit. We are in fact using the git describe, but it isn't helpful in this case.
We have Major.Minor.Patch-commit
- Major is manually updated
- Minor should be updated once per pull request/merge
- Patch is manually updated
- the commit number is taken from the git describe, so developers who are making multiple commits can track builds they make manually.
The minor number is the one we are interested in. I will look at doing some git describe or log magic to see if I can't extrapolate the same information.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
We do want our version number to change/increment with every merge to our main branch, but not necessarily every actual commit. We are in fact using the git describe, but it isn't helpful in this case.
We have Major.Minor.Patch-commit
- Major is manually updated
- Minor should be updated once per pull request/merge
- Patch is manually updated
- the commit number is taken from the git describe, so developers who are making multiple commits can track builds they make manually.
The minor number is the one we are interested in. I will look at doing some git describe or log magic to see if I can't extrapolate the same information.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm not sure if your requirements for a version number has to be incremental but you may be interested in using git describe --tags --always HEAD instead of updating a file every commit or creating many tags.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.