git 过滤器分支到 git 过滤器 repo 转换

git filter branch to git filter repo conversion

我正在按照此命令对我的 git 存储库中的所有提交执行更漂亮的操作:

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

我想在 git filter repo 中执行相同的操作,但我什至不确定这是否可以实现。任何人都可以帮助解决如何使用 git 过滤器回购协议吗?

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

是的,这是一个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()
'

reformat_commit as in this python script.