Skip to content

Instantly share code, notes, and snippets.

@eladg
Forked from Simbul/pre-commit
Last active August 29, 2015 14:23

Revisions

  1. eladg revised this gist Jun 14, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion pre-commit
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,7 @@
    # and make sure it is executable.
    # The name of the file *must* be "pre-commit" for Git to pick it up.

    FORBIDDEN_BRANCHES = ["staging", "production"]
    FORBIDDEN_BRANCHES = ["staging", "production", "sandbox"]

    branch = `git symbolic-ref --short HEAD`.strip

  2. eladg revised this gist Jun 14, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion pre-commit
    Original file line number Diff line number Diff line change
    @@ -8,7 +8,7 @@

    FORBIDDEN_BRANCHES = ["staging", "production"]

    branch = `git symbolic-ref --short HEAD`
    branch = `git symbolic-ref --short HEAD`.strip

    if (FORBIDDEN_BRANCHES.include?(branch))
    puts
  3. eladg revised this gist Jun 14, 2015. 1 changed file with 1 addition and 7 deletions.
    8 changes: 1 addition & 7 deletions pre-commit
    Original file line number Diff line number Diff line change
    @@ -8,13 +8,7 @@

    FORBIDDEN_BRANCHES = ["staging", "production"]

    def current_branch()
    branches = `git branch --no-color`.split(/\n/)
    current = branches.select{ |b| b =~ /\s*\*/ }.first
    current.gsub(/[\*\s]/, "")
    end

    branch = current_branch
    branch = `git symbolic-ref --short HEAD`

    if (FORBIDDEN_BRANCHES.include?(branch))
    puts
  4. @Simbul Simbul revised this gist Feb 14, 2012. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion pre-commit
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    #!/usr/bin/env ruby

    # This pre-commit hook will prevent any commit on forbidden branches
    # This pre-commit hook will prevent any commit to forbidden branches
    # (by default, "staging" and "production").
    # Put this file in your local repo, in the .git/hooks folder
    # and make sure it is executable.
  5. @Simbul Simbul revised this gist Feb 10, 2012. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions pre-commit
    Original file line number Diff line number Diff line change
    @@ -4,6 +4,7 @@
    # (by default, "staging" and "production").
    # Put this file in your local repo, in the .git/hooks folder
    # and make sure it is executable.
    # The name of the file *must* be "pre-commit" for Git to pick it up.

    FORBIDDEN_BRANCHES = ["staging", "production"]

  6. @Simbul Simbul created this gist Feb 9, 2012.
    28 changes: 28 additions & 0 deletions pre-commit
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,28 @@
    #!/usr/bin/env ruby

    # This pre-commit hook will prevent any commit on forbidden branches
    # (by default, "staging" and "production").
    # Put this file in your local repo, in the .git/hooks folder
    # and make sure it is executable.

    FORBIDDEN_BRANCHES = ["staging", "production"]

    def current_branch()
    branches = `git branch --no-color`.split(/\n/)
    current = branches.select{ |b| b =~ /\s*\*/ }.first
    current.gsub(/[\*\s]/, "")
    end

    branch = current_branch

    if (FORBIDDEN_BRANCHES.include?(branch))
    puts
    puts " STOP THE PRESS!"
    puts " You are trying to commit on the *#{branch}* branch."
    puts " Surely you don't mean that?"
    puts
    puts " If you really do, force the commit by adding --no-verify to the command."
    puts

    exit 1
    end