-
Notifications
You must be signed in to change notification settings - Fork 0
/
checkin.pl
executable file
·77 lines (67 loc) · 1.73 KB
/
checkin.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
70
71
72
73
74
75
76
77
#!/usr/bin/perl
use strict;
use warnings;
use Getopt::Long;
my $major = 0;
my $minor = 0;
GetOptions(
'M|major' => \$major,
'm|minor' => \$minor
) == 1 or die "Error in options.\n";
my $gitstatus = `git status`;
if(not($gitstatus =~ /modified:\s+/ or $gitstatus =~ /added:\s+/ or $gitstatus =~ /deleted:\s+/)) {
print "No changes observed!\n";
exit;
}
my ($main,$sub,$rel) = GetVersion();
if($major == 1) {
$main = $main + 1;
$sub = 0;
$rel = 0;
} elsif($minor == 1) {
$sub = $sub + 1;
$rel = 0;
} else {
$rel = $rel + 1;
}
# Make version change in VERSION file
open VER,"+>VERSION" or die "Could not write to VERSION\n";
print VER "$main.$sub-$rel\n";
close(VER);
# Make version change in trsh.pl
open TRSH,"trsh.pl" or die "Could not find trsh.pl";
my @trsh = <TRSH>;
close(TRSH);
system("mv trsh.pl trsh.pl.orig");
open TRSH, "+>trsh.pl" or die "Could not create trsh.pl\n";
foreach my $entry (@trsh){
$entry =~ s/\$VERSION = \"\d+\.\d+\-\d+\"/\$VERSION = \"$main\.$sub-$rel\"/;
print TRSH $entry;
}
system("rm -f trsh.pl.orig");
# Make version change in README
open README,"README" or die "Could not find README";
my @readme = <README>;
close(README);
system("mv README README.orig");
open README, "+>README" or die "Could not create README\n";
foreach my $entry (@readme){
$entry =~ s/Version \d+\.\d+-\d+/Version $main\.$sub-$rel/;
print README $entry;
}
close(README);
system("rm -f README.orig");
print "REVISION($main.$sub-$rel) Checking Message (Single line):\n";
my $message = <STDIN>;
chomp($message);
system("git commit -a -m \"$message\"");
system("git push origin master");
sub GetVersion
{
my $verstr = `cat VERSION`;
if($verstr =~ /(\d+)\.(\d+)-(\d+)/) {
return ($1,$2,$3);
}
print "ERROR In reading VERSION File.\n";
exit;
}