1.指定项目代码库中迭代列出全部ProductList(.git)到pro.log文件中
repo forall -c ‘echo $REPO_PROJECT‘ | tee pro.log
pro.log文件内容如下:(这里以高通源码部分project为例)
platform/abi/cpp
platform/art
platform/bionic
kernel/lk
platform/bootable/recovery
platform/build
platform/build/blueprint
platform/build/kati
platform/build/soong
.......
2.用 sed 命令在每一行的前面都加上相同的字符串
sed ‘s/^/ssh -p 29418 [email protected]服务器IP gerrit create-project /‘ pro.log > pro.sh
pro.sh文件内容如下:
ssh -p 29418 [email protected] gerrit create-project platform/abi/cpp (在gerrit上创建新的project)
ssh -p 29418 [email protected] gerrit create-project platform/art
ssh -p 29418 [email protected] gerrit create-project platform/bionic
ssh -p 29418 [email protected] gerrit create-project kernel/lk
ssh -p 29418 [email protected] gerrit create-project platform/bootable/recovery
ssh -p 29418 [email protected] gerrit create-project platform/build
ssh -p 29418 [email protected] gerrit create-project platform/build/blueprint
ssh -p 29418 [email protected] gerrit create-project platform/build/kati
ssh -p 29418 [email protected] gerrit create-project platform/build/soong
3.将pro.sh授予可执行权限
chmod 777 pro.sh
4.执行pro.sh文件,在服务器上的gerrit/review_site/git 目录下生成空的仓库目录
./pro.sh
5.将所有的 project push 到服务器上的空的 git 仓库里,并输出push日志到push.log
(repo forall -c ‘pwd && git push HostName:/$REPO_PROJECT HEAD:refs/heads/BranchName‘)2>&1 | tee push.log
6.Push OK的提示
To test:/amss/rpm_proc
[new branch] HEAD -> BranchName
/home/XXX/w0927/BranchName/slpi_proc
remote: Processing changes: refs: 1, done
7.查漏
通过命令 grep -iE "remote: Processing changes: refs: 1, done " push.log | wc -l
说明:ProjectList的count数(也就是pro.log的行数)与这里相等才是全部push到服务器上了
8.出错的project重新push
通过查询 log 发现/frameworks/base 这个 project push 出错,错误的日志在服务器的/review_site/logs/error_log 里有
git push ssh://HostName/frameworks/base HEAD:refs/heads/BranchName