Jan Nieuwenhuizen <janneke-list@xxxxxxxxx> writes: > On za, 2008-08-02 at 10:36 -0700, Junio C Hamano wrote: > >> > You forgot to document your option. (And possibly write a testcase.) >> >> I am not sure if this is generic enough to be in git-svn.perl itself, or >> perhaps there should be a hook make_log_entry() would call in the form of >> some Perl scriptlet given by the user to munge $log_entry{log}, which >> would be very specific to each project. > > If you're not sure, please make up your mind. That's something you would say when I cannot decide the color of bikeshed. I do not think your change falls into that category. We could add an ad-hoc preprocessing option like this, and keep adding more for different patterns, and at certain point we may be fed up with millions of such options and try to introduce a more generic mechanism. While doing so, the resulting code needs to support the ad-hoc ones that are added earlier, forever. We've done that in the past with other commands (cc-suppression scheme in send-email comes to mind). It was very unpleasant. > ... Doing this in a single > regexp is a bit tricky and asking a user to write a perl snippet is even > worse, imho. What you are saying is that a built-in one, no matter what, won't be sufficient for many projects. Unless a user writes Perl snippet to match his project's needs, the noise at the beginning of the log won't be stripped for him. That's fine. I do not expect a single built-in transformation would fit everybody's needs. I am not asking for miracles. But you could at least keep the door open for people who are _willing_ to write such transformation for their projects, right? For one thing, your --cut-changelog-bits has one fixed pattern. Later people either have to come up with different option, or modify your pattern (potentially breaking your project). Neither is good. Perhaps doing something like this a (admittedly slightly) better option? It allows you to choose from a canned set, or give a series of s/// rewriting rules (or whatever you would want to have in the custom function).. --- git-svn.perl | 34 +++++++++++++++++++++++++++++++++- 1 files changed, 33 insertions(+), 1 deletions(-) diff --git a/git-svn.perl b/git-svn.perl index cf6dbbc..eaf6a56 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -66,7 +66,7 @@ my ($_stdin, $_help, $_edit, $_version, $_fetch_all, $_no_rebase, $_merge, $_strategy, $_dry_run, $_local, $_prefix, $_no_checkout, $_url, $_verbose, - $_git_format); + $_git_format, $_clean_changelog, $_clean_log_message); $Git::SVN::_follow_parent = 1; my %remote_opts = ( 'username=s' => \$Git::SVN::Prompt::_username, 'config-dir=s' => \$Git::SVN::Ra::config_dir, @@ -109,9 +109,11 @@ my %cmd = ( fetch => [ \&cmd_fetch, "Download new revisions from SVN", { 'revision|r=s' => \$_revision, 'fetch-all|all' => \$_fetch_all, + 'clean-changelog=s' => \$_clean_changelog, %fc_opts } ], clone => [ \&cmd_clone, "Initialize and fetch revisions", { 'revision|r=s' => \$_revision, + 'clean-changelog=s' => \$_clean_changelog, %fc_opts, %init_opts } ], init => [ \&cmd_init, "Initialize a repo for tracking" . " (requires URL argument)", @@ -238,6 +240,33 @@ my $rv = GetOptions(%opts, 'help|H|h' => \$_help, 'version|V' => \$_version, $Git::SVN::default_repo_id = $_[1] }); exit 1 if (!$rv && $cmd && $cmd ne 'log'); +my %canned_changelog_cleaner = +( + 'ooo' => sub { + local ($_) = @_; + s/(^|\n)\s*((\n|\s)*(199[0-9]|20[0-1][0-9])(-[0-9]{2}){2}\s+.*<.*>\s*\n\s+)?/$1/g; + s/(^|\n)\* /\n$1/g; + s/^[\n\s]*//; + s/\n\s*/ /g if length ($_) < 81; + "\n"; + } +); + +if (defined $_clean_changelog) { + if (exists $canned_changelog_cleaner{$_clean_changelog}) { + $_clean_log_message = $canned_changelog_cleaner{$_clean_changelog}; + } elsif ($_clean_changelog ne '') { + $_clean_log_message = eval " + sub { local(\$_) = \@_; $_clean_changelog; return \$_; } + "; + if ($@) { + die "$!: $_clean_changelog"; + } + } else { + die "$_clean_changelog: unknown way to clean log message"; + } +} + usage(0) if $_help; version() if $_version; usage(1) unless defined $cmd; @@ -2463,6 +2492,9 @@ sub make_log_entry { close $un or croak $!; $log_entry{date} = parse_svn_date($log_entry{date}); + if ($_clean_log_message) { + $log_entry{log} = $_clean_log_message->($log_entry{log}); + } $log_entry{log} .= "\n"; my $author = $log_entry{author} = check_author($log_entry{author}); my ($name, $email) = defined $::users{$author} ? @{$::users{$author}} -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html