forked from intel/tinycbor
-
Notifications
You must be signed in to change notification settings - Fork 1
/
maketag.pl
69 lines (60 loc) · 1.67 KB
/
maketag.pl
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
#!perl
use strict;
sub run(@) {
open PROC, "-|", @_ or die("Cannot run $_[0]: $!");
my @out;
while (<PROC>) {
chomp;
push @out, $_;
}
close PROC;
return @out;
}
my @tags = run("git", "tag");
my @v = run("git", "show", "HEAD:VERSION");
my $v = $v[0];
my $tagfile = ".git/TAG_EDITMSG";
open TAGFILE, ">", $tagfile
or die("Cannot create file for editing tag message: $!");
select TAGFILE;
print "TinyCBOR release $v\n";
print "\n";
print "# Write something nice about this release here\n";
# Do we have a commit template?
my @result = run("git", "config", "--get", "commit.template");
if (scalar @result) {
open TEMPLATE, "<", $result[0];
map { print $_; } <TEMPLATE>;
close TEMPLATE;
}
print "\n";
print "# Commit log\n";
open LOG, "-|", "git", "shortlog", "-e", "--no-merges", "--not", @tags;
map { print "# $_"; } <LOG>;
close LOG;
print "# Header diff:\n";
open DIFF, "-|", "git", "diff", "HEAD", "--not", @tags, "--", 'src/*.h', ':!*_p.h';
map { print "# $_"; } <DIFF>;
close DIFF;
select STDOUT;
close TAGFILE;
# Run the editor.
# We use system so that stdin, stdout and stderr are forwarded.
@result = run("git", "var", "GIT_EDITOR");
@result = ($result[0], $tagfile);
system @result;
exit ($? >> 8) if $?;
# Create the tag
# Also using system so that hte user can see the output.
system("git", "tag", "-a", "-F", $tagfile, split(' ', $ENV{GITTAGFLAGS}), "v$v");
exit ($? >> 8) if $?;
# Update the version file for the next patch release
@v = split(/\./, $v);
if (scalar @v < 3) {
push @v, '1';
} else {
++$v[-1];
}
$v = join('.', @v);
open VERSION, ">", "VERSION" or die("Cannot open VERSION file: $!");
print VERSION "$v\n";