githooks

Git hooks : applying `git config core.hooksPath`

梦想的初衷 提交于 2019-12-21 07:38:58
问题 I have a git repository with a pre-commit hook set up : my-repo |- .git |- hooks |- pre-commit # I made this file executable Until there, everything works. The hook is running when I commit. ================================= I now run git config core.hooksPath ./git-config/hooks in my-repo . The folder structure is this one : my-repo |- .git |- hooks |- git-config |- hooks |- pre-commit # I made this file executable as well What happens is : the new pre-commit script doesn't run on commit the

Git hooks : applying `git config core.hooksPath`

拈花ヽ惹草 提交于 2019-12-21 07:38:40
问题 I have a git repository with a pre-commit hook set up : my-repo |- .git |- hooks |- pre-commit # I made this file executable Until there, everything works. The hook is running when I commit. ================================= I now run git config core.hooksPath ./git-config/hooks in my-repo . The folder structure is this one : my-repo |- .git |- hooks |- git-config |- hooks |- pre-commit # I made this file executable as well What happens is : the new pre-commit script doesn't run on commit the

Git hook for diff sqlite table

我的梦境 提交于 2019-12-21 06:18:56
问题 I have a Sqlite db in a Git repository. Today I wanted to do a diff of a view in two different commits. I did it this way: $ sqlite3 -list file.sqlite "SELECT * FROM contact_list_detailed" >/tmp/newlist $ git checkout 51c24d13c file.sqlite $ sqlite3 -list file.sqlite "SELECT * FROM contact_list_detailed" >/tmp/oldlist $ git checkout -- file.sqlite $ diff /tmp/oldlist /tmp/newlist It works and I could script it if I want. But are there any "nice" ways of doing this with hooks? 回答1: You would

Git: convert carriage return \r to new line \n with git hook?

假如想象 提交于 2019-12-21 04:19:10
问题 A fellow coder uses a Windows computer that is putting carriage returns everywhere in our source. Is there a way to write a git hook that converts all \r\n to \n ? Note I haven't used git hooks before, so a little extra hand-holding might go a long way :) 回答1: The simplest thing is to set core.autocrlf to false on The Windows side. (that way Git won't do any conversion and will keep the eol untouched). On the unix side, a core.autocrlf set to true could help restore the proper eol. As

Testing what is about to be committed in a pre-commit hook

若如初见. 提交于 2019-12-20 18:04:25
问题 The internet is absolutely littered with incorrect and non-ideal answers to this question. This is unfortunate because you would think this would be a common thing you would want to do. The problem: When a pre-commit hook runs, the repository might not be clean. So if you naively run your tests, they will not be against what you're committing, but whatever dirt happens to be in your working tree. The obvious thing to do is to git stash --keep-index --include-untracked at the start of the pre

block push of trivial merge to git server

别等时光非礼了梦想. 提交于 2019-12-20 08:44:04
问题 A while back I asked our developers to use rebase instead of merge before pushing. Eliminating trivial merges makes for a much easier to follow commit graph (ie: gitk, git log). Sometimes folks still accidentally do trivial merges, then push. Does anyone have handy or have tips for writing a server-side hook that blocks trivial merges? By "trivial merge", I mean a merge without conflicts. Here's an example, and here's a better explanation of a trivial merge in git. Update Wed Nov 10 01:26:41

block push of trivial merge to git server

落花浮王杯 提交于 2019-12-20 08:42:16
问题 A while back I asked our developers to use rebase instead of merge before pushing. Eliminating trivial merges makes for a much easier to follow commit graph (ie: gitk, git log). Sometimes folks still accidentally do trivial merges, then push. Does anyone have handy or have tips for writing a server-side hook that blocks trivial merges? By "trivial merge", I mean a merge without conflicts. Here's an example, and here's a better explanation of a trivial merge in git. Update Wed Nov 10 01:26:41

Git hook: enable echoing commands

空扰寡人 提交于 2019-12-19 17:35:11
问题 is there any way to enable echo in git hook /var/git/repositories/project.git/hooks/post-update #!/bin/bash unset GIT_DIR; echo '========post-update hook=========' cd /var/project; git reset --hard; git checkout testing; git pull; chmod -R 774 ./lib update-apps desired git push output on another mashine: #git push ... Writing objects: 100% (10/10), 5.98 KiB, done. Total 10 (delta 3), reused 8 (delta 1) ========post-update hook========= cd /var/project git reset --hard git checkout testing git

How to replace local git hooks with updated versions with git init?

对着背影说爱祢 提交于 2019-12-19 05:45:15
问题 I have exactly the same question as this user here: git init template, replacing modified hooks I have a new template file in my global git hooks. However, the original template file was already loaded, so git init does not overwrite. I read the same here, this appears to be the correct git behaviour: From http://www.cs.potsdam.edu/cgi-bin/man/man2html?1+git-init: Running git init in an existing repository is safe. It will not overwrite things that are already there. The primary reason for

git commit in pre-push hook

核能气质少年 提交于 2019-12-19 05:07:36
问题 I have added something like that in pre-push hook: gs0=$(git status) pip-dump gs1=$(git status) if [ "gs0" != "gs1" ] then git commit -m "pip-dump" fi (this is updating my pip requirements file) It seems that the push is not pushing the new commit, but the one which the HEAD was on at the beginning of the script. How to fix that? 回答1: You can't: the push command figures out which commits to push before invoking the hook, and pushes that if the hook exits 0. I see three options: Exit nonzero,