如何为一系列樱桃精选添加提交ID? [英] How to add a commit ID to a series of cherry picks?

查看:117
本文介绍了如何为一系列樱桃精选添加提交ID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在努力为LineageOS的发展做出贡献.

I'm trying to contribute to the LineageOS gerrit.

因此,从本质上讲,我樱桃从上游内核分支中选择了一系列提交...

So essentially I cherry picked a range of commits from an upstream kernel branch...

仅现在,没有任何经过挑选的提交具有更改ID. 我知道我可以使用提交钩子手动添加一个,然后:

Only now, none of the cherry picked commits have a Change-ID. I know I can manually add one with a commit hook and:

git commit --amend

但是,大约有834次提交... 我还知道,我可以通过以下方式运行交互式基础,以稍微减轻我的痛苦:

However, there are 834 or so commits... I'm also aware that I could run an interactive rebase to slightly ease my pain via:

git rebase -i $FIRST_CP
# Change every commit from pick to edit
git commit --amend
git rebase --continue

但是,这几乎和樱桃再次挑选每一个提交一样糟糕.

However this is almost just as bad as cherry picking every single commit all over again.

注意:我没有拥有对Gerrit服务器的管理员访问权限,所以我无法暂时删除更改ID的要求.

Note: I do not have admin access to the Gerrit server so I cannot temporarily remove the requirement of change IDs.

我不知所措,这确实阻碍了我的贡献... 希望有人有更好的主意.

I'm at my wits end and this is really putting a damper on my contributions... Hope someone has a better idea.

附件:我还尝试了合并分支,希望它可以被接受……虽然没有骰子.

Addenum: I also tried merging the branch and hoping it would be accepted... No dice though.

推荐答案

尝试git filter-branch --msg-filter.

比方说,我们有一个钩子可以在~/commit-msg处生成Change-Id,现在我们在master上.

Let's say we have the hook to generate Change-Id at ~/commit-msg, and we are now on master.

#create an orphan branch "tmp" from "master".
git checkout --orphan tmp master
git commit -m 'new root'

#cherry-pick all the commits from an upstream kernel branch.
git cherry-pick <all-the-commits>

#rewrite the commit message of every commit on "tmp"
git filter-branch --msg-filter 'git log -1 --pretty=%B $GIT_COMMIT > msg.txt;~/commit-msg msg.txt;cat msg.txt'

#all the commits now have Change-Id
#cherry-pick all of them except the root to "master"
root=$(git log --pretty=%H --max-parents=0)
git checkout master
git cherry-pick $root..tmp

msg.txt在当前存储库下的.git-rewrite/中创建,并且在执行该命令后会自动删除.git-rewrite/.因此,让我们忽略它.

msg.txt is created in .git-rewrite/ under the current repository, and .git-rewrite/ is deleted automatically after the command is done. So let's just ignore it.

msg-filter命令模拟生成Change-Id的过程.我认为它可能更优雅,但可以在我的测试中使用.

The msg-filter command simulates the process of generating Change-Id. I think it could be more elegant, but it works in my test.

这篇关于如何为一系列樱桃精选添加提交ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆