Browse Source

Add 'ctime' -- commit-based, and make it default

Alois Mahdal 6 years ago
parent
commit
70ee06717a
2 changed files with 14 additions and 7 deletions
  1. 4
    0
      src/include/facts.sh
  2. 10
    7
      src/include/vars.sh.skel

+ 4
- 0
src/include/facts.sh View File

54
         latest_sha)
54
         latest_sha)
55
             git log -1 --pretty=format:%h HEAD
55
             git log -1 --pretty=format:%h HEAD
56
             ;;
56
             ;;
57
+        latest_cdate)
58
+            git log -1 --format=%cd --date=unix HEAD
59
+            ;;
57
         *)
60
         *)
58
             warn "unknown git fact asked: $fact_name"
61
             warn "unknown git fact asked: $fact_name"
59
             ;;
62
             ;;
146
     case $MKIT_TTAG in
149
     case $MKIT_TTAG in
147
         none)   btime= ;;
150
         none)   btime= ;;
148
         btime)  btime=$(date -u +%Y%m%d%H%M%S) ;;
151
         btime)  btime=$(date -u +%Y%m%d%H%M%S) ;;
152
+        ctime)  btime=$(date -d @"$(git_fact latest_cdate)" -u +%Y%m%d%H%M%S) ;;
149
     esac
153
     esac
150
     grep ":" <<<"$prerl" \
154
     grep ":" <<<"$prerl" \
151
      && warn "colon in project:prerl may corrupt version data: $prerl"
155
      && warn "colon in project:prerl may corrupt version data: $prerl"

+ 10
- 7
src/include/vars.sh.skel View File

58
 #
58
 #
59
 # Add time-based ordinal tag to SemVer build data?
59
 # Add time-based ordinal tag to SemVer build data?
60
 #
60
 #
61
-# Can be 'none' or 'btime'.
61
+# Can be 'none', 'ctime' or 'btime'.
62
 #
62
 #
63
-# If 'btime', devel builds have also timestamp-based tag in format of
63
+# If 'ctime', devel builds have also timestamp-based tag in format of
64
 # `t%Y%m%d%H%M%S`, that is, a small character 't' followed by timestamp
64
 # `t%Y%m%d%H%M%S`, that is, a small character 't' followed by timestamp
65
 # without non-digit characters.  The timestamps are in UTC, ie. timezones
65
 # without non-digit characters.  The timestamps are in UTC, ie. timezones
66
-# need not apply.
66
+# need not apply.  'btime' has the same format, except that it's derived
67
+# from build time, while 'ctime' is from last commit's commit date.
67
 #
68
 #
68
 # This helps with deploying development builds where packaging system
69
 # This helps with deploying development builds where packaging system
69
 # is not SemVer-compliant and makes it hard to install arbitrary version.
70
 # is not SemVer-compliant and makes it hard to install arbitrary version.
74
 # considered same) this tag will make it more likely to "win" the build
75
 # considered same) this tag will make it more likely to "win" the build
75
 # you made later.
76
 # you made later.
76
 #
77
 #
77
-# Note that this makes devel and dirty builds non-deterministic,
78
-# but does not affect clean builds (ie. builds from clean repo
79
-# with HEAD corresponding to latest version tag.).
78
+# Note that this does not affect clean builds (ie. builds from clean
79
+# repo with HEAD corresponding to latest version tag.).
80
 #
80
 #
81
-MKIT_TTAG=${MKIT_TTAG:-btime}
81
+# Also note that 'btime' makes the version non-deterministic: merely
82
+# initiating the build a second later will result in different version.
83
+#
84
+MKIT_TTAG=${MKIT_TTAG:-ctime}
82
 
85
 
83
 #
86
 #
84
 # This MKit version
87
 # This MKit version