linux-tutorial/codes/linux/libtest/git-check.sh

28 lines
566 B
Bash
Raw Normal View History

2020-01-03 22:41:37 +08:00
#!/usr/bin/env bash
2020-02-12 22:46:17 +08:00
source ../lib/utils.sh
2020-01-03 22:41:37 +08:00
source ../lib/git.sh
##################################### MAIN #####################################
if [[ $1 ]]; then
DIR=$1
else
DIR=$(pwd)
fi
2020-02-12 22:46:17 +08:00
printInfo "Current path is: ${DIR}."
2020-01-03 22:41:37 +08:00
2020-02-12 22:46:17 +08:00
# 判断是否为 git 项目
2020-01-03 22:41:37 +08:00
checkGit ${DIR}
if [[ "${YES}" == "$?" ]]; then
2020-02-12 22:46:17 +08:00
printInfo "${DIR} is git project."
2020-01-03 22:41:37 +08:00
else
2020-02-12 22:46:17 +08:00
printError "${DIR} is not git project."
2020-01-03 22:41:37 +08:00
fi
2020-02-12 22:46:17 +08:00
# 获取 git 分支
getGitLocalBranch
printInfo "git local branch: ${GIT_LOCAL_BRANCH}"
getGitOriginBranch
printInfo "git origin branch: ${GIT_ORIGIN_BRANCH}"