githooks

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

早过忘川 提交于 2019-12-02 22:53:44
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? mvp It depends on what option you use when pulling: No option : git fetch and git merge are run You can write your own post-merge git hook : This hook is invoked by git merge, which happens when a git pull is done on a local

Create a BitBucket git commit hook?

让人想犯罪 __ 提交于 2019-12-02 22:06:16
I just ported over a repo from GitHub to BitBucket. Although it does many of necessities, I'm finding it surprisingly difficult to find documentation for creating a git commit hook. Originally I had a ruby app on a CentOS server that was triggered by a GitHub hook. Does anyone know how to achieve the same in the BitBucket environment? Thanks! Edit: here's what the ruby app simply looks like if it helps: post '/' do `rm -rf repofolder` `git clone https://user@bitbucket.org/user/repo.git` `sh fast_deploy.sh` end I was able to find a solution. Although John Percival's answer is right, no current

Prevent pushes to git containing tabs in certain files (e.g. *.cpp, *.h, CMakeLists.txt)

二次信任 提交于 2019-12-02 20:39:10
I'd like my remote repository to refuse any pushes that contains a file that contains a tab, but only if the file belongs in a certain class (based on the filename). Is that possible? I have looked a bit at the update hook in githooks, and I think that is the correct one. So in short, a push should be rejected if: there is a file of the listed types ( *.cpp , *.h , CMakeLists.txt ) that contains one or more tab characters. Cascabel Uh oh, this question seems to have slipped through the cracks. Hope you're still out there, Esben! You're looking for an update hook , which is run once for each

How can I automate Pivotal Tracker & Github Integration?

我与影子孤独终老i 提交于 2019-12-02 19:13:48
Pivotal Tracker and Github have great integration: Once it's set up, each commit which is prefixed by the Pivotal Tracker ID will appear under the corresponding Pivotal Ticket automatically, for an example: git commit -am '[#1234567] my new changes' git push origin will add the comment 'my new changes' automatically to the 1234567 Pivotal Ticket among with the github commit link. However, it's easy to forget to add the ticket ID each time. How could it be simplified / automated? The solution is to use Git-Hooks and feature branches. (The Github-flow is recommended). You have to install this

Writing Git hooks in python/bash scripts [closed]

杀马特。学长 韩版系。学妹 提交于 2019-12-02 18:59:41
I have recently needed to write git hooks, for all commits to reference a particular ticket. I was hoping for a place to start learning. All the stuff in the pro git book is written in Ruby. Since Ruby is not my strong suit, can anybody share tutorials about git hooks written in other languages? (I'd particularly prefer Python or Bash scripts.) Here is an example of using Python for a hook. In general the hooks are language agnostic. You use the script to do some work or to exit with a 0/other return code to alter the flow of a git process. The examples that come with git are written in shell

Automatically synchronizing a Subversion repository and a Git repository

痴心易碎 提交于 2019-12-02 18:37:56
My project has a Subversion repository on a network file system, and a new team would like to access it using Git, and be able to commit to it and get updates from it. What I have in mind is to create a new bare git-svn clone of the Subversion repository on the same network file system, and make sure the two repositories are always up to date with respect to each other. The way to do this is probably to add a post-commit hook for both Subversion and the new Git repository, that will each update the other's repository. The Subversion post-commit hook will include git svn rebase , and the Git

block push of trivial merge to git server

佐手、 提交于 2019-12-02 17:09:56
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 UTC 2010 : great comments, all! Thank you. Consider the following: all I'm really asking folks to do

Pre-commit hook file staging for commit

浪子不回头ぞ 提交于 2019-12-02 08:52:55
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? 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 made by your hook (or anything external). That being said, I cannot recommend this kind of practice. Even if

How can I init/update git submodules in a remote?

风流意气都作罢 提交于 2019-12-02 06:32:08
I often use this pattern for easy deployment of websites: I have a bare repo, which I push/pull to from my computer and this bare repo has a post-update hook that automatically does a pull in another repo (the live version). However, if I add a submodule on my computer and push it, I have to manually connect to the remote and do the init/update. Is there a way around it ? Do you have the ability to do more than a pull on the live server? You can do all of that in one (well, technically two) command: git pull && git submodule update --init --recursive This will recursively initialise and pull

Writing a pre-push hook in Git to grep all files for regex want to reject push if regex not found

删除回忆录丶 提交于 2019-12-02 01:43:37
I have the following pre-push hook. Ideally I would like it to go through all files that are being pushed to my repository and reject the push if the content of any of the files doesn't match the regular expression defined at the top. I'm getting the following error when attempting to loop through the files: "undefined method `each' for "":String (NoMethodError)". '.each' doesn't work as the git command is returning a string containing the changed files. #!/usr/bin/env ruby regex = "\\s*GO\\s*$" localRef, remoteRef = ARGV #puts localRef #puts remoteRef input = $stdin.readlines[0] localSha =