Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git filter branch to git filter repo conversion

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?

like image 898
Ehsan Mahmud Avatar asked Mar 07 '26 06:03

Ehsan Mahmud


1 Answers

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.

like image 192
VonC Avatar answered Mar 10 '26 06:03

VonC