将提交哈希添加到每个提交消息
我想知道如何在 git filter-repo --commit-callback 的帮助下向每个提交消息添加原始提交哈希
我尝试过的是 git filter-repo -- commit-callback script.py --force,其中 script.py
包含
def commit_callback(commit):
commit.message = commit.message + '\n' + commit.original_id
但它没有效果,我也尝试通过 commit.author_name 更改作者姓名,它没有有什么影响有
什么解决办法吗?
I'm wondering how to add an original commit hash to each commit message with a help of git filter-repo --commit-callback
What I've tried is git filter-repo --commit-callback script.py --force
, where script.py
contains
def commit_callback(commit):
commit.message = commit.message + '\n' + commit.original_id
But it has no effect, also I've tried to change author name via commit.author_name, it does not have any effect either
Any solutions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为这个答案对你来说来得太晚了,但对于遇到同样问题的其他人来说:
你的脚本定义了一个应用于每个提交的函数,但它必须包含每个提交需要执行的内容。
目前,您的脚本所做的只是定义一个从未调用的函数。如果删除
def
行(和缩进),脚本实际上将按照您的预期运行。那么脚本仍然会失败,因为
commit
中的字段是bytes
而不是str
。固定 python 文件的完整内容为:I assume this answer comes too late for you, but for other people who run into the same issue:
Your script defines a function to be applied for each commit, but it must contain what needs to be executed for each commit.
At the moment all your script does is defining a function that does never called. If you remove the
def
line (and indentation) the script will actually run like you intended.The script will still fail then, because the fields in
commit
arebytes
and notstr
. The complete content of the fixed python file would be: