|
@@ -85,22 +85,19 @@ git_lasthash() {
|
85
|
85
|
|
86
|
86
|
|
87
|
87
|
|
88
|
|
-
|
89
|
|
-
|
90
|
|
-
|
91
|
|
-
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
|
92
|
91
|
|
93
|
92
|
local last_hash
|
94
|
|
- if git_present; then
|
95
|
|
- last_hash=$(git rev-parse HEAD)
|
96
|
|
- echo -n "$last_hash"
|
97
|
|
- git_bool dirty && echo -n ".dirty"
|
98
|
|
- else
|
99
|
|
- grep . .mkit/git_lasthash || {
|
100
|
|
- echo UNKNOWN
|
101
|
|
- warn "malformed source, could not determine git hash"
|
102
|
|
- }
|
103
|
|
- fi
|
|
93
|
+ git_present || {
|
|
94
|
+ echo UNKNOWN_HASH
|
|
95
|
+ warn "no git present; could not determine last hash"
|
|
96
|
+ return 3
|
|
97
|
+ }
|
|
98
|
+ last_hash=$(git rev-parse HEAD)
|
|
99
|
+ echo -n "$last_hash"
|
|
100
|
+ git_bool dirty && echo -n ".dirty"
|
104
|
101
|
}
|
105
|
102
|
|
106
|
103
|
semver() {
|
|
@@ -110,13 +107,13 @@ semver() {
|
110
|
107
|
|
111
|
108
|
|
112
|
109
|
|
113
|
|
-
|
114
|
|
-
|
115
|
|
-
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
116
|
113
|
|
117
|
|
-
|
|
114
|
+
|
118
|
115
|
|
119
|
|
-
|
|
116
|
+
|
120
|
117
|
|
121
|
118
|
|
122
|
119
|
|
|
@@ -148,37 +145,41 @@ semver() {
|
148
|
145
|
|
149
|
146
|
|
150
|
147
|
|
151
|
|
- local version
|
|
148
|
+ local xyz
|
152
|
149
|
local prerl
|
153
|
150
|
local latest_tag
|
154
|
151
|
local commit
|
155
|
152
|
local dirty
|
156
|
153
|
local suffix
|
157
|
|
- local_get semver && return 0
|
158
|
|
- version=$(ini 1value project:version)
|
159
|
154
|
prerl=$(ini 1value project:prerl)
|
160
|
155
|
grep ":" <<<"$prerl" \
|
161
|
156
|
&& warn "colon in project:prerl may corrupt version data: $prerl"
|
162
|
|
- if git_present;
|
163
|
|
- then
|
164
|
|
- latest_tag=$(git_fact latest_tag)
|
165
|
|
- if ! git describe --tags --exact-match HEAD >&/dev/null;
|
166
|
|
- then
|
167
|
|
- commit="$(git_fact current_branch).g$(git_fact latest_sha)"
|
168
|
|
- fi
|
169
|
|
- git_bool dirty; dirty=$?
|
170
|
|
- test -n "$latest_tag" && version=${latest_tag:1}
|
171
|
|
- case "$dirty:$commit" in
|
172
|
|
- 1:) suffix="" ;;
|
173
|
|
- 0:) suffix="+dirty" ;;
|
174
|
|
- 1:*) suffix="+$commit" ;;
|
175
|
|
- 0:*) suffix="+$commit.dirty" ;;
|
176
|
|
- *) suffix=MKIT_BUG
|
177
|
|
- warn "MKIT_BUG: bad dirt/commit detection" ;;
|
178
|
|
- esac
|
179
|
|
- test -n "$prerl" && suffix="-$prerl$suffix"
|
180
|
|
- version="$version$suffix"
|
|
157
|
+ git_present || {
|
|
158
|
+ echo UNKNOWN_VERSION
|
|
159
|
+ warn "no git present; could not determine SemVer"
|
|
160
|
+ return 3
|
|
161
|
+ }
|
|
162
|
+ latest_tag=$(git_fact latest_tag)
|
|
163
|
+ case $latest_tag in
|
|
164
|
+ v*) xyz=${latest_tag:1} ;;
|
|
165
|
+ "") warn "no tags, using base version from mkit.ini (ok for new project)"
|
|
166
|
+ xyz=$(ini 1value project:version) ;;
|
|
167
|
+ *) warn "bad form of last tag, using base version from mkit.ini: tag is '$latest_tag'"
|
|
168
|
+ xyz=$(ini 1value project:version) ;;
|
|
169
|
+ esac
|
|
170
|
+ if ! git describe --tags --exact-match HEAD >&/dev/null;
|
|
171
|
+ then
|
|
172
|
+ commit="$(git_fact current_branch).g$(git_fact latest_sha)"
|
181
|
173
|
fi
|
182
|
|
- local_putb semver <<<"$version"
|
183
|
|
- echo "$version"
|
|
174
|
+ git_bool dirty; dirty=$?
|
|
175
|
+ case "$dirty:$commit" in
|
|
176
|
+ 1:) suffix="" ;;
|
|
177
|
+ 0:) suffix="+dirty" ;;
|
|
178
|
+ 1:*) suffix="+$commit" ;;
|
|
179
|
+ 0:*) suffix="+$commit.dirty" ;;
|
|
180
|
+ *) suffix=MKIT_BUG
|
|
181
|
+ warn "MKIT_BUG: bad dirt/commit detection" ;;
|
|
182
|
+ esac
|
|
183
|
+ test -n "$prerl" && suffix="-$prerl$suffix"
|
|
184
|
+ echo "$xyz$suffix"
|
184
|
185
|
}
|