summaryrefslogtreecommitdiff
path: root/Build/source
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2020-02-27 22:08:39 +0000
committerKarl Berry <karl@freefriends.org>2020-02-27 22:08:39 +0000
commit24fb93d21a9eed45ac085a4d4f4711b28840f70e (patch)
tree27235bcbd6e3c49e4793d486e5169836bc179c52 /Build/source
parent2c9de92aba142ec2e77ebc32d13efda669546395 (diff)
latex-git-log (27feb20)
git-svn-id: svn://tug.org/texlive/trunk@53942 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source')
-rwxr-xr-xBuild/source/texk/texlive/linked_scripts/latex-git-log/latex-git-log82
1 files changed, 45 insertions, 37 deletions
diff --git a/Build/source/texk/texlive/linked_scripts/latex-git-log/latex-git-log b/Build/source/texk/texlive/linked_scripts/latex-git-log/latex-git-log
index e074d05a5ce..35d831b6eb6 100755
--- a/Build/source/texk/texlive/linked_scripts/latex-git-log/latex-git-log
+++ b/Build/source/texk/texlive/linked_scripts/latex-git-log/latex-git-log
@@ -1,6 +1,5 @@
#!/usr/bin/env perl
-# @author Robin Schneider <ypid23@aol.de>
-# @licence GPLv3+ <http://www.gnu.org/licenses/gpl.html>
+# SPDX-License-Identifier: GPL-3.0-or-later
# Modules and pragmas {{{
use strict;
@@ -23,6 +22,7 @@ BEGIN {
$dirpath = ( fileparse( abs_path($0) ) )[1];
}
# }}}
+
use Locale::Maketext::Simple (
Path => $dirpath . 'po/',
Decode => 1,
@@ -30,13 +30,14 @@ use Locale::Maketext::Simple (
# }}}
# Optional parameters {{{
-my $print_author = 0;
-my $commit_count = 1;
-my $width = 0;
-my $lang = undef;
-my $version = 0;
-my $help = 0;
-my $man = 0;
+my $print_author = 0;
+my $commit_count = 1;
+my $width = 0;
+my $lang = undef;
+my $version = 0;
+my $help = 0;
+my $man = 0;
+my $revision_range = 0;
my ( $git_user, $git_repo, $git_commit_address );
GetOptions(
'author' => \$print_author,
@@ -49,24 +50,17 @@ GetOptions(
'version' => \$version,
'help|?' => \$help,
'man' => \$man,
+ 'range=s' => \$revision_range,
);
-pod2usage(1) if $help;
-pod2usage( -verbose => 2, -exitstatus => 0, ) if $man;
-pod2usage( -verbose => 99, -sections => 'Version' ) if $version;
+pod2usage( -verbose => 99, -sections => [ qw(Synopsis Options) ] ) if $help;
+pod2usage( -verbose => 2, -exitstatus => 0, ) if $man;
+pod2usage( -verbose => 99, -sections => 'Version' ) if $version;
my $git_remote = ( split /\n/xms, capturex(qw(git remote -v)) )[0];
loc_lang($lang) if ( defined $lang );
-if ( not defined $git_user
- and not defined $git_repo
- and defined $git_remote
- and $git_remote =~ m#\s.*?:(?<user>\w+?)/(?<repo>.*?)\.git\ \(fetch\)\Z#xms )
-{
- $git_user = $+{user};
- $git_repo = $+{repo};
-}
say '%% This file was generated by the script latex-git-log';
my $git_command_commit_msg = '%s';
-if ( defined $git_user and defined $git_repo ) {
+if ( (defined $git_user and defined $git_repo) or $git_commit_address ) {
unless ( defined $git_commit_address ) {
$git_commit_address = "https://github.com/$+{user}/$+{repo}/commit";
}
@@ -133,15 +127,21 @@ if ($print_author) {
else {
push( @git_command, qq(--pretty=format:%H %ad & $git_command_commit_msg) );
}
+if ($revision_range) {
+ push( @git_command, qq($revision_range) );
+}
@lines = reverse capturex(@git_command);
# }}}
# Get tags {{{
-my @tags_commits = capturex( 'git', 'for-each-ref', '--format=%(refname:short) %(objectname)', 'refs/tags' );
+my @tags_commits = capturex( 'git', 'log', '--tags', '--no-walk', '--pretty=\'%H %d\'' );
my %commit_tags; # The key will be a SHA1 commit hash and the value a comma separated list of all tags.
for (@tags_commits) {
- my ( $tag, $c_hash ) = split /\s/xms, $_;
- chomp($c_hash);
+ chomp;
+ m/\A'([^ ]+)\s*\(([^)]+)\)'\z/xms;
+ my $c_hash = $1;
+ my $tag = $2;
+ $tag =~ s/tag: //g;
if ( defined $commit_tags{$c_hash} ) {
$commit_tags{$c_hash} .= ", $tag";
}
@@ -185,11 +185,15 @@ my @changes;
for (@lines) {
next if /\A\Z/xms;
chomp;
+ if ( m/^([0-9a-f]{40})\s/g and !$which_line) {
+ $which_line ^= 1; ## additional toggle for merge commits
+ @changes = ( "-", "-", "-" );
+ }
if ($which_line) {
s/\A([0-9a-f]{40})\s//xms or die "Did not match the commit hash\n";
my $tags = exists $commit_tags{$1} ? $commit_tags{$1} : q();
my $date_author = '';
- my $c_msg;
+ my $c_msg = '';
if ($print_author) {
/(?:& )(.*?)NoTinAuthorFiled(& .*? &) (.*)/;
$date_author = latex_escape($1) . $2;
@@ -200,7 +204,7 @@ for (@lines) {
$date_author = $1;
$c_msg = $2;
}
- if ( defined $git_user and defined $git_repo ) {
+ if ( defined $git_commit_address ) {
$c_msg =~ /(.*?) & (.*)/;
$c_msg = sprintf '\\href{%s/%s}{%s}', $git_commit_address, $1, latex_escape($2);
}
@@ -224,11 +228,12 @@ say '\end{longtable}';
__END__
# Documentation {{{
+=encoding UTF-8
=head1 NAME
latex-git-log - Generates the version history of a git project as LaTeX source code.
-=head1 SYNOPSIS
+=head1 Synopsis
latex-git-log [options]
@@ -244,8 +249,9 @@ Options:
--version, -v print version of this script
--help brief help message
--man full documentation
+ --range specify a git revision range
-=head1 OPTIONS
+=head1 Options
=over 8
@@ -266,7 +272,7 @@ This script will automatically try to use the base URL for github.
=item B<--lang>
-Set the language of the legend and all strings in the output. Be default the
+Set the language of the legend and all strings in the output. By default the
language of your system is used but you can overwrite this with this parameter.
Currently this script only supports English and German. If you need a translation
@@ -281,7 +287,7 @@ You can use it like this:
latex-git-log --width=6 --lang=en > example-output.tex
-=head1 DEPENDENCIES
+=head1 Dependencies
=head2 Of this script
@@ -303,34 +309,36 @@ expanded on the bottom of every page if the table will be continued on the next
page. You can defined it to a localized message to inform the reader that this
table is not complete and will be continued.
-=head1 DESCRIPTION
+=head1 Description
B<This program> will output the entire version history as table written in
LaTeX if it is executed within a git repository.
It is intended that you redirect the standard output of this script to a file
-which can then be included from your main TeX document.
+which can then be included from your main LaTeX document.
Because the table can be very large you might want to put the thing on a
landscape page.
=head1 Version
-0.9
+1.0.0
-=head1 AUTHOR
+=head1 Author
-Robin Schneider <ypid23@aol.de>
+Robin Schneider <ypid@riseup.net>
=head1 Development
+CTAN: https://ctan.org/pkg/latex-git-log
+
Source code repository: https://github.com/ypid/typesetting/tree/master/scripts/latex-git-log
Please report bugs and feature requests at https://github.com/ypid/typesetting/issues
-=head1 LICENSE AND COPYRIGHT
+=head1 License and Copyright
-Copyright (C) 2012-2013 by Robin Schneider
+Copyright (C) 2012-2013,2017,2019 Robin Schneider <ypid@riseup.net>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by