mirror of
https://github.com/whyour/qinglong.git
synced 2025-05-23 14:56:07 +08:00
ql repo命令增加分支参数
This commit is contained in:
parent
3355963168
commit
049a87780e
|
@ -275,12 +275,14 @@ git_clone_scripts() {
|
||||||
## 更新脚本,$1:仓库保存路径
|
## 更新脚本,$1:仓库保存路径
|
||||||
git_pull_scripts() {
|
git_pull_scripts() {
|
||||||
local dir_current=$(pwd)
|
local dir_current=$(pwd)
|
||||||
local dir_work=$1
|
local dir_work="$1"
|
||||||
|
local branch="$2"
|
||||||
|
[[ $branch ]] && local cmd="origin/${branch}"
|
||||||
cd $dir_work
|
cd $dir_work
|
||||||
echo -e "开始更新仓库:$dir_work\n"
|
echo -e "开始更新仓库:$dir_work\n"
|
||||||
git fetch --all
|
git fetch --all
|
||||||
exit_status=$?
|
exit_status=$?
|
||||||
git reset --hard
|
git reset --hard $cmd
|
||||||
git pull
|
git pull
|
||||||
cd $dir_current
|
cd $dir_current
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,11 +14,14 @@ reset_romote_url() {
|
||||||
local dir_current=$(pwd)
|
local dir_current=$(pwd)
|
||||||
local dir_work=$1
|
local dir_work=$1
|
||||||
local url=$2
|
local url=$2
|
||||||
|
local branch="$3"
|
||||||
|
|
||||||
|
[[ $branch ]] && local cmd="origin/${branch}"
|
||||||
|
|
||||||
if [ -d "$dir_work/.git" ]; then
|
if [ -d "$dir_work/.git" ]; then
|
||||||
cd $dir_work
|
cd $dir_work
|
||||||
git remote set-url origin $url >/dev/null
|
git remote set-url origin $url >/dev/null
|
||||||
git reset --hard >/dev/null
|
git reset --hard $cmd >/dev/null
|
||||||
cd $dir_current
|
cd $dir_current
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -156,6 +159,7 @@ update_repo() {
|
||||||
local path="$2"
|
local path="$2"
|
||||||
local blackword="$3"
|
local blackword="$3"
|
||||||
local dependence="$4"
|
local dependence="$4"
|
||||||
|
local branch="$5"
|
||||||
local urlTmp="${url%*/}"
|
local urlTmp="${url%*/}"
|
||||||
local repoTmp="${urlTmp##*/}"
|
local repoTmp="${urlTmp##*/}"
|
||||||
local repo="${repoTmp%.*}"
|
local repo="${repoTmp%.*}"
|
||||||
|
@ -165,11 +169,13 @@ update_repo() {
|
||||||
local author="${authorTmp2##*.}"
|
local author="${authorTmp2##*.}"
|
||||||
|
|
||||||
local repo_path="${dir_repo}/${author}_${repo}"
|
local repo_path="${dir_repo}/${author}_${repo}"
|
||||||
|
[[ $branch ]] && repo_path="${repo_path}_${branch}"
|
||||||
|
|
||||||
if [ -d ${repo_path}/.git ]; then
|
if [ -d ${repo_path}/.git ]; then
|
||||||
reset_romote_url ${repo_path} "${github_proxy_url}${url/https:\/\/ghproxy.com\//}"
|
reset_romote_url ${repo_path} "${github_proxy_url}${url/https:\/\/ghproxy.com\//}" "${branch}"
|
||||||
git_pull_scripts ${repo_path}
|
git_pull_scripts ${repo_path} "${branch}"
|
||||||
else
|
else
|
||||||
git_clone_scripts ${url} ${repo_path}
|
git_clone_scripts ${url} ${repo_path} "${branch}"
|
||||||
fi
|
fi
|
||||||
if [[ $exit_status -eq 0 ]]; then
|
if [[ $exit_status -eq 0 ]]; then
|
||||||
echo -e "\n更新${repo_path}成功...\n"
|
echo -e "\n更新${repo_path}成功...\n"
|
||||||
|
@ -380,6 +386,7 @@ main() {
|
||||||
local p3=$3
|
local p3=$3
|
||||||
local p4=$4
|
local p4=$4
|
||||||
local p5=$5
|
local p5=$5
|
||||||
|
local p6=$6
|
||||||
log_time=$(date "+%Y-%m-%d-%H-%M-%S")
|
log_time=$(date "+%Y-%m-%d-%H-%M-%S")
|
||||||
log_path="$dir_log/update/${log_time}_$p1.log"
|
log_path="$dir_log/update/${log_time}_$p1.log"
|
||||||
case $p1 in
|
case $p1 in
|
||||||
|
@ -394,7 +401,7 @@ main() {
|
||||||
local name=$(echo "${p2##*/}" | awk -F "." '{print $1}')
|
local name=$(echo "${p2##*/}" | awk -F "." '{print $1}')
|
||||||
log_path="$dir_log/update/${log_time}_$name.log"
|
log_path="$dir_log/update/${log_time}_$name.log"
|
||||||
if [[ -n $p2 ]]; then
|
if [[ -n $p2 ]]; then
|
||||||
update_repo "$p2" "$p3" "$p4" "$p5" | tee $log_path
|
update_repo "$p2" "$p3" "$p4" "$p5" "$p6" | tee $log_path
|
||||||
else
|
else
|
||||||
echo -e "命令输入错误...\n"
|
echo -e "命令输入错误...\n"
|
||||||
usage
|
usage
|
||||||
|
|
Loading…
Reference in New Issue
Block a user