aboutsummaryrefslogtreecommitdiff
path: root/ck.
blob: 7ab3b8ade5116e2614844ec4c59ea63eaf55ef86 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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