forked from SHYFEM-model/shyfem
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgit-tags
executable file
·86 lines (66 loc) · 1.69 KB
/
git-tags
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/usr/bin/perl -s
#
#------------------------------------------------------------------------
#
# Copyright (C) 1985-2018 Georg Umgiesser
#
# This file is part of SHYFEM.
#
#------------------------------------------------------------------------
#
# shows all tags and commits available
#
# -tagsonly
#
#--------------------------------------------------------------
@tags = `git show-ref --tags`;
foreach $line (@tags) {
chomp $line;
my ($hash,$tag) = split(/\s+/,$line);
$tag =~ s|^refs/tags/||;
$tags{$hash} = $tag;
#print "$hash $tag\n";
}
#exit;
#$coms = `git log --pretty=oneline`;
$coms = `git log --format="%H %ct %s"`;
@coms = split(/\n+/,$coms);
@lines = ();
foreach $com (@coms) {
($hash,$udate,@mess) = split(/\s+/,$com);
$mess = join(" ",@mess);
$date = format_date($udate);
$shorthash = substr($hash,0,10);
#$shortmess = substr($mess,0,55);
$shortmess = substr($mess,0,44);
$tag = format_tag($tags{$hash});
if( $tagsonly ) {
$tag =~ s/^\s+$//;
push(@lines,$tag) if( $tag );
} else {
my $line = "$shorthash $date $tag $shortmess";
push(@lines,$line);
}
#print "$line\n";
}
foreach my $line (reverse @lines) {
print "$line\n";
}
#-------------------------------------------------------------
sub format_tag {
my ($tag,$size) = @_;
$tag = " " unless( $tag );
my $line = sprintf("%12s",$tag);
return $line;
}
sub format_date {
my $utime = shift;
my ($sec, $min, $hour, $day, $mon, $year, $wday, $yday, $isdst) =
localtime($udate);
$year += 1900;
$mon += 1;
$mon = "0$mon" if $mon < 10;
$day = "0$day" if $day < 10;
$date = "$year-$mon-$day";
}
#-------------------------------------------------------------