aboutsummaryrefslogtreecommitdiff
path: root/ck.
diff options
context:
space:
mode:
Diffstat (limited to 'ck.')
-rwxr-xr-xck.42
1 files changed, 42 insertions, 0 deletions
diff --git a/ck. b/ck.
new file mode 100755
index 0000000..7ab3b8a
--- /dev/null
+++ b/ck.
@@ -0,0 +1,42 @@
+#!/bin/sh
+
+colorize_ver() {
+ color="${1:-3}"
+ perl -pe 's,(\d[\d.]+),\x1b[1;3'$color'm$1\x1b[0m,x'
+}
+
+sort_color() {
+ sort -V | colorize_ver
+}
+
+last_gh_commit() {
+ # only show latest commit
+ head -1 | sed 's,.*::Commit/\([^<]*\)</id>,\1,'
+}
+
+last_gh_tag() {
+ # only show latest commit
+ head -1 | sed 's,.*/v*\([^/]*\)</id.*,\1,'
+}
+
+DIR=~/.ck4up
+build="$( basename $( pwd ) )"
+conf="$( grep -l "^$build " $DIR/*.conf )"
+
+case "$conf" in
+ "") echo "can't find $build in $DIR/*.conf" 2>&1 ; exit 0 ;;
+ *" "*) echo "$build is in multiple configs: $conf" 2>&1; exit 0;;
+ *) ;;
+esac
+
+if grep -q "^$build .*github.*commits.atom" $conf; then
+ postproc="last_gh_commit"
+elif grep -q "^$build .*github.*tags.atom" $conf ; then
+ postproc="last_gh_tag"
+else
+ postproc="sort_color"
+fi
+
+ck4up -dk -f "$conf" "^$build\\s" | $postproc
+source ./*.info
+echo "===> VERSION=$VERSION" | colorize_ver 2