]>
Commit | Line | Data |
---|---|---|
0e6a94b3 HH |
1 | #!/usr/bin/perl |
2 | ||
3 | sub last_tag { | |
4 | open( GIT, 'git log --pretty=format:%H |'); | |
5 | LINE: while( <GIT> ) { | |
6 | open( GIT2, "git tag --contains $_ |"); | |
7 | while( <GIT2> ) { | |
8 | chomp; | |
9 | last LINE if /..*/; | |
10 | } | |
11 | close GIT2; | |
12 | } | |
13 | $tag=$_; | |
14 | close GIT2; | |
15 | close GIT; # be done | |
16 | return $tag; | |
17 | }; | |
18 | ||
19 | sub create_patches { | |
20 | my $tag=shift; | |
21 | my $num=0; | |
85cda6ae | 22 | open( GIT, 'git format-patch -N --no-signature '.$tag.' |'); |
0e6a94b3 HH |
23 | @lines=<GIT>; |
24 | close GIT; # be done | |
25 | return @lines; | |
26 | }; | |
f2953927 | 27 | |
0e6a94b3 HH |
28 | use POSIX qw(strftime); |
29 | my $datestr = strftime "%Y%m%d", gmtime; | |
30 | ||
31 | my $tag=shift; | |
32 | $tag=&last_tag if not defined $tag; | |
33 | my @patches=&create_patches($tag); | |
34 | my $num=$#patches + 2; | |
35 | $tag=~s/[^0-9]+?([0-9]+)/$1/; | |
36 | my $release="$num.git$datestr"; | |
37 | $release="1" if $num == 1; | |
38 | ||
39 | while(<>) { | |
40 | if (/^Version:/) { | |
41 | print "Version: $tag\n"; | |
42 | } | |
43 | elsif (/^Release:/) { | |
f2953927 | 44 | print "Release: $release%{?dist}\n"; |
0e6a94b3 HH |
45 | } |
46 | elsif ((/^Source0:/) || (/^Source:/)) { | |
47 | print $_; | |
48 | $num=1; | |
49 | for(@patches) { | |
50 | print "Patch$num: $_"; | |
51 | $num++; | |
52 | } | |
53 | print "\n"; | |
54 | } | |
0e6a94b3 HH |
55 | else { |
56 | print $_; | |
57 | } | |
58 | } |