7

I have following aliases in my .gitconfig to automate my tag annotations (using my git tag-release alias):

[alias]
  lm = log --pretty=format:'(%h) %s%n%w(72,10,10)%b%w(72,0,0)by %an on %ad%n' --date=local --no-merges
  rn = "!f() { git lm \"${1:-$(git describe --abbrev=0 --tags)}\"..\"${2:-$(git rev-parse HEAD)}\"; }; f \"$@\""
  tag-release = "!f() { { echo \"Release $1\n\nChanges:\n\n\"; git rn; } | git tag -a \"$1\" -F -; }; f \"$@\""

My problem is, that because of %w(72,10,10)%b, my commit body is moved 10 spaces to the right and wrapped at 72 characters, which sometimes gives weirdly formatted tag annotations, because the commit messages themselves contain newlines as well. I was wondering if there's a way to get the commit body, replace the newlines and then wrap that at 72 characters with an indentation of 10? Any help is appreciated!

JBL
  • 12,588
  • 4
  • 53
  • 84
Jelle
  • 298
  • 1
  • 11
  • I can get you part way there (removing the new lines); pipe your `git log` with a `sed` command... i.e. `git log | sed '/^[ \t]*$/d'` – Tom Howard Mar 20 '20 at 20:56
  • This is not an answer but, if you can live with the %b format specifier being at the end of the log line, then you will prevent at least some (or even most) of the newlines. – Patrick Fromberg Apr 29 '20 at 05:55

0 Answers0