Revision d1489df2
Von Moritz Bunkus vor etwa 12 Jahren hinzugefügt
SL/Git.pm | ||
---|---|---|
package SL::Git;
|
||
|
||
use strict;
|
||
use warnings;
|
||
|
||
use parent qw(Rose::Object);
|
||
|
||
use Carp;
|
||
use List::Util qw(first);
|
||
|
||
sub is_git_installation {
|
||
my ($self) = @_;
|
||
|
||
return $self->git_exe && -d ".git" && -f ".git/config" ? 1 : 0;
|
||
}
|
||
|
||
sub git_exe {
|
||
my ($self) = @_;
|
||
|
||
return $self->{git_exe} if $self->{_git_exe_search};
|
||
|
||
$self->{_git_exe_search} = 1;
|
||
$self->{git_exe} = first { -x } map { "${_}/git" } split m/:/, $ENV{PATH};
|
||
|
||
return $self->{git_exe};
|
||
}
|
||
|
||
sub get_log {
|
||
my ($self, %params) = @_;
|
||
|
||
croak "No git executable found" if !$self->git_exe;
|
||
|
||
my $since_until = join '..', $params{since}, $params{until};
|
||
my $in = IO::File->new($self->git_exe . qq! log --format='tformat:\%H|\%an|\%ae|\%ai|\%s' ${since_until} |!);
|
||
|
||
if (!$in) {
|
||
$::lxdebug->message(LXDebug::WARN(), "Error spawning git: $!");
|
||
return ();
|
||
}
|
||
|
||
my @log = grep { $_ } map { $self->_parse_log_line($_) } <$in>;
|
||
$in->close;
|
||
|
||
return @log;
|
||
}
|
||
|
||
sub _parse_log_line {
|
||
my ($self, $line) = @_;
|
||
|
||
chomp $line;
|
||
|
||
my @fields = split m/\|/, $line, 5;
|
||
return undef unless scalar(@fields) == 5;
|
||
|
||
my %commit = (
|
||
hash => $fields[0],
|
||
author_name => $fields[1],
|
||
author_email => $fields[2],
|
||
subject => $fields[4],
|
||
);
|
||
|
||
if ($fields[3] =~ m/^(\d+)-(\d+)-(\d+)\s+(\d+):(\d+):(\d+)\s+?([\+\-]?\d+)?$/) {
|
||
$commit{author_date} = DateTime->new(year => $1, month => $2, day => $3, hour => $4, minute => $5, second => $6, time_zone => $7);
|
||
}
|
||
|
||
return \%commit;
|
||
}
|
||
|
||
1;
|
bin/mozilla/login.pl | ||
---|---|---|
use SL::Auth;
|
||
use SL::User;
|
||
use SL::Form;
|
||
use SL::Git;
|
||
|
||
require "bin/mozilla/common.pl";
|
||
require "bin/mozilla/todo.pl";
|
||
... | ... | |
$form->{title} = $::locale->text('kivitendo');
|
||
$form->{interface} = $::dispatcher->interface_type;
|
||
|
||
my $git = SL::Git->new;
|
||
($form->{git_head}) = $git->get_log(since => 'HEAD~1', until => 'HEAD') if $git->is_git_installation;
|
||
|
||
# create the logo screen
|
||
$form->header() unless $form->{noheader};
|
||
|
locale/de/all | ||
---|---|---|
'General ledger and cash' => 'Finanzbuchhaltung und Zahlungsverkehr',
|
||
'General ledger corrections' => 'Korrekturen im Hauptbuch',
|
||
'Generic Tax Report' => 'USTVA Bericht',
|
||
'Git revision: #1, #2 #3' => 'Git-Revision: #1, #2 #3',
|
||
'Given Name' => 'Vorname',
|
||
'Go one step back' => 'Einen Schritt zurück',
|
||
'Go one step forward' => 'Einen Schritt vorwärts',
|
templates/webpages/login/company_logo.html | ||
---|---|---|
|
||
<h3 class="login">[% 'kivitendo' | $T8 %] [% version %]</h3>
|
||
|
||
[%- IF git_head %]
|
||
<p>[%- LxERP.t8("Git revision: #1, #2 #3", git_head.hash.substr(0, 7), git_head.author_date.to_kivitendo, git_head.author_date.strftime('%H:%M:%S %Z')) %]</p>
|
||
[%- END %]
|
||
|
||
<p>[% 'companylogo_subtitle' | $T8 %]</p>
|
||
<p>
|
||
<b>
|
||
... | ... | |
</center>
|
||
|
||
[%- todo_list %]
|
||
|
Auch abrufbar als: Unified diff
Loginbildschirm: Unter Versionsnummer auch aktuelle Git-Revisionsnummer anzeigen
Conflicts:
locale/de/all