githooks

VSCode: trigger organizeImports when git staging

*爱你&永不变心* 提交于 2020-02-02 02:15:12
问题 I like the automated organize feature in VSCode, but having it doing it on every save has given me some trouble. ... "editor.codeActionsOnSave": { "source.organizeImports": true }, ... Is it possible to set up some git hooks that organize the imports (either via vscode or some other script/lib) when I stage them? Issues If I hit save too early (do it to kick off prettier all the time) before I have used the imported methods - then it removes it and I have to write the import again. If I break

Git: How to re-stage the staged files in a pre-commit hook

蓝咒 提交于 2020-01-22 13:56:26
问题 I'm writting a git pre-commit hook. The script could reformat some code, so it could modify the staged files. How can I re-stage all files that are already staged ? 回答1: Without the pre-commit hook context, you can get a list of the staged files with the following command: git diff --name-only --cached So if you want to re-index the staged files, you can use: git diff --name-only --cached | xargs -l git add In the pre-commit hook context, you should follow the advices of David Winterbottom

Git hook for updating Git submodule on branch change

故事扮演 提交于 2020-01-20 08:29:06
问题 I'm working with some old code that makes use of Git submodules. The code has several divergent branches which are actively being used, and each of these branches depends on unfortunately a different revision of the relevant submodules; this has made development extremely complicated. One of the problems I face is that, when I switch between branches from e.g. master to newfeature-foo using git checkout newfeature-foo , the state of the submodules remains at that of master , which often

git server side hooks

自古美人都是妖i 提交于 2020-01-17 00:59:29
问题 I am running into a problem when running the follow python script on the server looking for commit information for the push making sure it follows a particular syntax, I am unable to get input from the user which is why the username and password are hard coded. I am now also unable to get the list of commit message that occurred before this particular push. #!/usr/bin/python import SOAPpy import getpass import datetime import sys import re import logging import os def login(x,y): try: auth =

How do I setup a git hook to pull from Github?

空扰寡人 提交于 2020-01-13 06:42:13
问题 I develop on my Mac and push it to Github. I login to my server by SSH and I git pull the changes to the server. I want the changes to automatically be pulled to the server when I push them to Github so I a file .git/hooks/post-update with this info #!/bin/sh echo echo "**** Pulling changes into Live [Hub's post-update hook]" echo cd /mydirector/html || exit unset GIT_DIR git pull exec git-update-server-info What else should I do to get it working? Thanks in advance for your answer. It will

How can I automatically be warned if a specific file changes?

只愿长相守 提交于 2020-01-12 01:31:33
问题 I have a php project, and when I pull from another repository and the composer.lock file gets changed, I'm supposed to run composer.phar install --dev . How can git automatically warn me / ask me if I want to run this command? I suppose some sort of hook would do the trick, but how can I get information regarding only what has changed before and after the pull in it? 回答1: It depends on what option you use when pulling: No option : git fetch and git merge are run You can write your own post

How can I automatically be warned if a specific file changes?

痞子三分冷 提交于 2020-01-12 01:31:32
问题 I have a php project, and when I pull from another repository and the composer.lock file gets changed, I'm supposed to run composer.phar install --dev . How can git automatically warn me / ask me if I want to run this command? I suppose some sort of hook would do the trick, but how can I get information regarding only what has changed before and after the pull in it? 回答1: It depends on what option you use when pulling: No option : git fetch and git merge are run You can write your own post

How can I automatically be warned if a specific file changes?

淺唱寂寞╮ 提交于 2020-01-12 01:31:12
问题 I have a php project, and when I pull from another repository and the composer.lock file gets changed, I'm supposed to run composer.phar install --dev . How can git automatically warn me / ask me if I want to run this command? I suppose some sort of hook would do the trick, but how can I get information regarding only what has changed before and after the pull in it? 回答1: It depends on what option you use when pulling: No option : git fetch and git merge are run You can write your own post

How can I prevent a file (.json) to be commited with a git hook?

痞子三分冷 提交于 2020-01-11 14:21:14
问题 How can I prevent a file (.json) to be commited with a git hook ? I have a .json which is on the server yet. So I can not use an gitignore. But now I do not want to allow anyone to change this file (commit it) because it would break something. I want to use a local hook. How can I even get the special file in the commit ? Could you please give me an instruction how to achieve this ? Thank your for your help. 回答1: A pre-commit sample: #!/bin/bash ipath="foo/bar.json" git diff --cached --name

Egit hooks do not get triggered

吃可爱长大的小学妹 提交于 2020-01-09 03:49:06
问题 I have a git repo with a pre-commit hook that intentionally fails 100% of the time. cat .git/hooks/pre-commit > exit 1 If I try to commit through the command line, it fails as expected. However, if I commit from egit, the hook is ignored and the changes get committed. Does egit/jgit not recognize hooks yet? Is there a workaround for this? Thanks in advance! 回答1: (Original answer: June 2011) MatrixFrog correctly points out to the bug 299315, which mentions those hooks aren't supported yet. You