Last active
October 21, 2015 15:59
-
-
Save jwliechty/68b7b0efa01a184ac73b to your computer and use it in GitHub Desktop.
Revisions
-
jwliechty renamed this gist
Oct 21, 2015 . 1 changed file with 15 additions and 16 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,39 +1,38 @@ # Library methods for git operations # See http://stackoverflow.com/questions/2657935/checking-for-a-dirty-index-or-untracked-files-with-git git::run_test(){ if git::has_staged_changes; then echo "There are staged changes" fi if git::has_working_changes; then echo "There are working changes" fi if git::has_untracked_changes; then echo "There are untracked changes" fi if git::has_any_changes; then echo 'Repo is dirty!' fi } git::has_any_changes(){ git::has_staged_changes \ || git::has_working_changes \ || git::has_untracked_changes } git::has_staged_changes(){ ! git diff-index --quiet --cached HEAD } git::has_working_changes(){ # fixes modified but unchanged files from reporting being changed git status > /dev/null ! git diff-files --quiet } git::has_untracked_changes(){ local u= ! ( u="$( git ls-files --exclude-standard --others )" && [ -z "${u}" ] ) } -
jwliechty revised this gist
Oct 6, 2015 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -25,7 +25,9 @@ hasStagedChanges(){ ! git diff-index --quiet --cached HEAD } hasWorkingChanges(){ # fixes modified but unchanged files from reporting being changed git status > /dev/null ! git diff-files --quiet } -
jwliechty revised this gist
Oct 5, 2015 . 1 changed file with 7 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -12,6 +12,13 @@ runTest(){ if hasUntrackedChanges; then echo "There are untracked changes" fi if hasAnyChanges; then echo 'Repo is dirty!' fi } hasAnyChanges(){ hasStagedChanges || hasWorkingChanges || hasUntrackedChanges } hasStagedChanges(){ -
jwliechty revised this gist
Oct 5, 2015 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,7 @@ #!/bin/bash -e # See http://stackoverflow.com/questions/2657935/checking-for-a-dirty-index-or-untracked-files-with-git runTest(){ if hasStagedChanges; then echo "There are staged changes" -
jwliechty created this gist
Oct 5, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,28 @@ #!/bin/bash -e runTest(){ if hasStagedChanges; then echo "There are staged changes" fi if hasWorkingChanges; then echo "There are working changes" fi if hasUntrackedChanges; then echo "There are untracked changes" fi } hasStagedChanges(){ ! git diff-index --quiet --cached HEAD } hasWorkingChanges(){ ! git diff-files --quiet } hasUntrackedChanges(){ local u= ! ( u="$( git ls-files --exclude-standard --others )" && [ -z "${u}" ] ) } runTest