-
Notifications
You must be signed in to change notification settings - Fork 0
/
get-version.pl
executable file
·35 lines (30 loc) · 1.68 KB
/
get-version.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
#!/usr/bin/env perl
###############################################################################
# This script finds the SemVer that would be most applicable to this code, #
# were it to be distributed in this state. #
# #
# Input: None #
# Output: A single line of text of the format: #
# {commit ID}[-modified] #
# #
# Note: #
# The presence of Git tags will change the behavior of this script. While #
# this makes it arguably stateful, the benefit is that there need be no #
# hard-coded version number anywhere in the code-base. This opens the doorway #
# for promotion of a particular commit from a release-candidate to a formally #
# accepted release. However, there are reasons to embed a hard-coded version #
# into a build. Largely, this is because we do not want to ship the entire #
# Git repository as part of this application. #
###############################################################################
use strict;
use warnings FATAL => 'all';
my $version = `perl ./ancestors.pl | perl ./max-version.pl`;
$version =~ s/\s+$//;
my $revision = `perl ./get-revision.pl`;
$revision =~ s/\s+$//;
my $current = `git rev-parse ${version}`;
$current =~ s/\s+$//;
if($current ne $revision){
$version = $version . "-modified";
}
print($version);