diff options
| -rwxr-xr-x | scripts/gist | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/scripts/gist b/scripts/gist index 2c47870..69c4b99 100755 --- a/scripts/gist +++ b/scripts/gist | |||
| @@ -29,7 +29,7 @@ | |||
| 29 | # gist update (update the list of gists from github.com) | 29 | # gist update (update the list of gists from github.com) |
| 30 | # gist 3 (show the repo path of your 3rd gist, and do custom actions) | 30 | # gist 3 (show the repo path of your 3rd gist, and do custom actions) |
| 31 | # gist 3 --no-action (show the repo path of your 3rd gist, and do not perform actions) | 31 | # gist 3 --no-action (show the repo path of your 3rd gist, and do not perform actions) |
| 32 | # gist new foo --desc bar (create a new gist with description) | 32 | # gist new foo --desc bar (create a new gist with file and description) |
| 33 | # | 33 | # |
| 34 | # Since now a gist is a local cloned repo | 34 | # Since now a gist is a local cloned repo |
| 35 | # It is your business to do git commit and git push | 35 | # It is your business to do git commit and git push |
| @@ -179,6 +179,8 @@ _show_list() { | |||
| 179 | [[ ! -d $repo ]] && extra="\e[32m[Not cloned yet]\e[0m" && occupy=16 | 179 | [[ ! -d $repo ]] && extra="\e[32m[Not cloned yet]\e[0m" && occupy=16 |
| 180 | # if there are some changes in git index or working directory, show blue message "working" | 180 | # if there are some changes in git index or working directory, show blue message "working" |
| 181 | [[ -n $(cd $repo && git status --short) ]] 2>/dev/null && extra="\e[36m[working]\e[0m" && occupy=9 | 181 | [[ -n $(cd $repo && git status --short) ]] 2>/dev/null && extra="\e[36m[working]\e[0m" && occupy=9 |
| 182 | # if there files are different, show red message "outdated" | ||
| 183 | [[ $(_blob_code $repo) != $blob_code ]] 2>/dev/null && extra="\e[31m[outdated]\e[0m" && occupy=10 | ||
| 182 | # if there is a commit not yet push, show red message "ahead" | 184 | # if there is a commit not yet push, show red message "ahead" |
| 183 | [[ -n $(cd $repo && git cherry) ]] 2>/dev/null && extra="\e[31m[ahead]\e[0m" && occupy=7 | 185 | [[ -n $(cd $repo && git cherry) ]] 2>/dev/null && extra="\e[31m[ahead]\e[0m" && occupy=7 |
| 184 | 186 | ||
| @@ -267,6 +269,11 @@ _query_user() { | |||
| 267 | done | 269 | done |
| 268 | } | 270 | } |
| 269 | 271 | ||
| 272 | _blob_code() { | ||
| 273 | cd $1 \ | ||
| 274 | && git ls-tree master | cut -d' ' -f3 | cut -c-7 | sort | paste -sd '-' | ||
| 275 | } | ||
| 276 | |||
| 270 | # update local git repos | 277 | # update local git repos |
| 271 | _sync_repos() { | 278 | _sync_repos() { |
| 272 | # clone repos which are not in the local | 279 | # clone repos which are not in the local |
| @@ -278,7 +285,7 @@ _sync_repos() { | |||
| 278 | cat $INDEX | cut -d' ' -f2,3 \ | 285 | cat $INDEX | cut -d' ' -f2,3 \ |
| 279 | | while read url blob_code_remote; do | 286 | | while read url blob_code_remote; do |
| 280 | local repo=$folder/$(echo $url | sed 's#.*/##') | 287 | local repo=$folder/$(echo $url | sed 's#.*/##') |
| 281 | local blob_code_local=$(cd $repo && git ls-tree master | cut -d' ' -f3 | cut -c-7 | sort | paste -sd '-') | 288 | local blob_code_local=$(_blob_code $repo) |
| 282 | cd $repo \ | 289 | cd $repo \ |
| 283 | && [[ $blob_code_local != $blob_code_remote ]] \ | 290 | && [[ $blob_code_local != $blob_code_remote ]] \ |
| 284 | && [[ $(git rev-parse origin/master) == $(git rev-parse master) ]] \ | 291 | && [[ $(git rev-parse origin/master) == $(git rev-parse master) ]] \ |