Skip to content

Commit 1b596ec

Browse files
committed
Update version to contain git version info, when available.
1 parent 60b0c90 commit 1b596ec

File tree

5 files changed

+57
-25
lines changed

5 files changed

+57
-25
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
modules/.version

PROBLEM-REPORT-FORM

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@ Documentation for MPC can be found at the following location.
44

55
Please consult the documentation to ensure that you are using MPC correctly.
66

7-
If you are still having a problem getting MPC to do what you want, please
8-
consult the FAQ before sending a support request.
9-
10-
http://www.ociweb.com/products/mpc/mpc-faq
11-
127
When requesting MPC support please provide the following items:
138

149
MPC version (using mwc.pl -version):
@@ -25,6 +20,7 @@ When requesting MPC support please provide the following items:
2520

2621
Problem description (please be as detailed as possible):
2722

28-
Finally, send support requests to [email protected]. You may send
29-
questions to the author ([email protected]), but a response is not
30-
guaranteed.
23+
Please go to
24+
https://objectcomputing.com/products/opendds/opendds-consulting-and-support
25+
for commercial support. Go to https://github.com/DOCGroup/MPC/issues for
26+
community support.
File renamed without changes.

modules/Driver.pm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ sub new {
4848
my @creators = @_;
4949
my $self = $class->SUPER::new();
5050

51+
Version::cache();
52+
5153
$self->{'path'} = $path;
5254
$self->{'basepath'} = ::getBasePath();
5355
$self->{'name'} = $name;

modules/Version.pm

Lines changed: 50 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ use strict;
1717
# ************************************************************
1818

1919
## This is the starting major and minor version
20-
my $version = '4.1';
20+
my $version = '5.0';
2121
my $once = 1;
22+
my $cache = 'modules/.version';
2223

2324
# ************************************************************
2425
# Subroutine Section
@@ -29,30 +30,62 @@ sub get {
2930
## We only need to do this once
3031
$once = 0;
3132

32-
## Here we determine the beta version. The base variable
33-
## is the negated number of existing ChangeLog entries at the
34-
## time of the release of the major and minor version. We then
35-
## add the total number of ChangeLog entries to the base to
36-
## get the beta version.
37-
my $base = -1;
38-
if (open(CLH, ::getBasePath() . '/ChangeLog')) {
39-
while(<CLH>) {
40-
if (/^\w\w\w\s\w\w\w\s/) {
41-
++$base;
33+
## Attempt to dynamically determine the revision part of the version
34+
## string every time the version number is requested. This only happens
35+
## if the --version option is used, an invalid option is used, and when
36+
## the process starts up and the version hasn't been cached yet.
37+
my $rev = '?';
38+
my $cwd = Cwd::getcwd();
39+
if (chdir(::getBasePath())) {
40+
## Get the git revision for the final part of the version string.
41+
my $r = _readVersion('git rev-parse --short HEAD |');
42+
if (defined $r) {
43+
## Store the version for later use, in the event that the git
44+
## revision isn't available in the future.
45+
if (open(CLH, ">$cache")) {
46+
print CLH "$r\n";
47+
close(CLH);
4248
}
4349
}
44-
close(CLH);
50+
else {
51+
## See if we can load in the previously stored version string.
52+
$r = _readVersion($cache);
53+
}
4554

46-
## We then append the beta version number to the version string
47-
$version .= ".$base";
48-
}
49-
else {
50-
$version .= '.??';
55+
## Set the revision string if we were able to read one.
56+
$rev = $r if (defined $r);
57+
58+
chdir($cwd);
5159
}
60+
61+
## We then append the revision to the version string.
62+
$version .= ".$rev";
5263
}
5364

5465
return $version;
5566
}
5667

68+
sub cache {
69+
## Attempt to cache the revision if the cache file does not exist.
70+
## This will allow the revision to be obtained in the event that git
71+
## cannot return the revision information at a later time.
72+
get() if (!-e ::getBasePath() . '/' . $cache);
73+
}
5774

5875
1;
76+
77+
sub _readVersion {
78+
my $file = shift;
79+
my $rev;
80+
if (open(CLH, $file)) {
81+
while(<CLH>) {
82+
if (/^(\w+)$/) {
83+
$rev = $1;
84+
last;
85+
}
86+
}
87+
close(CLH);
88+
}
89+
return $rev;
90+
}
91+

0 commit comments

Comments
 (0)