Skip to content

Instantly share code, notes, and snippets.

@yfix
Forked from GianlucaGuarini/post-merge
Created November 21, 2018 11:48
Show Gist options
  • Save yfix/53ad3445124c80758e6109cf17a0090c to your computer and use it in GitHub Desktop.
Save yfix/53ad3445124c80758e6109cf17a0090c to your computer and use it in GitHub Desktop.

Revisions

  1. @GianlucaGuarini GianlucaGuarini revised this gist Jan 15, 2015. 1 changed file with 19 additions and 3 deletions.
    22 changes: 19 additions & 3 deletions post-merge
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,7 @@
    changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)"

    check_run() {
    echo "$changed_files" | grep --quiet "$1" && eval "$2"
    echo "$changed_files" | grep -E --quiet "$1" && eval "$2"
    }

    # `npm install` and `npm prune` if the `package.json` file gets changed
    @@ -20,5 +20,21 @@ check_run bower.json "bower install && bower prune"
    # to update all the php dependencies
    check_run composer "sudo composer install"

    # `compass compile` to compil all the scss files when they get changed
    check_run .scss "compass compile"
    # for the sass files we need a bit more
    if [ -f "config.rb" ]
    then
    # `compass compile` to compile all the scss files when they get changed
    check_run ".scss|.sass" "compass compile"

    # check whether there is a gruntfile in the root of the project
    elif [[ -n $(find . -maxdepth 1 -iname "gruntfile.js" -o -iname "gruntfile.coffee") ]]
    then
    # try to compile just using grunt sass
    check_run ".scss|.sass" "grunt sass"

    # check whether there is a gulpfile in the root of the project
    elif [[ -n $(find . -maxdepth 1 -iname "gulpfile.js" -iname "gulpfile.coffee") ]]
    then
    # try to compile just using grunt sass
    check_run ".scss|.sass" "gulp sass"
    fi
  2. @GianlucaGuarini GianlucaGuarini revised this gist Feb 5, 2014. 1 changed file with 1 addition and 2 deletions.
    3 changes: 1 addition & 2 deletions post-merge
    Original file line number Diff line number Diff line change
    @@ -18,8 +18,7 @@ check_run bower.json "bower install && bower prune"

    # `composer install` if the `composer.json` file gets changed
    # to update all the php dependencies
    check_run composer.json "sudo composer install"
    check_run composer.lock "sudo composer update"
    check_run composer "sudo composer install"

    # `compass compile` to compil all the scss files when they get changed
    check_run .scss "compass compile"
  3. @GianlucaGuarini GianlucaGuarini revised this gist Feb 5, 2014. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion post-merge
    Original file line number Diff line number Diff line change
    @@ -18,7 +18,8 @@ check_run bower.json "bower install && bower prune"

    # `composer install` if the `composer.json` file gets changed
    # to update all the php dependencies
    check_run composer.json "composer install"
    check_run composer.json "sudo composer install"
    check_run composer.lock "sudo composer update"

    # `compass compile` to compil all the scss files when they get changed
    check_run .scss "compass compile"
  4. @GianlucaGuarini GianlucaGuarini revised this gist Jan 16, 2014. 1 changed file with 5 additions and 7 deletions.
    12 changes: 5 additions & 7 deletions readme.md
    Original file line number Diff line number Diff line change
    @@ -1,15 +1,14 @@
    How to create a global git commit hook by [Matt Venables](https://coderwall.com/p/jp7d5q)

    1. Enable git templates (This tells git to copy everything in ~/.git-templates to your per-project .git/ directory when you run git init):
    1 Enable git templates (This tells git to copy everything in ~/.git-templates to your per-project .git/ directory when you run git init):

    ``git config --global init.templatedir '~/.git-templates'``


    2. Create a directory to hold the global hooks:
    2 Create a directory to hold the global hooks:

    ``mkdir -p ~/.git-templates/hooks``

    3. Write your hooks in ~/.git-templates/hooks. For example, here's a post-commit hook (located in ~/.git-templates/hooks/post-commit):
    3 Write your hooks in ~/.git-templates/hooks. For example, here's a post-commit hook (located in ~/.git-templates/hooks/post-commit):

    ```
    @@ -19,16 +18,15 @@ How to create a global git commit hook by [Matt Venables](https://coderwall.com/
    git log -1 --format=format:%h | pbcopy
    # Add other post-commit hooks
    ```

    4. Make sure the hook is executable.
    4 Make sure the hook is executable.

    ``chmod a+x ~/.git-templates/hooks/post-commit``

    5. Re-initialize git in each existing repo you'd like to use this in:
    5 Re-initialize git in each existing repo you'd like to use this in:

    ``git init``

  5. @GianlucaGuarini GianlucaGuarini revised this gist Dec 17, 2013. 1 changed file with 0 additions and 22 deletions.
    22 changes: 0 additions & 22 deletions post-merge
    Original file line number Diff line number Diff line change
    @@ -2,28 +2,6 @@
    # MIT © Sindre Sorhus - sindresorhus.com
    # forked by Gianluca Guarini

    # 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/`.

    changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)"

    check_run() {
    echo "$changed_files" | grep --quiet "$1" && eval "$2"
    }

    # `npm install` and `npm prune` if the `package.json` file gets changed
    # to update all the nodejs ( grunt ) dependencies deleting the unused packages (not listed into the `package.json` file)
    check_run package.json "npm install && npm prune"
    # `bower install` and `bower prune` if the `bower.json` file gets changed
    # to install all the frontend dependencies removing the unused packages ( not listed into the `bower.json` file )
    check_run bower.json "bower install && bower prune"
    # `composer install` if the `composer.json` file gets changed
    # to update all the php dependencies
    check_run composer.json "composer install"
    #/usr/bin/env bash
    # MIT © Sindre Sorhus - sindresorhus.com
    # forked by Gianluca Guarini

    changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)"

    check_run() {
  6. @GianlucaGuarini GianlucaGuarini revised this gist Dec 17, 2013. 1 changed file with 25 additions and 1 deletion.
    26 changes: 25 additions & 1 deletion post-merge
    Original file line number Diff line number Diff line change
    @@ -19,4 +19,28 @@ check_run package.json "npm install && npm prune"
    check_run bower.json "bower install && bower prune"
    # `composer install` if the `composer.json` file gets changed
    # to update all the php dependencies
    check_run composer.json "composer install"
    check_run composer.json "composer install"
    #/usr/bin/env bash
    # MIT © Sindre Sorhus - sindresorhus.com
    # forked by Gianluca Guarini

    changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)"

    check_run() {
    echo "$changed_files" | grep --quiet "$1" && eval "$2"
    }

    # `npm install` and `npm prune` if the `package.json` file gets changed
    # to update all the nodejs ( grunt ) dependencies deleting the unused packages (not listed into the `package.json` file)
    check_run package.json "npm install && npm prune"

    # `bower install` and `bower prune` if the `bower.json` file gets changed
    # to install all the frontend dependencies removing the unused packages ( not listed into the `bower.json` file )
    check_run bower.json "bower install && bower prune"

    # `composer install` if the `composer.json` file gets changed
    # to update all the php dependencies
    check_run composer.json "composer install"

    # `compass compile` to compil all the scss files when they get changed
    check_run .scss "compass compile"
  7. @GianlucaGuarini GianlucaGuarini revised this gist Dec 17, 2013. 2 changed files with 46 additions and 5 deletions.
    16 changes: 11 additions & 5 deletions post-merge
    Original file line number Diff line number Diff line change
    @@ -1,16 +1,22 @@
    #/usr/bin/env bash
    # MIT © Sindre Sorhus - sindresorhus.com
    # forked by Gianluca Guarini

    # 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/`.

    changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)"

    check_run() {
    echo "$changed_files" | grep --quiet "$1" && eval "$2"
    echo "$changed_files" | grep --quiet "$1" && eval "$2"
    }

    # Example usage
    # In this example it's used to run `npm install` if package.json changed and `bower install` if `bower.json` changed.
    check_run package.json "npm install"
    check_run bower.json "bower install"
    # `npm install` and `npm prune` if the `package.json` file gets changed
    # to update all the nodejs ( grunt ) dependencies deleting the unused packages (not listed into the `package.json` file)
    check_run package.json "npm install && npm prune"
    # `bower install` and `bower prune` if the `bower.json` file gets changed
    # to install all the frontend dependencies removing the unused packages ( not listed into the `bower.json` file )
    check_run bower.json "bower install && bower prune"
    # `composer install` if the `composer.json` file gets changed
    # to update all the php dependencies
    check_run composer.json "composer install"
    35 changes: 35 additions & 0 deletions readme.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,35 @@
    How to create a global git commit hook by [Matt Venables](https://coderwall.com/p/jp7d5q)

    1. Enable git templates (This tells git to copy everything in ~/.git-templates to your per-project .git/ directory when you run git init):

    ``git config --global init.templatedir '~/.git-templates'``


    2. Create a directory to hold the global hooks:

    ``mkdir -p ~/.git-templates/hooks``

    3. Write your hooks in ~/.git-templates/hooks. For example, here's a post-commit hook (located in ~/.git-templates/hooks/post-commit):

    ```
    #!/bin/sh
    # Copy last commit hash to clipboard on commit
    git log -1 --format=format:%h | pbcopy
    # Add other post-commit hooks
    ```

    4. Make sure the hook is executable.

    ``chmod a+x ~/.git-templates/hooks/post-commit``

    5. Re-initialize git in each existing repo you'd like to use this in:

    ``git init``

    NOTE if you already have a hook defined in your local git repo, this will not overwrite it.
  8. @sindresorhus sindresorhus created this gist Dec 16, 2013.
    16 changes: 16 additions & 0 deletions post-merge
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    #/usr/bin/env bash
    # MIT © Sindre Sorhus - sindresorhus.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/`.

    changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)"

    check_run() {
    echo "$changed_files" | grep --quiet "$1" && eval "$2"
    }

    # Example usage
    # In this example it's used to run `npm install` if package.json changed and `bower install` if `bower.json` changed.
    check_run package.json "npm install"
    check_run bower.json "bower install"