Parcourir la source

Update mk.sh from fastfoo

Alois Mahdal il y a 10 ans
Parent
révision
6870d055c8
1 fichiers modifiés avec 40 ajouts et 0 suppressions
  1. 40
    0
      setup/mk.sh

+ 40
- 0
setup/mk.sh Voir le fichier

@@ -147,6 +147,46 @@ install() {
147 147
 }
148 148
 
149 149
 get_version() {
150
+    #
151
+    # Build semver version string with build metadata
152
+    #
153
+    # Build version string from available info using following
154
+    # logic:
155
+    #
156
+    #  1. use VERSION (from config.mk)
157
+    #  2. if we are in git, override the version with last tag
158
+    #  3. if set, add STAGE (from config.mk) as pre-release ID
159
+    #     (afer dash)
160
+    #  4. if we are at a later commit than the last tag, add commit
161
+    #     sha1 to build metadata (after plus sign)
162
+    #  5. if the tree is "dirty", i.e. has uncommited changes,
163
+    #     add "dirty" to build metadata
164
+    #
165
+    # The version is compatible with SemVer 2.0.0.
166
+    #
167
+    # Examples:
168
+    #
169
+    #     myprog v1.0.7                         # all clear
170
+    #     myprog v1.0.7-alpha                   # STAGE="alpha"
171
+    #     myprog v1.0.7-alpha+g1aef811          # ^^ + some commits after
172
+    #     myprog v1.0.7-alpha+g1aef811.dirty    # ^^ + tree edited
173
+    #     myprog v1.0.7-alpha+dirty             # tag OK but tree edited
174
+    #     myprog v1.0.7+dirty                   # ^^ but no stage
175
+    #
176
+    # Note that versions with "dirty" should be perceived as kind of
177
+    # dangerous outside developer's own machine.  Versions with sha1 are
178
+    # safer but must not be released.
179
+    #
180
+    # I have considered decorating the git commit refs to make them
181
+    # sort of sortable (e.g. "r1.g1aef811"), but on second thought,
182
+    # I don't think it's good idea to give *any* semantics to meta-data
183
+    # at all.  First, there is no rule that r1<r2<r3; a commit can be
184
+    # removing what other just added and one change can be split to
185
+    # multiple commits.  Also, the whole thing breaks anyway once you
186
+    # rebase your branch (no, it's not a sin).  The sole purpose of
187
+    # meta-data is to *identify* the code, and provide safe path back
188
+    # to tree; commit refs are already perfect for that.
189
+    #
150 190
     local version=$VERSION
151 191
     local stage=$STAGE
152 192
     if git rev-parse HEAD >&/dev/null;