I would like to apply the attached patch to git_changelog for use in
creating the major release notes.  I specifically added these flags:

    --author-after  Show author after the commit
    --master-only   Show commits made exclusively to the master branch
    --reverse-order Show commits in reverse date order

The default output is unaffected.

-- 
  Bruce Momjian  <br...@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + It's impossible for everything to be true. +
diff --git a/src/tools/git_changelog b/src/tools/git_changelog
new file mode 100755
index af76f6d..3cd5af4
*** a/src/tools/git_changelog
--- b/src/tools/git_changelog
*************** my @BRANCHES = qw(master REL9_0_STABLE R
*** 43,51 ****
  # Might want to make this parameter user-settable.
  my $timestamp_slop = 600;
  
  my $post_date = 0;
  my $since;
! Getopt::Long::GetOptions('post-date' => \$post_date,
                           'since=s' => \$since) || usage();
  usage() if @ARGV;
  
--- 43,60 ----
  # Might want to make this parameter user-settable.
  my $timestamp_slop = 600;
  
+ my $author_after = 0;
  my $post_date = 0;
+ my $master_only = 0;
+ my $reverse_order = 0;
  my $since;
! my @output_buffer;
! my $output_line = '';
! 
! Getopt::Long::GetOptions('author-after' => \$author_after,
! 			 'master-only' => \$master_only,
! 			 'post-date' => \$post_date,
! 			 'reverse-order' => \$reverse_order,
                           'since=s' => \$since) || usage();
  usage() if @ARGV;
  
*************** while (1) {
*** 193,211 ****
  	last if !defined $best_branch;
  	my $winner =
  		$all_commits_by_branch{$best_branch}->[$position{$best_branch}];
! 	printf "Author: %s\n", $winner->{'author'};
! 	foreach my $c (@{$winner->{'commits'}}) {
! 	    printf "Branch: %s", $c->{'branch'};
! 	    if (defined $c->{'last_tag'}) {
! 		printf " Release: %s", $c->{'last_tag'};
! 	    }
! 	    printf " [%s] %s\n", substr($c->{'commit'}, 0, 9), $c->{'date'};
  	}
! 	print "Commit-Order-Inversions: $best_inversions\n"
! 		if $best_inversions != 0;
! 	print "\n";
! 	print $winner->{'message'};
! 	print "\n";
  	$winner->{'done'} = 1;
  	for my $branch (@BRANCHES) {
  		my $leader = $all_commits_by_branch{$branch}->[$position{$branch}];
--- 202,229 ----
  	last if !defined $best_branch;
  	my $winner =
  		$all_commits_by_branch{$best_branch}->[$position{$best_branch}];
! 
! 	# check for master-only
! 	if (! $master_only || ($winner->{'commits'}[0]->{'branch'} eq 'master' &&
! 	    @{$winner->{'commits'}} == 1)) {
! 		output_entry("Author: %s\n", $winner->{'author'}) if (! $author_after);
! 		foreach my $c (@{$winner->{'commits'}}) {
! 		    output_entry("Branch: %s ", $c->{'branch'}) if (! $master_only);
! 		    if (defined $c->{'last_tag'}) {
! 			output_entry("Release: %s ", $c->{'last_tag'});
! 		    }
! 		    output_entry("[%s] %s\n", substr($c->{'commit'}, 0, 9), $c->{'date'});
! 		}
! 		output_entry("Commit-Order-Inversions: $best_inversions\n")
! 			if $best_inversions != 0;
! 		output_entry("\n");
! 		output_entry("%s", $winner->{'message'});
! 		output_entry("%s\n", $winner->{'author'}) if ($author_after);
! 		output_entry("\n");
! 		unshift(@output_buffer, $output_line) if ($reverse_order);
! 		$output_line = '';
  	}
! 
  	$winner->{'done'} = 1;
  	for my $branch (@BRANCHES) {
  		my $leader = $all_commits_by_branch{$branch}->[$position{$branch}];
*************** while (1) {
*** 216,221 ****
--- 234,241 ----
  	}
  }
  
+ print @output_buffer if ($reverse_order);
+ 
  sub push_commit {
  	my ($c) = @_;
  	my $ht = hash_commit($c);
*************** sub parse_datetime {
*** 274,284 ****
  	return $gm - $tzoffset;
  }
  
  sub usage {
  	print STDERR <<EOM;
! Usage: git_changelog [--post-date/-p] [--since=SINCE]
!     --post-date Show branches made after a commit occurred
!     --since     Print only commits dated since SINCE
  EOM
  	exit 1;
  }
--- 294,316 ----
  	return $gm - $tzoffset;
  }
  
+ sub output_entry {
+ 	if (! $reverse_order) {
+ 		printf(@_);
+ 	} else {
+ 		my $fmt = shift;
+ 		$output_line .= sprintf($fmt, @_);
+ 	}
+ }
+ 
  sub usage {
  	print STDERR <<EOM;
! Usage: git_changelog [--author-after/-a] [--master-only/-m] [--post-date/-p] [--reverse-order/-r] [--since=SINCE]
!     --author-after  Show author after the commit
!     --master-only   Show commits made exclusively to the master branch
!     --post-date     Show branches made after a commit occurred
!     --reverse-order Show commits in reverse date order
!     --since         Print only commits dated since SINCE
  EOM
  	exit 1;
  }
-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to