3

我们在项目中使用了 git-repo 工具,但我们不使用 gerrit 进行代码审查。到目前为止,我们使用常规的 git 命令来推送我们的更改,但是由于 repos 的数量不断增加,使用repo 上传功能会很酷。

repo 上传需要清单中的审核服务器。我尝试添加常规的 git 遥控器,但这不起作用。

一个潜在的解决方案是编写一个repo forall -c ...命令,在所有 repos中执行git push 。我仍然喜欢repo 上传的内置功能,想知道是否可以在没有 gerrit 审查的情况下拥有类似的功能。理想情况下类似repo push

根据 repo 的帮助,这样的命令不可用:

$ repo help --all
usage: repo COMMAND [ARGS]
The complete list of recognized repo commands are:
  abandon        Permanently abandon a development branch
  branch         View current topic branches
  branches       View current topic branches
  checkout       Checkout a branch for development
  cherry-pick    Cherry-pick a change.
  diff           Show changes between commit and working tree
  diffmanifests  Manifest diff utility
  download       Download and checkout a change
  forall         Run a shell command in each project
  gitc-delete    Delete a GITC Client.
  gitc-init      Initialize a GITC Client.
  grep           Print lines matching a pattern
  help           Display detailed help on a command
  info           Get info on the manifest branch, current branch or unmerged branches
  init           Initialize repo in the current directory
  list           List projects and their associated directories
  manifest       Manifest inspection utility
  overview       Display overview of unmerged project branches
  prune          Prune (delete) already merged topics
  rebase         Rebase local branches on upstream branch
  selfupdate     Update repo to the latest version
  smartsync      Update working tree to the latest known good revision
  stage          Stage file(s) for commit
  start          Start a new branch for development
  status         Show the working tree status
  sync           Update working tree to the latest revision
  upload         Upload changes for code review
  version        Display the version of repo
See 'repo help <command>' for more information on a specific command.

有人知道是否可以在没有 gerrit 审查的情况下通过 repo 推送更改?

4

1 回答 1

0

我认为回购协议下没有任何东西可以满足您的要求。如果有的话,我也很想了解它。但我最终编写了一个简单的 bash 脚本,它可以满足您的要求,这也是我在我的 repo 项目中使用的。

只需从包含清单文件的主存储库运行此脚本。

#!/bin/bash

#go through each subrepo and push local commits
for directory in */; do 
    cd $directory;  #go into the subrepo
    Current_Branch=$(git branch | sed -n -e 's/^\* \(.*\)/\1/p')    #current checked out local branch - taken from https://stackoverflow.com/a/2111099/4441211
    git push origin $Current_Branch
done
于 2021-05-25T08:17:46.787 回答