We are planning to convert our SVN repo to Git via stash and we would like to convert all the existing shell-based hooks to Stash. Can someone tell what would be the best way to get these items in Stash for a Pre-commit hook?
REPO=passed into the hook
PARENT_BRANCH=(I'm not sure what you mean?)
BRANCH=passed into the hook
DIR=Not sure what you mean here? If you're talking about the Git directory you shouldn't need that if you're just trying to get the above information which you can from our APIs/
I have previously written a hook that checks the file size of everything in a push, which I think will cover most of these except the file content and how to wire them together.
Does that help?
Charles - You are correct, I am talking about Java-based hook in Stash. So, the idea is to convert our existing SVN-hooks written in shell/perl to Java but before we can start we need the variables to play with. The list that I pasted was the list of variables used by shell-scripts and if I get them in Java-based hook (for Stash) then I will be more than happy.
AUTHOR= com.atlassian.stash.history. HistoryService.getChangeset(context.getRepository(), refId).getAuthor()
LAST_CHANGED_AUTHOR (for FILE_NAMES)= ?
If you can provide info how to get variabes with '?' for a pre-commit Java-based hook that will work.
When I am calling FILE_NAMES/FILE_CONTENTS/... and other variables I am trying to access the data which is getting committed from the developer in "THIS" commit which hasnt been committed yet (since we are in pre-rcv state), is that possible ?
I agree that calls will work in all cases but I can only access OLD commits, not the data related to CURRENT commit which hasnt been committed yet.
Ok, just to make sure we're on the same page:
1. Developer makes changes locally
2. Developer commits changes locally
3. Developer pushes changes to Stash
4. Stash accepts or rejects changes basd on pre-receive commit
You said "hasnt been committed yet". The only time that happens is before step 2 - as the developer is committing. Stash obviously can't stop this from happening, as they're working on their machine. You can use Git pre-commit hooks but that requires some mechanism to install and manage them, something Stash can't help with. One of the advantages of using pre-receive hooks is that it's central and can be controlled in one place.
On the Stash team we use both types, and check the pre-commit hooks into a repository and ask developers to symlink to them once so that they get updated over time.
If you actually mean "hasn't been accepted in Stash yet" then we're still talking about a pre-receive commit. In that case the commits are technically _in_ the Git repository on the server, but the refs (branches) haven't been updated yet. This allows you to look at the contents of the commits as long as you don't expect the refs to have updated yet, which is what I was suggesting earlier with toHash and fromHash.
Let me know if that helps?
You mind creating a separate Question so we can track it more easily? Although maybe see if this helps first:
Stop: Articles and permission Article-writing permissions are given to Leaders, Marketplace Vendors, Solutions Partners, Atlassian Team members, and those who are Level 4 + above. But for any aspir...
Connect with like-minded Atlassian users at free events near you!Find an event
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.Host an event
You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events