@@ -17,8 +17,9 @@ use strict;
17
17
# ************************************************************
18
18
19
19
# # This is the starting major and minor version
20
- my $version = ' 4.1 ' ;
20
+ my $version = ' 5.0 ' ;
21
21
my $once = 1;
22
+ my $cache = ' modules/.version' ;
22
23
23
24
# ************************************************************
24
25
# Subroutine Section
@@ -29,30 +30,62 @@ sub get {
29
30
# # We only need to do this once
30
31
$once = 0;
31
32
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);
42
48
}
43
49
}
44
- close (CLH);
50
+ else {
51
+ # # See if we can load in the previously stored version string.
52
+ $r = _readVersion($cache );
53
+ }
45
54
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 );
51
59
}
60
+
61
+ # # We then append the revision to the version string.
62
+ $version .= " .$rev " ;
52
63
}
53
64
54
65
return $version ;
55
66
}
56
67
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
+ }
57
74
58
75
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