githooks

Asynchronous git hook?

青春壹個敷衍的年華 提交于 2019-12-05 15:49:36
问题 I execute unit tests on post-receive but don't want the user to wait for it. I tried the suggestions from the git-user mailing list ("just & it") but this is not working: https://groups.google.com/forum/#!topic/git-users/CFshrDgYYzE git seems to wait for the bash script to exit even if I just put this in hooks/post-receive: exec-unit-tests.sh & 回答1: This worked for me. & and the stdout & stderr pipe must be closed: long-running-command >&- 2>&- & In order to put the command in the background,

Is there a way to make a local branch immutable?

浪尽此生 提交于 2019-12-05 13:41:20
I'm extremely stupid and sometimes I merge a "feature branch" in the wrong master branch as opposed to the develop branch and that of course leads to pain and suffering. Since it's the second time already that this has been happening, I wonder if there's a way for me to make a branch immutable locally. I've already tried with this pre-commit hook to prevent me from directly making commits on said branch, but this is not stopping merges as in: git checkout master git merge wip Is there a way to prevent all possible changes to a local branch? If not, is it at least possible to prevent changes

Commit message hook on github

一个人想着一个人 提交于 2019-12-05 10:48:17
I am trying to setup a pre-receive hook in github that I used to use on STASH. In STASH, I had a pre-receive hook that used to enforce "A custom commit message that should have a JIRA number included in it". Now, I am trying to understand what would be the best way to do something similar on github. If I split it up, it would be: Requiring a custom commit message. Every commit should include an existing JIRA. Enforce this on any pull request as well. Eg: TEST-1 Adding the first commit message. Can anybody here help me, how can this be done ? GitHub only offers webhooks , which allows you to

Executing a git-hook after pull --rebase

我的未来我决定 提交于 2019-12-05 10:05:41
I'd like to have a hook run after doing git pull --rebase in order to check if a certain file was changed. Something along the lines of this hook. I initially thought of using the post-rewrite hook, however that only works when commits are being rewritten, and won't run when the pull operation simply fast-forwards the branch, which is very often. Any ideas will be appreciated. I ran strace git pull --rebase on a local repository, which performed a fast-forward update... First, rewinding head to replay your work on top of it... Fast-forwarded master to b0a60c3302973ca1878d149d61f2f612c8f27fac.

Multiple git hooks for the same trigger

三世轮回 提交于 2019-12-05 09:42:57
I have a post-checkout hook that I use locally in all of my repos (it renames my tmux session to repo-name/branch-name ) For a project I am working on, we just added a post-checkout hook that we're asking the whole team to use. I don't want to add my personal hook's logic to the team-wide hook, because it's not useful to everyone, but I also don't want to give it up. Is there a way to have more than one script execute on a single git-hook trigger? I want every git checkout to execute the teamwide post-checkout hook and execute my personal post-checkout hook. I can't have two files named the

git: who pushed in post-receive hook

好久不见. 提交于 2019-12-05 09:15:53
How do I determine who pushed to the repository? I.e. Somebody does git push origin master and in the post-receive hook on the origin repo I need to use the name or e-mail of Somebody. If you're using the SSH protocol to push changes to the server, with each user having their own account on the server, then your script should be running as the user who's doing the push. So, you should be able to use whoami or id -un to get the username of the person doing the push. If you are not using this setup, the best way to keep track of who is pushing is probably using Gitolite , a powerful Git

Modify file before commit with pre-commit hook

a 夏天 提交于 2019-12-05 05:43:37
I am trying to write a pre-commit hook that modify a line in my code but I do not know even from where to start. The problem is: I have a KEY public static final String APP_KEY = ""; //DELETE THE KEY BEFORE COMMIT!!! In order to avoid publishing the KEY to the repository I've think maybe git hooks are the thing we need instead of delete the key manually. I've take a look at Customizing git hooks but I do not know how to write the hook. Is there a way to before commit the changes, delete the KEy and after the commit write the key again? VonC That would be done with a content filter driver : a

Gitlab post-receive/update hook to forward a commit to another git repo

自闭症网瘾萝莉.ら 提交于 2019-12-05 05:08:36
问题 In a team we have a gitlab set up that is avialable only to our team and is meant for development purposes, pushing, branching etc and we have an official git repo to which we would like to mirror commits only from master branch (stable). I know that this can be done with use of server-side git hooks but how specifically can I do that so that the developers won't have to type anything extra and the hook will be set on gitlab (no on developers' machines - local repos) ? 回答1: Take a look at

Git global hooks and project hooks

a 夏天 提交于 2019-12-05 04:24:18
Currently I'm using git config --global core.hooksPath ~/.git/hooks to configure global hooks for all my git projects. But if those projects contain hooks, they're not run. I'd like to run the global hook as well as the project hooks. Thank you! I think the only way is for your global hooks to check if a corresponding local hook exists and run it. This is not a complete solution because some hooks ( pre-push , for example) accepts standard input in addition to command line parameters. If one of the hooks consumes the standard input the other doesn't have a chance. In order to execute the local

git hook: ensure each merge into the master has a message also the automatic merges

白昼怎懂夜的黑 提交于 2019-12-05 03:47:19
问题 In our deployment process on of the last steps will be a merge of the release branch into the master branch. I want to ensure via a hook, that each of these merges needs a manual message in the commit, so the person merging has the opportunity to write down what general changes will go into the master with this merge. Aka Change.log or release notes. I found so far that the hook I would need would be the pre-merge. https://gitorious.org/git/mjg/commit/c15bfac6d3f5a28b3cd5745fef71e7f93bc1f8a4