Skip to content

Instantly share code, notes, and snippets.

@guilherme
Last active October 10, 2024 18:27
Show Gist options
  • Select an option

  • Save guilherme/9604324 to your computer and use it in GitHub Desktop.

Select an option

Save guilherme/9604324 to your computer and use it in GitHub Desktop.

Revisions

  1. guilherme revised this gist Nov 5, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -9,7 +9,7 @@ consoleregexp='console.log'
    if test $(git diff --cached | grep $consoleregexp | wc -l) != 0
    then
    exec git diff --cached | grep -ne $consoleregexp
    read -p "There are some ocurrences of console.log at your modification. Are you sure want to continue? (y/n)" yn
    read -p "There are some occurrences of console.log at your modification. Are you sure want to continue? (y/n)" yn
    echo $yn | grep ^[Yy]$
    if [ $? -eq 0 ]
    then
  2. guilherme revised this gist Mar 17, 2014. 1 changed file with 3 additions and 2 deletions.
    5 changes: 3 additions & 2 deletions gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -4,10 +4,11 @@ exec 1>&2
    # enable user input
    exec < /dev/tty

    consoleregexp='console.log'
    # CHECK
    if test $(git diff --cached | grep console | wc -l) != 0
    if test $(git diff --cached | grep $consoleregexp | wc -l) != 0
    then
    exec git diff --cached | grep -ne console
    exec git diff --cached | grep -ne $consoleregexp
    read -p "There are some ocurrences of console.log at your modification. Are you sure want to continue? (y/n)" yn
    echo $yn | grep ^[Yy]$
    if [ $? -eq 0 ]
  3. guilherme created this gist Mar 17, 2014.
    19 changes: 19 additions & 0 deletions gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    #!/bin/sh
    # Redirect output to stderr.
    exec 1>&2
    # enable user input
    exec < /dev/tty

    # CHECK
    if test $(git diff --cached | grep console | wc -l) != 0
    then
    exec git diff --cached | grep -ne console
    read -p "There are some ocurrences of console.log at your modification. Are you sure want to continue? (y/n)" yn
    echo $yn | grep ^[Yy]$
    if [ $? -eq 0 ]
    then
    exit 0; #THE USER WANTS TO CONTINUE
    else
    exit 1; # THE USER DONT WANT TO CONTINUE SO ROLLBACK
    fi
    fi