githooks

Adding git hooks to google cloud repo

你离开我真会死。 提交于 2020-08-22 17:01:47
问题 One of the things that comes with google cloud are git repos. Is it possible to add hooks to this repo? I'd like to incoming pushes, but I don't know how to get access to .git/hooks . 回答1: You can do it if you host your code on git-hub/bitbucket. Then you will be able to use the git hooks. Google source has this feature (Object Change Notification) instead of hooks: https://cloud.google.com/storage/docs/object-change-notification 回答2: Check your server settings, if you use VM not cloud repo

Trigger something in post-receive only when new tag is added

本秂侑毒 提交于 2020-08-11 01:11:07
问题 I want to do some action in GIT's post-receive hook when only new tag is pushed to the repository. How to accomplish this? Thanks SOLUTION (answer by Jan Krüger) New tag has $oldrev equalled zeroes. Removed tag has $newrev equalled zeroes. For both $ref value starts with refs/tags/ . #!/bin/sh # read oldrev newrev ref if [[ "0000000000000000000000000000000000000000" == $oldrev ]] && [[ $ref == refs\/tags\/* ]]; then echo "New tag added" fi 回答1: The post-receive hook receives information on

Can pre-receive hook edit commits?

落花浮王杯 提交于 2020-08-06 03:36:10
问题 I'm building a pre-receive hook to check the name and email address of the author. I'm able to easily check if the name/email address of the commit using, while read oldsha newsha refname; do authorEmail=$(git log -1 --pretty=format:%ae $newsha) if [[ $(grep -w $authorEmail ~/.ssh/authorized_keys | wc -w) -gt 1 ]]; then echo "Author Email: $authorEmail" exit 0 else echo "Unauthorized Email" exit 1 fi done But instead of simply rejecting it, I want to replace the email with the right one. I

GIT hook -> Python -> Bash: How to read user input?

心不动则不痛 提交于 2020-07-22 04:41:25
问题 I'm doing a GIT hook in Python 3.5. The python script calls a Bash script that that reads input from the user using read command. The bash script by itself works, also when calling directly the python script, but when GIT runs the hook written in Python, it doesn't work as expected because no user input is requested from the user. Bash script: #!/usr/bin/env bash echo -n "Question? [Y/n]: " read REPLY GIT Hook (Python script): #!/usr/bin/env python3 from subprocess import Popen, PIPE proc =

Git pre-commit hook not running on windows

旧街凉风 提交于 2020-06-24 03:24:09
问题 I'm just starting to look into Git hooks, but I can't seem to get them to run. I set up a local repository, so there is now a '.git' directory in my project folder. I have added a '.cmd' file into the C:/path/to/my/project/.git/hooks directory named 'pre-commit.cmd'. Here is the contents of this file: echo "HOOK RUNNING" echo. 2>C:/path/to/my/project/.git/hooks/EmptyFile.txt This should echo the text "HOOK RUNNING" and create an empty text file in that directory. However, if I commit changes

Git pre-commit hook not running on windows

非 Y 不嫁゛ 提交于 2020-06-24 03:24:09
问题 I'm just starting to look into Git hooks, but I can't seem to get them to run. I set up a local repository, so there is now a '.git' directory in my project folder. I have added a '.cmd' file into the C:/path/to/my/project/.git/hooks directory named 'pre-commit.cmd'. Here is the contents of this file: echo "HOOK RUNNING" echo. 2>C:/path/to/my/project/.git/hooks/EmptyFile.txt This should echo the text "HOOK RUNNING" and create an empty text file in that directory. However, if I commit changes

Git: is there a way to auto push a subtree?

北慕城南 提交于 2020-06-14 07:37:06
问题 I have a big private repository which is maintained on a local network. I'd like to automatically push a subtree of that repository outside of that network. I need it to be simple: *Task* someone pushes to local remote repository --> a subtree is automatically pushed to some other repository I am not sure if this could be achieved with a server side hook because AFAIK there is no such thing as pushing subtrees from bare remotes. I came up with two ideas: I could clone the remote on the server

How to authenticate user via git pre-receive hook

与世无争的帅哥 提交于 2020-06-13 00:21:07
问题 I am looking to write a pre-receive githook in Python. It is my understanding that no arguments are passed into pre-receive scripts but rather each reference is passed in using standard input on separate lines. I have been able to read the reference changes via: !/usr/bin/env python import sys import fileinput for line in fileinput.input(): print "pre-receive: Trying to push ref: %s" % line However, for this hook, I am mainly concerned with making sure that the user pushing code has the

Bash confirmation won't wait for user input

筅森魡賤 提交于 2020-06-12 08:02:46
问题 I am trying to implement confirmation prompt with a bash script but for some reason, prompt won't wait for user input. I've tried many examples but no luck so far. I am on MacOS if it makes any difference. Just a few examples I tried (All copy+paste from other answers in SO): #!/bin/bash read -p "Are you sure? " -n 1 -r echo # (optional) move to a new line if [[ $REPLY =~ ^[Yy]$ ]] then # do dangerous stuff fi #!/bin/bash read -p "Continue (y/n)?" CONT if [ "$CONT" = "y" ]; then echo "yaaa";

How to prevent a specific branch from being merged in git?

▼魔方 西西 提交于 2020-05-29 02:37:18
问题 We have a master branch where the released production code lives, a dev branch where the code for the test server lives, and various feature branches (branched from master ) as each developer sees fit. Over the course of time the dev branch has diverged somewhat from master . In addition, there are some incorrect merges there that mess up parts of the code. Several times already we have tried to reset (force-push) dev to be the same as master . To start over with a clean slate, so to say.