Hi Karl,
The `post-merge` is used for read only purposes, and is also executed when
you run `git pull` (as `git pull` is effectively a `fetch` + `merge`).
Off the top of my hat, I'd do a `release.sh` (or similar) script, which
would merge the `feature` branch in `develop`, update the
`VersionNumber` file, add it and commit it.
Maybe with the following flow:
check you are on a feature branch or provide the branch name as
argument and check it is a feature branch
check you have the latest develop
check your feature branch is ahead of develop or if it needs to be
rebased (if this matters to you)
go on develop
merge the branch
update the version number file
commit it
push
would it solve your issue?
Regards,
Ghislain
On 22 March 2018 at 20:50, Karl Gemayel <[email protected]> wrote:
> Say I have two branches: `develop` and `feature`.
>
> Assume I also have a file called `VersionNumber` which has the following
> content:
>
> BUILD_NUMBER 1
>
> I want to use Git hooks so that, when I merge `feature` into `develop`,
> the `BUILD_NUMBER` field gets incremented automatically.
>
> I thought about the following process using the `post-merge` hook:
>
> 1. Check that branch being merged into is `develop`
> 2. Update the `VersionNumber` file by incrementing `BUILD_NUMBER` by 1
> 3. Add the updated file: `git add VersionNumber`
> 4. Amend the commit: `git commit --amend -C HEAD --no-verify`
>
> It all works fine until the final command. Git says I can't amend the
> commit in the middle of a merge (which is surprising to me, since I thought
> this was `post-merge`).
>
> Any advice on how I can do this (using `post-merge` or any other hook for
> that matter)?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Git for human beings" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>
--
You received this message because you are subscribed to the Google Groups "Git
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.