The Enforce Author Hook is rejecting any cherry picked commits that I am trying to bring into a feature branch. For example, a bug is fixed on master and I need that fix asap so I cherry pick it into my feature branch. When I try to push, the Enforce Author Hook rejects it.
Is this the expected behavior (i.e. you cannot use cherry pick with this hook) or is it a bug?
Hi Carolyn,
How do you know it was a cherry pick (or rebase or commit amend)? As far as Git is concerned they are completely different commits, based on the SHA. Sure the message is the same, but that doesn't necessarily mean anything.
This is the difficulty in trying to enforce a centralized workflow in the distributed world of Git. I've warned other people about this:
https://answers.atlassian.com/questions/249972/stash-and-git-s-user-name
I might try to contact the vendor directly and see if they have any thoughts, but I'm fairly confident there's nothing technical you can do, at least not without making the plugin broken in other ways. For example you could make it so that you could amend the message with a magic keyword and it lets you through, but obviously that's bad for security.
http://www.risingoak.com/contact.html
I've pinged them on Twitter for you.
For now you could:
1. Disable the hook, push, and then enable it again.
2. Cherry-pick with --no-commit and then using your own details.
3. Filter-branch the commits and update them with you as the author.
http://stackoverflow.com/questions/750172/how-do-i-change-the-author-of-a-commit-in-git
Charles
Thanks Charles! I didn't know about the second option (cherry picking with --no-commit), that should work just fine for now. In the future, I will look into ditching this particular hook and switching to a hook that just checks the domain of the author's email, e.g. *@mycompany.com.
I initially enabled this hook because everyone is new to git and some people were getting their author information mixed up between their open source github repositories and their work repositories. This seemed like an easy way to detect that they had misconfigured their repo.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Carolyn, I am the author of this plugin.
Charles is basically right. Cherry pick with --no-commit is the answer on this one, because from a strict audit perspective, while the original author made that commit on another branch, it was introduced on this branch by you. You may not need this type of strict checking if you don't have particularly stringent audit requirements.
If you need a starting point for writing a hook that only checks the email domain, you may be able to use the source code for the Enforce Author Hook, which is now available under the Apache License at https://github.com/RisingOak/stash-enforce-author-hook. It solves the painful parts of finding what new commits are part of the push, and looping over their author information, etc.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Cosmin, I appreciate the link to the original source. That will save me a ton of time! :-)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for jumping in Cosmin.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.