githooks

Can GIT_COMMITTER_DATE be customized inside a git hook?

不想你离开。 提交于 2019-12-01 21:08:51
I'd like to manually control the git commit timestamp so that my GIT_COMMITTER_DATE always matches the GIT_AUTHOR_DATE. I've seen many solutions using filter-branch to rewrite history, but I'd rather be proactive about this and put the logic in a git hook so that it always matches going forward. But I find that while these variables work fine if defined in the environment where git is invoked, they do not seem to have any effect when they are defined inside the pre-commit git hook. Eg: # this works if run directly on cmd line, but not inside the pre-commit hook export GIT_AUTHOR_DATE='Mon, 11

git hooks - regenerate a file and add it to each commit?

 ̄綄美尐妖づ 提交于 2019-12-01 19:27:44
I'd like to automatically generate a file and add it to a commit if it has changed. Is it possible, if so, what hooks should I use? Context: I'm programming a CSS library. It has several CSS files, and at the end I want to produce a compacted and minimized version. Right now my workflow is: Modify the css files x.css and y.css git add x.css y.css Execute minimize.sh which parses all the css files on my lib, minimizes them and produces a min.css file git add min.css git commit -m 'modified x and y doing foo and bar' I would like to have steps 3 and 4 done automatically via a git hook. Is that

Can GIT_COMMITTER_DATE be customized inside a git hook?

ぃ、小莉子 提交于 2019-12-01 19:23:11
问题 I'd like to manually control the git commit timestamp so that my GIT_COMMITTER_DATE always matches the GIT_AUTHOR_DATE. I've seen many solutions using filter-branch to rewrite history, but I'd rather be proactive about this and put the logic in a git hook so that it always matches going forward. But I find that while these variables work fine if defined in the environment where git is invoked, they do not seem to have any effect when they are defined inside the pre-commit git hook. Eg: # this

git pre-commit hook, add file into index

若如初见. 提交于 2019-12-01 13:44:51
I'm trying to write a simple pre-commit hook to check if a file was modified, if so, compress it and add it into the current index, something like this #!/bin/sh # was the file modified? mf='git status | grep jquery.detectBrowser.js' # is the non-compressed file in the staging area? if [ $mf != "" ] then # alert the user echo "Javascript file modified, YUI Compressor will begin now." # go to rhino cd $HOME/apps/rhino/yuicompressor-2.4.7/build # compress my file java -jar yuicompressor-2.4.7.jar ~/www/jquery.detectBrowser.js/jquery.detectBrowser.js -o ~/www/jquery.detectBrowser.js/jquery

How to print all the staged file names using ruby git pre-commit hook?

老子叫甜甜 提交于 2019-12-01 13:25:24
I just started playing around with git hooks using Ruby(as am more comfortable with ruby). Can anyone tell me how to print all the staged file names? and can anyone tell me or give me a good resource where I can understand how will git search through the staged files and search for a particular text? VonC One possible command is (from " Git pre-commit hook : changed/added files "): git diff --cached --name-only --diff-filter=ACM That is what I recommended for that other ruby pre-commit hook " And you could use it with " jish/pre-commit ". 来源: https://stackoverflow.com/questions/26955973/how-to

Is there a way to check that a git tag matches the content of the corresponding commit?

拜拜、爱过 提交于 2019-12-01 12:45:16
In the company I work for, some projects have an project.info file which contains the current version of the program/library/whatever. Actually, when someone wants to tag a version, he must first ensure that the project.info file (which is versionned) is up-to-date and contains the same version than the name of the tag he is about to create. No need to say that this is error prone. We work on a clients-server workflow for git (all commits go to the same central repository) so I wonder: is there a way (a hook perhaps ?) to make this central repository refuse tags for which the project.info does

post-receive hook fails - any chance to see why?

扶醉桌前 提交于 2019-12-01 11:28:47
I'm implementing this approach to send updates to my website: created bare repository to push to $ mkdir website.git && cd website.git $ git init --bare And added the following hook: $ mkdir /var/www/example.com $ cat > hooks/post-receive #!/bin/sh GIT_WORK_TREE=/var/www/example.com git checkout -f $ chmod +x hooks/post-receive when I push to website.git from local repository, the update works fine. But no files are added into /var/www/example.com . How can I investigate what could be wrong here? Any kind of log or something? EDIT ---------------------- The problem is fixed if I push to master

how to add the pre-receive hook in server side in GitLab?

最后都变了- 提交于 2019-12-01 11:12:27
I am trying to restrict the binary file (EXE, DLL, PDF) committing in our gitlab. So I need to add the hook to restrict it in globally. How can I do this? Is Pre-receive hook is suitable for this? Is this place is correct to add the hook? /opt/gitlab/embedded/service/gitlab-shell/hooks/pre-receive Any helps appreciated! As I commented, for per-project, use custom hooks : ( Chained hooks support ) See the exact steps at " How can I add hooks to gitlab? ", and involve the create of a dedicate repo.git/custom_hooks subfolder. But that is per-repository, not for all repos. You would need to add

Is there a way to check that a git tag matches the content of the corresponding commit?

*爱你&永不变心* 提交于 2019-12-01 10:47:33
问题 In the company I work for, some projects have an project.info file which contains the current version of the program/library/whatever. Actually, when someone wants to tag a version, he must first ensure that the project.info file (which is versionned) is up-to-date and contains the same version than the name of the tag he is about to create. No need to say that this is error prone. We work on a clients-server workflow for git (all commits go to the same central repository) so I wonder: is

post-receive hook permission denied “unable to create file” error

最后都变了- 提交于 2019-12-01 09:35:32
Just got gitolite installed on my webserver and am trying to get a post-receive hook that can point the git dir in apache's direction. This is what my post-receive hook looks like. Got this script from the Using Git to manage a web site . #!/bin/sh echo "post-receive example.com triggered" GIT_WORK_TREE=/srv/sites/example.com/public git checkout -f I've also tried: #!/bin/sh echo "post-receive example.com triggered" unset GIT_INDEX_FILE export GIT_WORK_TREE=/srv/sites/example.com/public export GIT_DIR=/home/git/repositories/example.com.git git checkout -f This is the error response i'm getting