git filter branch to git filter repo conversion

此生再无相见时 提交于 2020-07-07 05:02:20

问题


I am following this command to perform prettier over all commits in my git repository:

git filter-branch --tree-filter 'prettier --write "**/**.js" || echo “Error formatting, possibly invalid JS“' -- --all

I want to perform the same in git filter repo but I am not even sure whether that is achievable. Can anyone help on how to approach this with git filter repo?


回答1:


I want to perform the same in git filter repo but I am not even sure whether that is achievable

Yes, it is a blob callback and allows you to call any script/command you want on said blob, similar to what is done in newren/git-filter-repo issue 45, and this example

git filter-repo --force --blob-callback '
  import black
  blob.data = black.reformat_commit(blob.data.decode(), mode=black.FileMode()).encode()
'

With reformat_commit as in this python script.



来源:https://stackoverflow.com/questions/62123172/git-filter-branch-to-git-filter-repo-conversion

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!