X-Git-Url: https://perl5.git.perl.org/perl5.git/blobdiff_plain/241240e5f5eec9134729b63037803b23f7333dad..daa565d026db59bdc912c9e6c35dfa9f5eb6ba1e:/Porting/git-deltatool diff --git a/Porting/git-deltatool b/Porting/git-deltatool index 3c413ff..33bd595 100644 --- a/Porting/git-deltatool +++ b/Porting/git-deltatool @@ -92,11 +92,12 @@ sub assign { my @choices = ( $self->section_choices, $self->action_choices ); $self->_iterate_commits( sub { - my $log = shift; - say ""; + my ($log, $i, $count) = @_; + say "\n### Commit @{[$i+1]} of $count ###"; say "-" x 75; $self->show_header($log); $self->show_body($log, 1); + $self->show_files($log); say "-" x 75; return $self->dispatch( $self->prompt( @choices ), $log); } @@ -109,8 +110,8 @@ sub review { my @choices = ( $self->review_choices, $self->action_choices ); $self->_iterate_commits( sub { - my $log = shift; - say ""; + my ($log, $i, $count) = @_; + say "\n### Commit @{[$i+1]} of $count ###"; say "-" x 75; $self->show_header($log); $self->show_notes($log, 1); @@ -178,8 +179,10 @@ sub _iterate_commits { my ($self, $fcn) = @_; my $type = $self->opt('type'); say STDERR "Scanning for $type commits since " . $self->last_tag . "..."; - for my $log ( $self->find_commits($type) ) { - redo unless $fcn->($log); + my $list = [ $self->find_commits($type) ]; + my $count = @$list; + while ( my ($i,$log) = each @$list ) { + redo unless $fcn->($log, $i, $count); } return 1; } @@ -219,22 +222,21 @@ sub edit_text { $args //= {}; my $tempfh = File::Temp->new; $tempfh->printflush( $text ); - if ( my (@editor) = $ENV{VISUAL} || $ENV{EDITOR} ) { + if ( my @editor = split /\s+/, ($ENV{VISUAL} || $ENV{EDITOR}) ) { push @editor, "-f" if $editor[0] =~ /^gvim/; system(@editor, "$tempfh"); } else { warn("No VISUAL or EDITOR defined"); } - $tempfh->seek(0,0); - return do { local $/; <$tempfh> }; + return do { local (@ARGV,$/) = "$tempfh"; <> }; } sub find_commits { my ($self, $type) = @_; $type //= 'new'; my @commits = $self->git->log($self->last_tag . "..HEAD"); - $_ = Git::Wrapper::XLog->from_log($_) for @commits; + $_ = Git::Wrapper::XLog->from_log($_, $self->git) for @commits; my @list; if ( $type eq 'new' ) { @list = grep { ! $_->notes } @commits; @@ -323,10 +325,21 @@ sub show_body { return; } +sub show_files { + my ($self, $log) = @_; + my @files = $self->git->diff_tree({r => 1, abbrev => 1}, $log->id); + shift @files; # throw away commit line + return unless @files; + say "\nChanged:"; + say join("\n", map { " * $_" } sort map { /.*\s+(\S+)/; $1 } @files); + return; +} + sub show_header { my ($self, $log) = @_; my $header = $log->short_id; $header .= " " . $log->subject if length $log->subject; + $header .= sprintf(' (%s)', $log->author) if $log->author; say colored( $header, "yellow"); return; } @@ -409,10 +422,9 @@ sub do_head2 { my $section = _strip_parens($choice->{name}); my $subject = $log->subject; my $body = $log->body; - my $id = $log->short_id; my $template = $self->note_template( $log, - "perldelta: $section [pending]\n\n=head2 $subject\n\n$body ($id)\n" + "perldelta: $section [pending]\n\n=head2 $subject\n\n$body\n" ); my $note = $self->edit_text( $template ); @@ -428,10 +440,9 @@ sub do_linked_item { my $section = _strip_parens($choice->{name}); my $subject = $log->subject; my $body = $log->body; - my $id = $log->short_id; my $template = $self->note_template( $log, - "perldelta: $section [pending]\n\n=head3 L\n\n=over\n\n=item *\n\n$subject ($id)\n\n$body\n\n=back\n" + "perldelta: $section [pending]\n\n=head3 L\n\n=over\n\n=item *\n\n$subject\n\n$body\n\n=back\n" ); my $note = $self->edit_text($template); @@ -447,10 +458,9 @@ sub do_item { my $section = _strip_parens($choice->{name}); my $subject = $log->subject; my $body = $log->body; - my $id = $log->short_id; my $template = $self->note_template( $log, - "perldelta: $section [pending]\n\n=item *\n\n$subject ($id)\n\n$body\n" + "perldelta: $section [pending]\n\n=item *\n\n$subject\n\n$body\n" ); my $note = $self->edit_text($template); @@ -473,10 +483,9 @@ sub do_platform { my $section = _strip_parens($choice->{name}); my $subject = $log->subject; my $body = $log->body; - my $id = $log->short_id; my $template = $self->note_template( $log, - "perldelta: $section [pending]\n\n=item PLATFORM-NAME\n\n$subject ($id)\n\n$body\n" + "perldelta: $section [pending]\n\n=item PLATFORM-NAME\n\n$subject\n\n$body\n" ); my $note = $self->edit_text($template); @@ -498,14 +507,13 @@ sub do_special { my $section = _strip_parens($choice->{name}); my $subject = $log->subject; my $body = $log->body; - my $id = $log->short_id; my $template = $self->note_template( $log, << "HERE" ); perldelta: $section [pending] $subject -$body ($id) +$body HERE my $note = $self->edit_text( $template ); @@ -774,9 +782,10 @@ BEGIN { our @ISA = qw/Git::Wrapper::Log/; } sub subject { shift->attr->{subject} } sub body { shift->attr->{body} } sub short_id { shift->attr->{short_id} } +sub author { shift->attr->{author} } sub from_log { - my ($class, $log) = @_; + my ($class, $log, $git) = @_; my $msg = $log->message; my ($subject, $body) = $msg =~ m{^([^\n]+)\n*(.*)}ms; @@ -784,7 +793,7 @@ sub from_log { $body //= ''; $body =~ s/[\r\n]*\z//ms; - my ($short) = Git::Wrapper->new(".")->rev_parse({short => 1}, $log->id); + my ($short) = $git->rev_parse({short => 1}, $log->id); $log->attr->{subject} = $subject; $log->attr->{body} = $body;