Skip to content

Commit 1488042

Browse files
authored
Merge pull request DOCGroup#170 from DOCGroup/elliottc/version
Removed the automated version number based on ChangeLog
2 parents 8ca0621 + c1e81f1 commit 1488042

File tree

5 files changed

+59
-25
lines changed

5 files changed

+59
-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: 52 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,16 @@ package Version;
1111
# ************************************************************
1212

1313
use strict;
14+
use File::Spec;
1415

1516
# ************************************************************
1617
# Data Section
1718
# ************************************************************
1819

1920
## This is the starting major and minor version
20-
my $version = '4.1';
21+
my $version = '5.0';
2122
my $once = 1;
23+
my $cache = 'modules/.version';
2224

2325
# ************************************************************
2426
# Subroutine Section
@@ -29,30 +31,63 @@ sub get {
2931
## We only need to do this once
3032
$once = 0;
3133

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;
34+
## Attempt to dynamically determine the revision part of the version
35+
## string every time the version number is requested. This only happens
36+
## if the --version option is used, an invalid option is used, and when
37+
## the process starts up and the version hasn't been cached yet.
38+
my $rev = '?';
39+
my $cwd = Cwd::getcwd();
40+
if (chdir(::getBasePath())) {
41+
## Get the git revision for the final part of the version string.
42+
my $nul = File::Spec->devnull();
43+
my $r = _readVersion("git rev-parse --short HEAD 2> $nul |");
44+
if (defined $r) {
45+
## Store the version for later use, in the event that the git
46+
## revision isn't available in the future.
47+
if (open(CLH, ">$cache")) {
48+
print CLH "$r\n";
49+
close(CLH);
4250
}
4351
}
44-
close(CLH);
52+
else {
53+
## See if we can load in the previously stored version string.
54+
$r = _readVersion($cache);
55+
}
4556

46-
## We then append the beta version number to the version string
47-
$version .= ".$base";
48-
}
49-
else {
50-
$version .= '.??';
57+
## Set the revision string if we were able to read one.
58+
$rev = $r if (defined $r);
59+
60+
chdir($cwd);
5161
}
62+
63+
## We then append the revision to the version string.
64+
$version .= ".$rev";
5265
}
5366

5467
return $version;
5568
}
5669

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

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

0 commit comments

Comments
 (0)