【问题标题】:How to create dependencies between merged patch and before merged patch in gerrit?如何在gerrit中创建合并补丁和合并补丁之前的依赖关系?
【发布时间】:2012-11-19 18:05:13
【问题描述】:

我在 gerrit 上有两个补丁,我想让未合并的补丁依赖于合并的补丁。

两者都已上传到 gerrit。

  • 我该怎么做?有可能吗?

  • 我可以通过 gerrit 来实现吗?不是通过git 和樱桃采摘。

假设https://gerrit.wikimedia.org/r/#/c/34106/ 是未合并的文件

合并后的文件https://gerrit.wikimedia.org/r/#/c/25756/

【问题讨论】:

    标签: linux git dependencies patch gerrit


    【解决方案1】:

    Gerrit 中的依赖关系只是 Git 树图的一种表示。因此,要使变更 B 依赖于变更 A,B 必须以 A 作为其父项。

    在您的情况下,您在两个不同的存储库中有两个更改。 Gerrit 目前不支持跨存储库依赖项。但是,它是commonly-requested feature,刚刚在上周末的 Gerrit 用户大会上进行了讨论。希望未来版本的 Gerrit 会添加对跨存储库依赖项的支持。

    【讨论】:

    • 抱歉 - 就像我上面所说的,您想要做的事情目前在 Gerrit 中是不可能的。这是开发人员正在考虑和努力的事情。很多用户都想这样做,但目前还做不到。
    • 我的意思是在 git... 所以如果有人寻找这个问题,他会看到一个解决方案。
    • 在 git 中支持跨仓库依赖的唯一方法是使用子模块。 git-scm.com/book/en/Git-Tools-Submodules 有很多文档
    【解决方案2】:

    使用来自here的git命令:

    git fetch --all # Make sure we have latest info from the repository
    git review -d 1234 # Gerrit change number of the change you want as dependency ("parent")
    
    git checkout -b bug/1234 # Creates a new branch, with the current branch (the dependency) as parent
    # Edit files: make your changes
    git add someFile.php some/other/file.js 
    git commit # Commit your patch
    
    git log -n5 --decorate --pretty=oneline # Verify that the last 5 entries of the log now start with:
    # * (HEAD, bug/1234) your change
    # * (review/john/700) the dependency
    # * (gerrit/master)
    
    git push gerrit HEAD:refs/for/master # Use this instead of `git review`
    
    git branch # Take note of the review/* branch that was created for this, it has an "*" in front of it
    git checkout bug/1234 # Check out the local topic branch of your change
    git rebase review/john/7000 # The branch name of the gerrit change we checked out earlier
    
    # Resolve conflicts if needed,
    # - use "git status" to see the files that need resolution
    # - after fixing it in your editor, "git add filename" for each of the fixed files 
    
    git commit --amend -c HEAD # Re-commit your patch replacing the one with the wrong parent
    
    git log -n5 --decorate --pretty=oneline # Verify that the last 5 entries of the log now start with:
    # * (HEAD, bug/1234) your change
    # * (review/john/700) the dependency
    # * (gerrit/master)
    
    git push gerrit HEAD:refs/for/master # Use this instead of `git review`
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-01-18
      • 2016-11-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-04-13
      • 2014-10-12
      • 2012-07-22
      相关资源
      最近更新 更多