Browse Source

Update MKit to v0.0.40

Alois Mahdal 4 years ago
parent
commit
a1e7491aab
5 changed files with 55 additions and 12 deletions
  1. 1
    1
      mkit.ini
  2. 28
    7
      utils/mkit/include/build.sh
  3. 22
    1
      utils/mkit/include/facts.sh
  4. 3
    2
      utils/mkit/include/release.sh
  5. 1
    1
      utils/mkit/include/vars.sh

+ 1
- 1
mkit.ini View File

30
 [files]
30
 [files]
31
     bin = src/app dummy
31
     bin = src/app dummy
32
 
32
 
33
-#mkit version=0.0.37
33
+#mkit version=0.0.40

+ 28
- 7
utils/mkit/include/build.sh View File

80
     MacroMap[__MKIT_PROJ_MAINTAINER__]=$(ini 1value project:maintainer)
80
     MacroMap[__MKIT_PROJ_MAINTAINER__]=$(ini 1value project:maintainer)
81
     MacroMap[__MKIT_PROJ_VCS_BROWSER__]=$(ini 1value project:vcs_browser)
81
     MacroMap[__MKIT_PROJ_VCS_BROWSER__]=$(ini 1value project:vcs_browser)
82
     MacroMap[__MKIT_PROJ_GIT_LASTHASH__]=$(__cached git_lasthash)
82
     MacroMap[__MKIT_PROJ_GIT_LASTHASH__]=$(__cached git_lasthash)
83
+    MacroMap[__MKIT_PROJ_GIT_LASTSUMMARY__]=$(__cached git_lastsummary)
83
     MacroMap[__MKIT_PROJ_VERSION__]=$(__cached semver)
84
     MacroMap[__MKIT_PROJ_VERSION__]=$(__cached semver)
84
     for section in "$@"; do
85
     for section in "$@"; do
85
         for mname in $(ini lskeys "$section"); do
86
         for mname in $(ini lskeys "$section"); do
161
     #
162
     #
162
     local file=$1
163
     local file=$1
163
     mkdir -p "$MKIT_LOCAL"
164
     mkdir -p "$MKIT_LOCAL"
164
-    echo "$file" >> "$MKIT_LOCAL/built.lst"
165
+    echo "1:$file" >> "$MKIT_LOCAL/built.lst"
165
 }
166
 }
166
 
167
 
167
 _mkit_data() {
168
 _mkit_data() {
185
         echo "  x_MKIT_PROJ_MAINTAINER__ => '__MKIT_PROJ_MAINTAINER__'"
186
         echo "  x_MKIT_PROJ_MAINTAINER__ => '__MKIT_PROJ_MAINTAINER__'"
186
         echo "  x_MKIT_PROJ_VCS_BROWSER__ => '__MKIT_PROJ_VCS_BROWSER__'"
187
         echo "  x_MKIT_PROJ_VCS_BROWSER__ => '__MKIT_PROJ_VCS_BROWSER__'"
187
         echo "  x_MKIT_PROJ_GIT_LASTHASH__ => '__MKIT_PROJ_GIT_LASTHASH__'"
188
         echo "  x_MKIT_PROJ_GIT_LASTHASH__ => '__MKIT_PROJ_GIT_LASTHASH__'"
189
+        echo "  x_MKIT_PROJ_GIT_LASTSUMMARY__ => '__MKIT_PROJ_GIT_LASTSUMMARY__'"
188
         echo "  x_MKIT_PROJ_VERSION__ => '__MKIT_PROJ_VERSION__'"
190
         echo "  x_MKIT_PROJ_VERSION__ => '__MKIT_PROJ_VERSION__'"
189
         for section in "${sections[@]}"; do
191
         for section in "${sections[@]}"; do
190
             echo "$section:"
192
             echo "$section:"
212
     #
214
     #
213
     # Clean up tree after building
215
     # Clean up tree after building
214
     #
216
     #
215
-    test -f "$MKIT_LOCAL/built.lst" && {
216
-        <"$MKIT_LOCAL/built.lst" grep -v -e '\.\.' -e ^/ \
217
-          | xargs -r rm -rf
218
-        rm -f "$MKIT_LOCAL/built.lst"
219
-        rmdir --ignore-fail-on-non-empty "$MKIT_LOCAL"
220
-    }
217
+    local path
218
+    local line
219
+    local depth
220
+    test -f "$MKIT_LOCAL/built.lst" || return 0
221
+    {
222
+        cat "$MKIT_LOCAL/built.lst"
223
+        echo "1:$MKIT_LOCAL/built.lst"
224
+        echo "1:$MKIT_LOCAL"
225
+    } \
226
+      | grep -v -e '\.\.' -e ^/ -e '^~' \
227
+      | while IFS=: read -r depth path; do
228
+            test -e "$path" || continue
229
+            case $depth in
230
+                1)  warn "removing: $path"
231
+                    test -d "$path" \
232
+                     && rmdir -p --ignore-fail-on-non-empty "$path"
233
+                    test -f "$path" && rm "$path"
234
+                    ;;
235
+                r)  warn "removing recursively: $path"
236
+                    rm -r "$path"
237
+                    ;;
238
+                *)  warn "invalid built.lst format!"
239
+                    ;;
240
+            esac
241
+        done
221
     true
242
     true
222
 }
243
 }
223
 
244
 

+ 22
- 1
utils/mkit/include/facts.sh View File

103
     git_bool dirty && echo -n ".dirty"
103
     git_bool dirty && echo -n ".dirty"
104
 }
104
 }
105
 
105
 
106
+git_lastsummary() {
107
+    #
108
+    # Show last commit summary
109
+    #
110
+    # We can't do it outside git repo (or without git) but we should
111
+    # not be asked to; targets that don't require git should make use
112
+    # of cache built by dist target.
113
+    #
114
+    git_present || {
115
+        echo UNKNOWN_SUMMARY
116
+        warn "no git present; could not determine last summary"
117
+        return 3
118
+    }
119
+    git_bool dirty && {
120
+        echo "(index is dirty)"
121
+        return
122
+    }
123
+    git log -1 --format=oneline HEAD \
124
+      | cut -d' ' -f2-
125
+}
126
+
106
 semver() {
127
 semver() {
107
     #
128
     #
108
     # Build proper SemVer version string
129
     # Build proper SemVer version string
171
     if ! git describe --tags --exact-match HEAD >&/dev/null;
192
     if ! git describe --tags --exact-match HEAD >&/dev/null;
172
     then    # we are at a later commit than the last tag
193
     then    # we are at a later commit than the last tag
173
         is_tagged=F
194
         is_tagged=F
174
-        brname=$(git_fact current_branch)
195
+        brname=$(git_fact current_branch | sed 's/[^[:alnum:]]/_/g')
175
         ghash=$(git_fact latest_sha)
196
         ghash=$(git_fact latest_sha)
176
     fi
197
     fi
177
     git_bool dirty && is_dirty=T
198
     git_bool dirty && is_dirty=T

+ 3
- 2
utils/mkit/include/release.sh View File

154
     git add mkit.ini \
154
     git add mkit.ini \
155
       || die "failed to add mkit.ini to the index"
155
       || die "failed to add mkit.ini to the index"
156
     cache=$(mktemp -t "mkit._vbump_gitmsg.XXXXXXXX")
156
     cache=$(mktemp -t "mkit._vbump_gitmsg.XXXXXXXX")
157
-    _vbump_gitmsg > "$cache"
157
+    _vbump_gitmsg "$nextver" > "$cache"
158
     git commit -e -F "$cache"   # note: reading from stdin will break vim
158
     git commit -e -F "$cache"   # note: reading from stdin will break vim
159
     rm "$cache"
159
     rm "$cache"
160
 }
160
 }
163
     #
163
     #
164
     # Compose git message template for 'Bump version' commit
164
     # Compose git message template for 'Bump version' commit
165
     #
165
     #
166
-    echo "Bump version"
166
+    local nextver=$1
167
+    echo "Bump version to $nextver"
167
     echo ""
168
     echo ""
168
     echo "Overview of changes:"
169
     echo "Overview of changes:"
169
     echo ""
170
     echo ""

+ 1
- 1
utils/mkit/include/vars.sh View File

86
 #
86
 #
87
 # This MKit version
87
 # This MKit version
88
 #
88
 #
89
-MKIT_VERSION=0.0.37
89
+MKIT_VERSION=0.0.40