Skip to content
Permalink
Browse files
Optimized (mainly LaTeX-git-wdiff).
  • Loading branch information
Robin Schneider committed May 22, 2013
1 parent 782b0e0 commit f3048459117aa782b32324bd08ce77bfde325a62
15 COPYING
@@ -0,0 +1,15 @@
Copyright (C) 2012-2013 by Robin Schneider <ypid23@aol.de>

This work may be distributed and/or modified under the
conditions of the LaTeX Project Public License, either version 1.3
of this license or (at your option) any later version.
The latest version of this license is in
http://www.latex-project.org/lppl.txt
and version 1.3 or later is part of all distributions of LaTeX
version 2005/12/01 or later.

This work has the LPPL maintenance status `maintained'.

The Current Maintainer of this work is Robin Schneider.

This work consists of all files in this repository.
@@ -1,50 +1,70 @@
#!/usr/bin/perl
#!/usr/bin/env perl
use strict;
use warnings;
use autodie;
use feature qw(say);
use utf8;
use open qw(:std :utf8);
binmode STDOUT, ':encoding(UTF-8)';
use IPC::System::Simple qw(capturex);
use Getopt::Long;
use Pod::Usage;

# Optional parameters {{{
my $man = 0;
my $help = 0;
my $print_author = 0;
my $commit_count = 1;
my $width = 0;
my( $git_user, $git_repo, $git_commit_address );
GetOptions ('startcommit=s' => \$commit_count,
'author' => \$print_author,
'width=s' => \$width,
'git-c-add=s' => \$git_commit_address,
'user=s' => \$git_user,
'repo=s' => \$git_repo,
my $width = 0;
my ( $git_user, $git_repo, $git_commit_address );
GetOptions(
'startcommit=s' => \$commit_count,
'author' => \$print_author,
'width=s' => \$width,
'git-c-add=s' => \$git_commit_address,
'user=s' => \$git_user,
'repo=s' => \$git_repo,
'help|?' => \$help,
'man' => \$man,
);
my $git_remote = (split /\n/, capturex(qw(git remote -v)))[0];
if ($git_remote =~ m#\s.*?:(?<user>\w+?)/(?<repo>.*?)\.git\ \(fetch\)\Z#xms) {
pod2usage(1) if $help;
pod2usage( -exitstatus => 0, -verbose => 2 ) if $man;
my $git_remote = ( split /\n/xms, capturex(qw(git remote -v)) )[0];

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};
}
my $git_command_commit_msg = '%H';
if (defined $git_user and defined $git_repo) {
unless (defined $git_commit_address) {
my $git_command_commit_msg = '%s';
if ( defined $git_user and defined $git_repo ) {
unless ( defined $git_commit_address ) {
$git_commit_address = "https://github.com/$+{user}/$+{repo}/commit";
}
$git_command_commit_msg = "\\href{$git_commit_address/%H}{%s}";
say "%% Base git commit URL: ". $git_commit_address;
say "%% Base git commit URL: " . $git_commit_address;
}
if ($width) {
$width = "p{${width}cm}";
} else {
}
else {
$width = 'l';
}
## Tags auslesen und benutzen
# }}}

# LaTeX template {{{
say '\begin{tabular}{lp{12cm}}
% \lable{tabular:Legende:git-log}
\textbf{Abkürzung} & \textbf{Bedeutung} \\\\\\
V & \texttt{Version} \\\\
Tag & \texttt{Markierung} einer Menge von Dateien,
aus denen sich zu einem beliebigen Zeitpunkt eine bestimmte Version wiederherstellen lässt \\\\
Fm & Wie viele \texttt{Dateien} innerhalb dieser Version \texttt{verändert} wurden \\\\
La & Wie viele \texttt{Zeilen} innerhalb dieser Version neu \texttt{hinzugekommen} sind \\\\
Ld & Wie viele \texttt{Zeilen} innerhalb dieser Version \texttt{gelöscht} wurden \\\\
% \lable{tabular:Legende:git-log}
\textbf{Abkürzung} & \textbf{Bedeutung} \\\\\\
V & \texttt{Version} \\\\
Tag & \texttt{Markierung} einer Menge von Dateien,
aus denen sich zu einem beliebigen Zeitpunkt eine bestimmte Version wiederherstellen lässt \\\\
Fm & Wie viele \texttt{Dateien} innerhalb dieser Version \texttt{verändert} wurden \\\\
La & Wie viele \texttt{Zeilen} innerhalb dieser Version neu \texttt{hinzugekommen} sind \\\\
Ld & Wie viele \texttt{Zeilen} innerhalb dieser Version \texttt{gelöscht} wurden \\\\
\end{tabular}
\bigskip
@@ -60,7 +80,8 @@ say '& \multicolumn{1}{c}{\textbf{Datum}}
& \multicolumn{1}{c}{\textbf{La}} & \multicolumn{1}{c|}{\textbf{Ld}} \\\\ \hline}';
if ($print_author) {
say "\\begin{longtable}{|rllllrrr|}";
} else {
}
else {
say "\\begin{longtable}{|rll${width}rrr|}";
}
say '\longtableheader
@@ -71,42 +92,115 @@ say '\longtableheader
';
if ($print_author) {
say '\hline \multicolumn{8}{|r|}{\longtableendfoot} \\\\ \hline';
} else {
}
else {
say '\hline \multicolumn{7}{|r|}{\longtableendfoot} \\\\ \hline';
}
say '\endfoot
\hline% \hline
\endlastfoot
';
## git log --pretty=format:'%ai'
## git log --date=short --pretty=format:'%ad'
## for privacy
# }}}

# Get version history from git log {{{
# git log --pretty=format:'%ai'
# git log --date=short --pretty=format:'%ad'
my @lines;
my @git_command = qw(git log --date=short --shortstat);
if ($print_author) {
push(@git_command, qq(--pretty=format:%d & %an & %ad & $git_command_commit_msg));
} else {
push(@git_command, qq(--pretty=format:%d & %ad & $git_command_commit_msg));
push( @git_command, qq(--pretty=format:%H & %an & %ad & $git_command_commit_msg) );
}
else {
push( @git_command, qq(--pretty=format:%H %ad & $git_command_commit_msg) );
}
@lines = reverse capturex(@git_command);
# }}}

# Get tags {{{
my @tags_commits = capturex( 'git', 'for-each-ref', '--format=%(refname:short) %(objectname)', 'refs/tags' );
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);
if ( defined $commit_tags{$c_hash} ) {
$commit_tags{$c_hash} .= ", $tag";
}
else {
$commit_tags{$c_hash} = $tag;
}
}
# }}}

# Loop over all commits {{{
my $which_line = 0;
my @changes;
for (@lines) {
next if /\A\Z/xms;
chomp;
if ($which_line) {
s#\(\w+?/\w+?\) ##;
s/\((?:HEAD, |)(.*?)(?:, master|)\)/$1/;
s/ master//;
say "\\hline $commit_count &$_ & " . join(' & ', @changes) . ' \\\\';
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();
say "\\hline $commit_count & $tags & $_ & " . join( ' & ', @changes ) . ' \\\\';
$commit_count++;
} else {
@changes = (0, 0, 0);
}
else {
@changes = ( 0, 0, 0 );
/(\d+) files? changed/ and $changes[0] = $1;
/(\d+) insertions?/ and $changes[1] = $1;
/(\d+) deletions?/ and $changes[2] = $1;
/(\d+) insertions?/ and $changes[1] = $1;
/(\d+) deletions?/ and $changes[2] = $1;
}
$which_line ^= 1; ## toggle bit
}
say '\end{longtable}';
# }}}

__END__
=head1 NAME
LaTeX-git-log - output the version history of git as LaTeX source code.
=head1 SYNOPSIS
LaTeX-git-log [options]
Options:
--help brief help message
--man full documentation
--man full documentation
--startcommit set the start value of count commit
--author set this if you want the author included
--width set the width in cm of the commit message field in the LaTeX table
--git-c-add set an base URL to show a commit. This script will automaticly try to the the base URL for github.
--user set a github user to derive the base URL
--repo set a github repository to derive the base URL
=head1 OPTIONS
=over 8
=item B<-help>
Print a brief help message and exits.
=item B<-man>
Prints the manual page and exits.
=back
=head1 DESCRIPTION
If you execute B<this program> within a git repository it will output the entiry version history as table written in LaTeX.
=cut
@@ -1,5 +1,5 @@
#!/bin/bash
## Konvertiert die Ausgabe von git diff --color-words in LaTeX Befehle
## Converts the output of git diff --color-words to LaTeX commands.
tmp="/tmp/git-wdiff.tmp"
convert2latex (){
sed 's/{/(((((/g' \
@@ -0,0 +1,46 @@
#!/bin/bash
SCRIPT="`readlink -e $0`"
SCRIPTPATH="`dirname $SCRIPT`"
if [ $# != 2 ];then
echo "Dieses Skript bitte in dem Ordner ausführen wo die Daten abgelegt werden sollen."
echo "Bitte übergeben Sie einen Verzeichnisnamen und einen Dateinamen für das PDF."
exit 1
fi
dirname="$1"
jobfile="$2"

mkdir -p "$dirname/images-raw" "$dirname/images"

echo "Bitte alle Bilder [pdf,png,jpg] in den Ordner \"$dirname/images\" verschieben."
echo "Wenn bei Bildern [png,jpg] vorher noch der Kontrast erhöht werden sollen dann in \"$dirname/images-raw\" verschieben..."
echo "Die Dateinamen der Bilder dürfen keine Leerzeichen und keine Kommata enthalten."
read fnord

(find "$dirname/images-raw/" -name "*.png"
find "$dirname/images-raw/" -name "*.jpg")|sort|while read i;do
filename="`basename "$i"`";filename="${filename%.*}"
if [ ! -s "`echo "$dirname/images/$filename-V2.png"|sed 's/ /_/g'`" ]
then echo -n "."
image-scan-tweak "$i"
mv "$dirname/images-raw/$filename-V2.png" "`echo "$dirname/images/$filename-V2.png"|sed 's/ /_/g'`"
else echo -n "+"
fi
done
echo
rmdir --ignore-fail-on-non-empty "$dirname/images-raw"

cd "$dirname"
Cdate="`LaTeX-echoCREATEDATE`"
(
grep -v "\end{document}" $SCRIPTPATH/../templates/scan2pdf.tex|sed -e s/\\SetCREATEDATE.*$/"$Cdate"/
(
find images/ -name "*.pdf"
find images/ -name "*.png"
find images/ -name "*.jpg"
)|sort|while read i;do
echo '\includepdf'"{$i}"
done
echo "\end{document}"
) > "$jobfile.tex"

echo "Jetzt muss nur noch mit einer LaTeX IDE der Wahl die Datei $jobfile.tex angepasst und übersetzt weden."
@@ -0,0 +1,2 @@
%% This file 'scan2pdf.ctr' was generated by the package counttexruns
8
@@ -1,23 +1,21 @@
%% <school/scan2pdf.tex> template 1.5 by Robin `ypid` Schneider <ypid23@aol.de>
%% The current version can be found on: https://github.com/ypid/typesetting/blob/master/templates/school/scan2pdf.tex
%% Um Bilder Ganzseitig in ein DIN A4 PDF zu konvertieren
%% <scan2pdf.tex> template 1.6 by Robin `ypid` Schneider <ypid23@aol.de>
%% The current version can be found on: https://github.com/ypid/typesetting/blob/master/templates/scan2pdf.tex
%% To convert images to PDF files. The script LaTeX-scan2pdf uses this template.
%%% preamble
%\listfiles %% listfiles to logfile
\documentclass[a4paper,ngerman]{scrartcl}
\usepackage{
scrartclRS,
defaultRS,
% debugRS,
datetime,
% graphicRS,
extensionsRS,
declareDocumentVariablesRS,
readgitRS,
schoolRS,
}
%% specific indications
\SetTITEL{\jobname}
\SetAUTHOR{4}{Heisenberg}
\SetCLASS{12}
\SetAUTHOR{1}{}
%\SetSUBJECT{}
%\SetURL{}
%\choosedefaultlicense
@@ -75,9 +75,7 @@ \section{Einführung}
%\ifDraft{
% \begin{landscape}
% \pagestyle{empty}
% \pdfbookmark[2]{Versionshinweise}{versionshinweise}
% \subsection*{Versionshinweise}
% \input{files/git/versions-log}
% \printVersionNotes
% \printgitstatlandscape{1}
% \end{landscape}
% \printgitstat{1}

This file was deleted.

0 comments on commit f304845

Please sign in to comment.