githooks

Git hook to detect file changes that contain a certain string

ぐ巨炮叔叔 提交于 2019-12-04 14:32:12
I want to warn a user if their code includes a certain string and alert people via email. Right now I'm using a post-receive hook because the detection needs to be done on the server side. I am updating a server-side repository and running something like git diff-tree -r --name-only --no-commit-id $2 | xargs grep foo to detect bad string "foo." Problems with this approach: I don't like maintaining and entire working version of the repository server-side It scans the entire file, not just the changes. edit I solved this problem replacing the above with: git show $2 | grep ^+ ... Is there a

git ignore filemode config isn't working

拥有回忆 提交于 2019-12-04 14:01:58
I am using gitolite git server on a ubuntu linux server. I used a hook that will be called on every push and will update a server's directory(which include live site's source code). Now, whenever I change something on my local pc and push the changes to server, the hook is being called and the pull request are being executed fine. But, problem is, the files which were updated, are now having changed permission. Like: rwxrwxr_x (before) rwx_____x (After) After few searches, I did came up with this solution . I did tried it with both my global git config and repository specific config settings.

Difference between pre-push and pre-receive hook in git?

淺唱寂寞╮ 提交于 2019-12-04 12:57:36
问题 Is there a difference between pre-push and pre-receive hook in git, in terms of use case or working logic? The only difference I could understand from their documentation was in terms of the input they receive - 1. Pre-Push : Information about what is to be pushed is provided on the hook's standard input with lines of the form - local ref SP local sha1 SP remote ref SP remote sha1 LF 2. Pre-receive : For each ref to be updated it receives on standard input a line of the format - old-value SP

Gerrit change-merged Hook

北城余情 提交于 2019-12-04 12:38:12
I use git as my version control system and have set up a Gerrit site to do the code review. I would like to create a hook to do the following: When the admin clicks the Submit button, a file (called version.txt ) should be modified. Script should open the file. Find the following text (where the ID may change) #version Change-Id: Ie1411d50f6beb885bc3d3b7d8c587635e1446c18 Replace the Change-Id with the Change-Id of the new patch. So, if the patch being merged has the Change-Id: I1c25f7b967084008b69a6a8aefa6e3bb32967b82 then the version.txt file should contain the following string after the

Compress JS/CSS files on deploy using Git

安稳与你 提交于 2019-12-04 12:36:41
问题 I'm kinda new to git. Also, this is my first project where I'm automating the deployment process. So far it's been bliss to being able to do git push dev and have files uploaded, config files copied, etc. Now I want to minify JS/CSS files when I push to my dev server. I was thinking of installing some command-line tool on the server for minifying and for-each js/css file on certain folder, compress and save, on a post-receive git hook. Is this a good approach? (cause I've read about adding

Dissallow deletion of Master branch in git

送分小仙女□ 提交于 2019-12-04 11:08:00
问题 I'm trying to setup a git hook that will disallow anyone to delete the master, alpha, and beta branches of our repository. Can anyone help with this? I have never done a git hook so i don't want to try my luck in developing my own without a little help. Thanks in advance. 回答1: Straightforward with a pre-receive hook. Assuming you're using a bare central repository, place the following code in your-repo.git/hooks/pre-receive , and don't forget to chmod +x your-repo.git/hooks/pre-receive . #!

How to create a tag on GitHub when a PR is merged?

此生再无相见时 提交于 2019-12-04 10:44:42
My current workflow requires a version Bump on every PR, so I would like to take advantage of that and automatically create a tag on GitHub on every PR merge, so it appears in the "release" section. I've seen that I can write a post-merge hook. My doubt is if that hook runs locally in my machine, remotely on GitHub, or both (given that I merge the PR on GitHub, and not locally. What's the case? I can write a post-merge hook. My doubt is if that hook runs locally in my machine, remotely on GitHub, or both It will certainly not run on GitHub (that wouldn't be safe for GitHub to run any user

Symbolic link to a hook in git

流过昼夜 提交于 2019-12-04 07:27:21
问题 I wrote my own custom post-merge hook, now I added a "hooks" directory to my main project folder (since git doesn't track changes in .git/hooks), somewhere I read that I can make a symbolic link from hooks to .git/hooks so I don't have to copy the file from one folder to the other every time someone changes it so I tried: ln -s -f hooks/post-merge .git/hooks/post-merge But it doesn't seem to work, any ideas why? "ln hooks/post-merge .git/hooks/post-merge" works fine but making a hard link is

aborting git pre-commit hook when var_dump present

旧城冷巷雨未停 提交于 2019-12-04 07:01:34
I am trying (but failing miserably) to make a git pre-commit hook that checks for the presence of a var_dump in my modified files and exits if it finds one. The problem that I'm having is that it appears to always be aborting the commit. Here is the contents of my pre-commit file: VAR=$(git diff | grep -w "var_dump") if [ -z $VAR ]; then echo "You've left a var_dump in one of your files! Aborting commit..." exit 1 fi First of all, note that plain git diff gives the difference between the working tree and the index (i.e. what can still be staged), not what is about to be committed. Use git diff

Pre-commit hook file staging for commit

ぃ、小莉子 提交于 2019-12-04 06:08:27
问题 If you have a pre-commit hook in Git that creates (or modifies) a file, does that file need to be staged for it to be committed? For example, if I have a pre-commit hook that creates a minified version of some code, do I need to git add that minified version for it to be included in the commit? 回答1: Yes, you would have to add the file yourself to the index. The pre-commit hook allows you to run some commands before committing, that doesn't mean that git will keep track of the modifications