git-filter-repo icon indicating copy to clipboard operation
git-filter-repo copied to clipboard

[Feature req] - easy ammending of commit messages

Open the-Arioch opened this issue 2 years ago • 1 comments

I love the idea behind the git filter-repo --tag-rename '':'my-module-' command.

I want the same no-hassle way to add "anchors" to the commit messages.

This can be done placing a regex into the "expression.txt" but this feels a lot of boilerplate for a simple straightforward usecase.

So i wish for a new option to insert a specific text

  • In the beginning of every message

git filter-repo --add-to-message "[MyLib]" git filter-repo --add-to-message BOF:"[MyLib]" git filter-repo --add-to-message BOL:"[MyLib]" git filter-repo --add-to-message BOLN:"[MyLib]"

Commit messages:

Old: #345 no more crashing on negative numbers New: [MyLib] #345 no more crashing on negative numbers - notice the auto-added space

see the "EOF" option below, maybe the "BOF" option should prepend the commit message with a new line for homogenity? But i won't think this would have a practical use. Maybe "BOF" option should just not exist.

  • After the first word of a message (guessing that would be an issue reference), ideally accounting for [({< bracket pairs and quotes, if the first words starts with any.

git filter-repo --add-to-message WORD:"[MyLib]" git filter-repo --add-to-message 2W:"[MyLib]" git filter-repo --add-to-message NEXT:"[MyLib]"

Commit messages:

Old: #345 no more crashing on negative numbers New: #345 [MyLib] no more crashing on negative numbers

  • Before the end of the first line

git filter-repo --add-to-message EOL:"[MyLib]" git filter-repo --add-to-message EOLN:"[MyLib]"

Commit messages:

Old: #345 no more crashing on negative numbers New: #345 no more crashing on negative numbers [MyLib]

  • Before the end of a whole (potentially multi-line) message, in a newly appended line

git filter-repo --add-to-message EOF:"[MyLib]"

Commit messages:

Old:

#345 no more crashing on negative numbers

Modified: 
  * dir1/sourceA.logo
  * dir2/sourceB.logo

New:

#345 no more crashing on negative numbers

Modified: 
  * dir1/sourceA.logo
  * dir2/sourceB.logo
[MyLib]

Also, about auto-delimiting:

  • git filter-repo --add-to-message '[MyLib] '

New: [MyLib] #345 no more crashing on negative numbers - same result, just using the explicit space instead of implicit.

  • git filter-repo --add-to-message '[MyLib] '

New: [MyLib] #345 no more crashing on negative numbers - two space delimeters were explicitly requested, and added

  • git filter-repo --add-to-message ' [MyLib]'

New: [MyLib] #345 no more crashing on negative numbers - there was no explicit delimiter RIGHT of the added anchor, so still using impicit delimiter there

  • git filter-repo --add-to-message-no-delims '[MyLib]'

New: [MyLib]#345 no more crashing on negative numbers - implicit adding spaces was explicitly suppressed

the-Arioch avatar Jul 04 '23 13:07 the-Arioch

Why not use the --message-callback filter to make such changes?

newren avatar Sep 29 '23 22:09 newren

No response; I'll assume my suggestion solved your problem. Feel free to reopen if that's not the case.

newren avatar Jul 02 '24 16:07 newren