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

git-svnimport: Parse log message for Signed-off-by: lines

This add '-S' option. When specified svn-import will try to parse commit message for 'Signed-off-by: ...' line, and if found will use the name and email address extracted at first occurrence as this commit author name and author email address. Committer name and email are extracted in usual way. Signed-off-by: Sasha Khapyorsky <sashak@voltaire.com> Signed-off-by: Junio C Hamano <junkio@cox.net>

Sasha Khapyorsky committed Sep 5, 2006 at 21:46 UTC ae35b30433f5b732bd21f9577711584e3f9bba06
1 file changed +20 -11
git-svnimport.perl
+20 -11
@@ -31,7 +31,7 @@ $SIG{'PIPE'}="IGNORE";
31 $ENV{'TZ'}="UTC";
32
33 our($opt_h,$opt_o,$opt_v,$opt_u,$opt_C,$opt_i,$opt_m,$opt_M,$opt_t,$opt_T,
34 - $opt_b,$opt_r,$opt_I,$opt_A,$opt_s,$opt_l,$opt_d,$opt_D);
34 + $opt_b,$opt_r,$opt_I,$opt_A,$opt_s,$opt_l,$opt_d,$opt_D,$opt_S);
35
36 sub usage() {
37 print STDERR <<END;
@@ -39,12 +39,12 @@ Usage: ${\basename $0} # fetch/update GIT from SVN
39 [-o branch-for-HEAD] [-h] [-v] [-l max_rev]
40 [-C GIT_repository] [-t tagname] [-T trunkname] [-b branchname]
41 [-d|-D] [-i] [-u] [-r] [-I ignorefilename] [-s start_chg]
42 - [-m] [-M regex] [-A author_file] [SVN_URL]
42 + [-m] [-M regex] [-A author_file] [-S] [SVN_URL]
43 END
44 exit(1);
45 }
46
47 -getopts("A:b:C:dDhiI:l:mM:o:rs:t:T:uv") or usage();
47 +getopts("A:b:C:dDhiI:l:mM:o:rs:t:T:Suv") or usage();
48 usage if $opt_h;
49
50 my $tag_name = $opt_t || "tags";
@@ -531,21 +531,30 @@ sub copy_path($$$$$$$$) {
531
532 sub commit {
533 my($branch, $changed_paths, $revision, $author, $date, $message) = @_;
534 - my($author_name,$author_email,$dest);
534 + my($committer_name,$committer_email,$dest);
535 + my($author_name,$author_email);
536 my(@old,@new,@parents);
537
538 if (not defined $author or $author eq "") {
538 - $author_name = $author_email = "unknown";
539 + $committer_name = $committer_email = "unknown";
540 } elsif (defined $users_file) {
541 die "User $author is not listed in $users_file\n"
542 unless exists $users{$author};
542 - ($author_name,$author_email) = @{$users{$author}};
543 + ($committer_name,$committer_email) = @{$users{$author}};
544 } elsif ($author =~ /^(.*?)\s+<(.*)>$/) {
544 - ($author_name, $author_email) = ($1, $2);
545 + ($committer_name, $committer_email) = ($1, $2);
546 } else {
547 $author =~ s/^<(.*)>$/$1/;
547 - $author_name = $author_email = $author;
548 + $committer_name = $committer_email = $author;
549 + }
550 +
551 + if ($opt_S && $message =~ /Signed-off-by:\s+(.*?)\s+<(.*)>\s*\n/) {
552 + ($author_name, $author_email) = ($1, $2);
553 + } else {
554 + $author_name = $committer_name;
555 + $author_email = $committer_email;
556 }
557 +
558 $date = pdate($date);
559
560 my $tag;
@@ -772,8 +781,8 @@ sub commit {
781 "GIT_AUTHOR_NAME=$author_name",
782 "GIT_AUTHOR_EMAIL=$author_email",
783 "GIT_AUTHOR_DATE=".strftime("+0000 %Y-%m-%d %H:%M:%S",gmtime($date)),
775 - "GIT_COMMITTER_NAME=$author_name",
776 - "GIT_COMMITTER_EMAIL=$author_email",
784 + "GIT_COMMITTER_NAME=$committer_name",
785 + "GIT_COMMITTER_EMAIL=$committer_email",
786 "GIT_COMMITTER_DATE=".strftime("+0000 %Y-%m-%d %H:%M:%S",gmtime($date)),
787 "git-commit-tree", $tree,@par);
788 die "Cannot exec git-commit-tree: $!\n";
@@ -825,7 +834,7 @@ sub commit {
834 print $out ("object $cid\n".
835 "type commit\n".
836 "tag $dest\n".
828 - "tagger $author_name <$author_email>\n") and
837 + "tagger $committer_name <$committer_email>\n") and
838 close($out)
839 or die "Cannot create tag object $dest: $!\n";
840