Sample Header Ad - 728x90

bash: Split log into parsable chunks

0 votes
1 answer
299 views
I have a variable log which contains svn history:
$ log=$(svn log -r 9:11)
$ echo "%s\n" "$log"
------------------------------------------------------------------------
r9 | stew | 2021-03-06 20:14:57 +0100 (Sat, 06 Mar 2021) | 1 line

Moving things to trunk
------------------------------------------------------------------------
r10 | stew | 2021-03-06 20:16:27 +0100 (Sat, 06 Mar 2021) | 1 line

Adding script svn2redmine
------------------------------------------------------------------------
r11 | stew | 2021-03-06 20:19:38 +0100 (Sat, 06 Mar 2021) | 2 lines

Moving stuff to a file execute permissions.
This is a multi-line message
------------------------------------------------------------------------
I have a good script which will parse individual commit messages. But right now I call it with:
for rev in {9..11}; do
  parse "$(svn log -r $rev)"
done
That means, I'm making lots of svn log requests which each establishes another connection to the server and is thus slow. I'd rather:
log=$(svn log -r 9:11)
for commit in "$log"; do
  parse "$commit"
done
But how can I split "$log" into individual commits?
Asked by Stewart (15631 rep)
Apr 8, 2021, 09:57 AM