1 Star 0 Fork 2

PersonalSummary/gitlab_sync

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
update_code.sh 1.29 KB
一键复制 编辑 原始数据 按行查看 历史
wenfei6316 提交于 2023-09-29 08:33 . update update_code.sh
#!/bin/bash
# this file is used for update code
# $1 is project_name
# $2 is project_path
# $3 is branch
# $4 is gitlab_url
# $5 is pid_flag, confirm whether project is current create
set -e
project_name=$1
code_path=$2
branch=$3
gitlab_url=$4
pid_flag=$5
remote_name="update_code_branch"
echo "project is ${project_name}"
echo "branch is ${branch}"
echo "gitlab_url is ${gitlab_url}"
echo "pid_flag is ${pid_flag}"
if [ -d ${code_path:?} ]; then
echo "code path is ${code_path}"
fi
pushd ${code_path}
branch_check=$(git status | grep ${branch} | wc -l)
if [[ ${branch_check} -eq 0 ]]; then
echo "please set code to branch ${branch}!!!"
exit 1
fi
origin_check=$(git remote show | grep ${remote_name} | wc -l)
if [[ ${origin_check} -gt 0 ]]; then
git remote remove ${remote_name}
fi
git remote add ${remote_name} ${gitlab_url}
shallow_check=$(find ./.git -name "shallow" | wc -l)
if [[ ${shallow_check} -gt 0 ]]; then
set +e
git fetch --unshallow
set -e
fi
git fetch ${remote_name}
git lfs fetch --all
if [[ ${pid_flag} -eq 0 ]]; then
git checkout -b ${remote_name} ${remote_name}/${branch}
git merge ${branch}
git push -u ${remote_name} ${remote_name}:${branch}
else
set +e
git tag -d ${branch}
set -e
git lfs push ${remote_name} ${branch}
git push -u ${remote_name} ${branch}
fi
popd
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/personal-summary/gitlab_sync.git
[email protected]:personal-summary/gitlab_sync.git
personal-summary
gitlab_sync
gitlab_sync
master

搜索帮助