sh 利用coding.net批量更新本地所有仓库

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh 利用coding.net批量更新本地所有仓库相关的知识,希望对你有一定的参考价值。

source_code_dir="/Users/username/sourcecode/dev.tencent.com/"
token="your_coding_net_token"
current_dir=$(pwd)
response=$(curl -X GET "https://coding.net/api/user/projects?type=all&sort=&page=1&pageSize=100" -H "Authorization: token ${token}")
project_count=$(echo $response | jq '.data.list | length')
echo $project_count
for(( i = 0; i < $project_count; i = i + 1 ))
do
  operation="clone"
  item=$(echo $response | jq -r ".data.list[$i]")
  name=$(echo $item | jq -r ".name")
  owner_user_name=$(echo $item | jq -r ".owner_user_name")
  ssh_url=$(echo $item | jq -r ".ssh_url")
  if [ -d "$source_code_dir$owner_user_name/$name/.git" ]; then
    echo "$source_code_dir$owner_user_name/$name/.git 存在"
    operation="pull"
  else 
    echo "$source_code_dir$owner_user_name/$name/.git 不存在"
  fi
  echo "正在 $operation 项目:$ssh_url"
  if [ $operation = "clone" ]; then
    git clone $ssh_url "$source_code_dir$owner_user_name/$name"
  else
    cd "$source_code_dir$owner_user_name/$name"
    git pull
    cd $current_dir
  fi
  echo -e "完成 $operation 项目:$ssh_url\n"
done 

以上是关于sh 利用coding.net批量更新本地所有仓库的主要内容,如果未能解决你的问题,请参考以下文章

如何批量更新本地仓库中的jar包

CODING 更新日志:Coding.net 现已支持 SVN

Linux之shell脚本实战批量上传docker镜像到华为云容器镜像仓库

Linux利用xargs批量查看所有文件的第一行内容 + 批量清空所有文件的内容

使用idea上传项目初始化版本到coding

批量删除本地仓库未下载完成的jar文件