如何在Gerrit中创建合并补丁和先前合并补丁之间的依赖关系?

3
2个回答

4

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

在您的情况下,您有两个不同存储库中的两个变更。目前,Gerrit不支持跨存储库的依赖关系。这是一个常见的请求功能,上周末在Gerrit用户会议上刚刚讨论。希望在未来的Gerrit版本中增加对跨存储库依赖关系的支持。


抱歉 - 如我上面所说,您想要做的目前在Gerrit中是不可能的。这是开发人员正在思考和努力解决的问题。许多用户想要做到这一点,但目前无法实现。 - Brad
我是指在git中...所以如果有人寻找这个问题,他会看到一个解决方案。 - 0x90
1
支持 Git 中跨存储库依赖项的唯一方法是使用子模块。在 http://git-scm.com/book/en/Git-Tools-Submodules 上有很多文档可供参考。 - Brad

3

使用从这里获取的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`

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接