forked from getsolus/linux-steam-integration
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rpkg.macros
49 lines (38 loc) · 1.36 KB
/
rpkg.macros
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
43
44
45
46
47
48
49
#!/bin/bash
function cached {
declare v=${OUTPUT[$1]}
[[ -n $v ]] && echo -n "$v"
}
function dev_version {
cached dev_version && return
git -C $GIT_ROOT fetch origin master # ensure we could find ref
declare master_describe master_tag master_commits master_hash
master_describe=$(git -C $GIT_ROOT describe --first-parent origin/master)
read master_tag master_commits master_hash <<<"${master_describe//-/ }"
[[ $master_tag == v* && $master_commits -gt 0 && -n $master_hash ]] || die "failed git describe"
output "${master_tag}-dev+${master_commits}-${master_hash}"
}
function git_version {
cached git_version && return
declare v
v=$(dev_version) # v0.5.0-dev+1080-g971e0ca90
v=${v#v} # 0.5.0-dev+1080-g971e0ca90
v=${v/-/\~} # 0.5.0~dev+1080-g971e0ca90
v=${v//[+-]/.} # 0.5.0~dev.1080.g971e0ca90
output "$v"
}
function git_revision {
cached git_revision && return
# count commits not on master
output "$(git -C $GIT_ROOT log --oneline origin/master.. | wc -l)"
}
function git_changelog_date {
cached git_changelog_date && return
output "$(date +'%a %b %d %Y')"
}
function git_changelog_version {
cached git_changelog_version && return
git_version &>/dev/null # cache
git_revision &>/dev/null # cache
output "$(git_version)-$(git_revision)"
}