aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authortypebrook <typebrook@gmail.com>2020-04-11 10:16:55 +0800
committertypebrook <typebrook@gmail.com>2020-04-11 12:04:20 +0800
commit6acdd86d1fede147dd93fff2f9ad86a5f2f2337c (patch)
treefc0bf2d1e6de7840cb86353518917b0b93244b5a
parent0ce82ec3ec16481d5b58a41f5349d1e29d0145fb (diff)
Refactor the way of checking repo status
-rwxr-xr-xgist5
1 files changed, 4 insertions, 1 deletions
diff --git a/gist b/gist
index 455d4fa..9c6bdc6 100755
--- a/gist
+++ b/gist
@@ -267,10 +267,13 @@ _check_repo_status() {
267 fi 267 fi
268 else 268 else
269 cd "$1" || exit 1 269 cd "$1" || exit 1
270 if [[ -n $(git status --short) || $(git branch | sed -n '/\* / s///p') != 'master' ]] &>/dev/null; then 270 # git status is not clean or working on non-master branch
271 if [[ -n $(git status --short) || $(cat .git/HEAD) != 'ref: refs/heads/master' ]] &>/dev/null; then
271 echo "\e[36m[working]\e[0m" 272 echo "\e[36m[working]\e[0m"
272 else 273 else
274 # files contents are not the same with the last time called GIST API, so warn user to call 'gist fetch'
273 [[ $(_blob_code "$1") != "$2" ]] 2>/dev/null && local status="\e[31m[outdated]\e[0m" 275 [[ $(_blob_code "$1") != "$2" ]] 2>/dev/null && local status="\e[31m[outdated]\e[0m"
276 # current HEAD is newer than remote, warn user to call 'git push'
274 [[ -n $(git cherry) ]] 2>/dev/null && local status="\e[31m[ahead]\e[0m" 277 [[ -n $(git cherry) ]] 2>/dev/null && local status="\e[31m[ahead]\e[0m"
275 echo "$status" 278 echo "$status"
276 fi 279 fi