githooks

Difference between -C and --git-dir when manipulating repo in git hook

瘦欲@ 提交于 2021-02-18 22:11:49
问题 I am writing a git post-receive hook that will clone a separate repo as part of a deployment. It clones the repo to a certain folder and uses the -C option in subsequent git commands to set the directory to that of the checked out repo (as documented in the man page). The hook works as expected when run manually from the command line, however when the hook is run by git (ie when a push is received) the command fails with fatal: Not a git repository: '.' . When I swap out the -C for a --git

Difference between -C and --git-dir when manipulating repo in git hook

随声附和 提交于 2021-02-18 22:11:06
问题 I am writing a git post-receive hook that will clone a separate repo as part of a deployment. It clones the repo to a certain folder and uses the -C option in subsequent git commands to set the directory to that of the checked out repo (as documented in the man page). The hook works as expected when run manually from the command line, however when the hook is run by git (ie when a push is received) the command fails with fatal: Not a git repository: '.' . When I swap out the -C for a --git

git pre-push hook: run test on each new commit

心不动则不痛 提交于 2021-02-10 20:20:26
问题 Context I want to ensure that each commit I push pass tests. I want to check this on my (client) side, i.e. before commits are even pushed (so I don't want to rely on CI tools). Problem Currently, I have implemented a pre-commit hook that run my tests, so that I cannot even commit a broken state. However, my test suite takes more than a few seconds to run. It is that much time I need to wait prior to writing my commit message. This makes it impractical to use on a daily basis; both because I

Triggering post-checkout hook after “git checkout -b” command

我的未来我决定 提交于 2021-02-08 10:28:32
问题 Same question was asked here before however both answers didn't help me much. I couldn't get my post-checkout hook to differ git checkout from git checkout -b command as $1 (sha1 of previous HEAD) and $2 (sha1 of new HEAD) are same for both calls. Here is my post-checkout script: #!/bin/bash echo "old HEAD: $1" echo "new HEAD: $2" echo "checkout type: $3" I executed following commands: > ozgur@ozgurv:~/project (master)$ git checkout -b new_branch old HEAD:

git server side hook - only specific branches will be pushed

给你一囗甜甜゛ 提交于 2021-01-28 10:12:30
问题 i' m very newbie to git hooks. I' d like to make sure that to the repository only branches will be pushed / updated which starts with BT. So no update is possible to master / current branch. How can i achieve that? I guess it should be part of the update script, right? 回答1: It could be a pre-receive hook. #!/bin/bash #sample z40=0000000000000000000000000000000000000000 while read old new ref;do #fail if it's not a branch or the name of the branch does not start with BT if [ "${ref:0:13}" !=

tracking version numbers of subfolders in git

有些话、适合烂在心里 提交于 2021-01-28 02:57:34
问题 My team is using github to manage a private repo full of cms themes. We have them all within the same repo and keep track of them with subfolders, labels and keeping our branchs and commits prefixed with the theme name IE Commit message: "[Super Theme] upgraded Navigation to include hover effect" Branch super_theme-upgrade-navigation-hover Now we want to introduce semantic versioning into the theme's settings page so if you click about, you get the version number, but I'm not sure the best

Enforce git branch policies

删除回忆录丶 提交于 2021-01-28 01:42:10
问题 I'm trying to enforce a company policy, taking these assumptions: There are only 3 available upstream branches: master, version/* and hotfix/*. Master branch accepts only non-forwarded merge commits. Version and Hotfix branches accept only fast-forward/rebased commits. Master branch must only be merged into from Version or Hotfix branches. Version and Hotfix branches must diverge from Master branch directly. So far this is what I come up with: #!/usr/bin/env ruby # Encoding: utf-8 $oldrev,

Fixing mac/windows new lines with git pre-commit hook?

流过昼夜 提交于 2021-01-24 07:12:19
问题 In our office we working in a team of about 10 developers. Most of them have a Mac machines. Recently I've realise when I'm checking differences of my work (after changing only one line of code) almost each line is changed, but git diff shows you change is exactly same as original. After some research it's turned out to be a different new line. Before I do anything it's '\r\n' (CR+LF, 0x0D0A) and after my change all non Unix new lines (\r\n) are change to Unix one (\n). I realize I could ask

How to run husky pre-commit in child directory only

余生颓废 提交于 2021-01-22 06:37:08
问题 We have an enterprise application with a folder structure like the following: /project .git /sub1 ...Java project /sub2 package.json ...Javascript Backbone project /sub3 ...Java project /sub4 ...Java project /sub5 package.json ...Javascript React project I currently have Husky set up both in sub2 and sub5 projects, which causes conflicts (requires an npm install whenever I switch projects). Also, the Java developers are reporting that when they commit code in projects sub1, sub3 and sub4, the

How to run husky pre-commit in child directory only

南楼画角 提交于 2021-01-22 06:35:37
问题 We have an enterprise application with a folder structure like the following: /project .git /sub1 ...Java project /sub2 package.json ...Javascript Backbone project /sub3 ...Java project /sub4 ...Java project /sub5 package.json ...Javascript React project I currently have Husky set up both in sub2 and sub5 projects, which causes conflicts (requires an npm install whenever I switch projects). Also, the Java developers are reporting that when they commit code in projects sub1, sub3 and sub4, the