githooks

Git server hook: get contents of files being pushed?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-12 08:34:35
问题 I am trying to enforce some coding rules in my team. To that end, I've written a number of client-side hooks, which work all right, but now I want the same checks to run when a developer pushes their modifications to the central repository. But they don't work. Here is what I want to do: I want to traverse the pushed files line by line, check for coding conventions violations and if I find any, reject the push, also showing the line numbers + violations. In my pre-commit client side hook I

Git post-receive hook not working

拥有回忆 提交于 2019-12-12 08:22:59
问题 We're using git with a central repo (using Gitosis). I've created a post-receive hook to generate an email to the dev mailing list whenever changes are pushed to the central repo, and to generate documentation from the documentation folder in the git repo. Therefore, in ~git/ I've got a directory, we'll call it 'a' that contains a clone of the git repo. The post-receive hook looks like: #!/bin/bash cd ~git/repositories/a.git . ~git/post-receive-email &> /dev/null ( cd ~git/a && git pull &>

View commits on a new branch in the update hook

孤街醉人 提交于 2019-12-12 07:27:13
问题 I wrote an update hook (server-side) which checks all commit messages (To check if there is an Issue Id) There is an extract of my python code (update.py): [...] if newrev == "0000000000000000000000000000000000000000": newrev_type = "delete" elif oldrev == "0000000000000000000000000000000000000000": newrev_type = "create" # HERE IS MY QUESTION, I want to get the commits SHA-1 :-) else: POPnewrev_type = os.popen("git cat-file -t " + newrev) newrev_type = POPnewrev_type.read()[0:-1] # get the

update local bare repository A after push from another repository B to remote C

守給你的承諾、 提交于 2019-12-12 04:38:40
问题 I cannot find any hook that is invoked from repository B (executes bash script on B) if I do a push from B to remote repo C. I want to take some action after push - I want to cd to another bare repo A on same machine as B is and do fetch from remote C. I can write a script wrapping git push, cd, git fetch but ideally I would like to execute cd, fetch from hook. I am in B ( A and B are on same machine, I work in B and do push to remote C, A is tracking C so I want to cd into it and fetch/reset

git commit -a bypasses git hook when it shouldn't

喜夏-厌秋 提交于 2019-12-12 01:55:08
问题 I have a git hook for commit-msg which works quite happily when I run git commit -m "MSG HERE" but if I run git commit -a Which triggers committing using your text editor it skips the hook. Any suggestions on how to fix this? My hook is as follows #!/bin/bash if ! egrep -q 'DAVE-[0-9]+' $1 ; then echo "No Jira Issue Number found" >&2 exit 1 fi if [[ "$(wc -c $1 | awk '{print $1}')" -le 20 ]] ; then echo "Commit message too short" >&2 exit 1 fi 回答1: I can't reproduce your problem, so my guess

exit 1 in pre-commit doesn't abort git commit?

送分小仙女□ 提交于 2019-12-12 01:25:15
问题 I'm aborting git commit if a certain condition is met. check if my commit has 'import pdb' in emacs/git? #!/bin/sh git diff --cached --no-renames --name-status --diff-filter=AM | while read st file; do case "$file" in *.py) if git show ":$file" | grep -E "^[^#]*\bimport[[:space:]]+pdb\b"; then echo "$file: has import pdb" exit 1 fi;; esac done git diff --cached --name-status --diff-filter=ACM | while read st file; do if grep "#[[:space:]]*@test" "$file"; then echo "$file: has @test" exit 1 fi

Git hook: add a new file to repo if a new branch is created

眉间皱痕 提交于 2019-12-12 00:40:28
问题 I am writing a git hook which checks if a new branch is created, and if so then add some predefined files to the repo for that new branch(Some config files). However because the branch is actually in the process of being created, my logic fails. Currently I am doing this in a post-receive hook, which looks something like this: #!/bin/sh read oldrev newrev refname branch=$(git rev-parse --symbolic --abbrev-ref $refname) echo "branch is $branch" echo "oldrev is $oldrev and newrev is $newrev" #

Git hook pre-push prompt to squash commits first

自闭症网瘾萝莉.ら 提交于 2019-12-11 14:36:32
问题 I'm not sure if I'm going about this the correct way. Sorta new to Git and GitKraken. I want to force others to squash their feature branch commits before pushing and creating a pull request. So I've tried the following pre-push git hook but even when I squash first it still thinks there are multiple commits. What am I missing? Thanks! #!/bin/sh # An example hook script to verify what is about to be pushed. Called by "git # push" after it has checked the remote status, but before anything has

Is it possible to run a pre-receive style hooks in Gerrit?

こ雲淡風輕ζ 提交于 2019-12-11 14:31:52
问题 We are planning to have some policies that will ensure we don't accept commits that won't adhere to commit message policy. This policy is specific to a repo. Is it possible to run pre-receive style hooks in Gerrit where we can run these policies before the patch gets created? 回答1: Yes, Gerrit has its own hook mechanism included via the hooks plugin so it's possible to block the push if some policy is not valid. Consider also to use the Git::Hooks. We use it and it's really good. Using Git:

Git hook to update superproject on submodule change?

爱⌒轻易说出口 提交于 2019-12-11 10:25:01
问题 I have three git repositories: A , B , and C . C is a superproject including submodules A and B , tracking each submodule's respective master branch. When the master branch of A or B is changed, I must do the following in C : git submodule update --remote git add A git add B git commit -m "Update submodule A or B" git push At this point an automated build and deploy from C is executed. I'm looking for ways to streamline this process. Ideally, any commit to the master branch of A or B would