Skip to content

Instantly share code, notes, and snippets.

@vadakattu
vadakattu / post-merge
Last active May 14, 2018 13:56 — forked from sindresorhus/post-merge
git hook to run a command after `git pull` if a specified file was changed. In this example it's used to update your python virtual environment if the requirements file has changed. Run `chmod +x post-merge` to make it executable then put it into git hooks folder (`.git/hooks/` by default)
#!/usr/bin/env bash
# MIT © Sindre Sorhus - sindresorhus.com
# Krishna Vadakattu - vadakattu.com
# git hook to run a command after `git pull` if a specified file was changed.
# Run `chmod +x post-merge` to make it executable then put it into git hooks folder (`.git/hooks/` by default)
changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)"
check_run() {
@vadakattu
vadakattu / pre-commit.sh
Last active September 18, 2018 15:54 — forked from milancermak/pre-commit.sh
Python pre-commit hook feature to check if python package requirements have changed. Useful for maintaining consistency across virtualenvs. Can be skipped using git commit --no-verify
#!/bin/sh
# To version control your hook, save this script inside your repository e.g. .githooks/
# Then run 'git config core.hooksPath .githooks' to point your local repository to it
# Check if the python package requirements match the existing requirements
pip freeze | diff requirements.txt -
if [ $? -ne 0 ]
then
echo "The requirements have changed!"