@matheusbsbs / matheus-bagliano / commits / a94f457e89
Fork 0

git-archimport: support empty summaries, put summary on a single line.

Don't fail if the summary line in an arch commit is empty. In this case, try to use the first line in the commit message followed by an ellipsis. In addition, if the summary is multi-line, it is joined on a single line. Signed-off-by: Junio C Hamano <junkio@cox.net>

Paolo Bonzini committed Feb 28, 2007 at 21:02 UTC a94f457e89f78a5a15e63417abdb281ce655f986
1 file changed +15 -4
git-archimport.perl
+15 -4
@@ -553,7 +553,7 @@ foreach my $ps (@psets) {
553
554 my $pid = open2(*READER, *WRITER,'git-commit-tree',$tree,@par)
555 or die $!;
556 - print WRITER $ps->{summary},"\n";
556 + print WRITER $ps->{summary},"\n\n";
557 print WRITER $ps->{message},"\n";
558
559 # make it easy to backtrack and figure out which Arch revision this was:
@@ -755,7 +755,8 @@ sub parselog {
755 $ps->{tag} = $1;
756 $key = undef;
757 } elsif (/^Summary:\s*(.*)$/ ) {
758 - # summary can be multiline as long as it has a leading space
758 + # summary can be multiline as long as it has a leading space.
759 + # we squeeze it onto a single line, though.
760 $ps->{summary} = [ $1 ];
761 $key = 'summary';
762 } elsif (/^Creator: (.*)\s*<([^\>]+)>/) {
@@ -787,8 +788,18 @@ sub parselog {
788 }
789 }
790
790 - # post-processing:
791 - $ps->{summary} = join("\n",@{$ps->{summary}})."\n";
791 + # drop leading empty lines from the log message
792 + while (@$log && $log->[0] eq '') {
793 + shift @$log;
794 + }
795 + if (exists $ps->{summary} && @{$ps->{summary}}) {
796 + $ps->{summary} = join(' ', @{$ps->{summary}});
797 + }
798 + elsif (@$log == 0) {
799 + $ps->{summary} = 'empty commit message';
800 + } else {
801 + $ps->{summary} = $log->[0] . '...';
802 + }
803 $ps->{message} = join("\n",@$log);
804
805 # skip Arch control files, unescape pika-escaped files