forked from ghostty-org/ghostty
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrpkg.macros
79 lines (58 loc) · 1.96 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/bash
function cached {
declare v=${OUTPUT[$1]}
[[ -n $v ]] && echo -n "$v"
}
function zig_min_version {
cached zig_min_version && return
output "$(grep -oP 'buildpkg\.requireZig\("\K[^"]+' build.zig)"
}
function zig_max_version {
cached zig_max_version && return
declare major minor patch
read -r major minor patch <<<"$(zig_min_version | tr '.' ' ')"
output "${major}.$((minor + 1)).${patch}~"
}
function git_custom_describe {
cached git_custom_describe && return
declare describe devtag tag commits affix hash
describe=$(git describe --always --long --first-parent --abbrev=7 --exclude=tip origin/main)
read -r tag commits hash <<<"${describe//-/ }"
devtag="$(grep -oP '\.version\s*=\s*"\K[^\"]+' build.zig.zon)"
tag="${tag:1}"
if [[ "${tag}" == "${devtag}" ]]; then
affix='stable'
else
tag="${devtag}"
affix='dev'
fi
[[ ${#hash} -eq 8 ]] && hash="${hash:1}"
output "${tag} ${commits} ${affix} ${hash}"
}
function git_custom_package_version {
cached git_custom_package_version && return
declare tag commits affix hash
read -r tag commits affix hash <<<"$(git_custom_describe)"
output "${tag}~${affix}.${commits}+${hash}"
}
function git_custom_internal_version {
cached git_custom_internal_version && return
declare tag commits affix hash
read -r tag commits affix hash <<<"$(git_custom_describe)"
output "${tag}-${affix}+${hash}"
}
function git_custom_release {
cached git_custom_release && return
# find last merge
declare last_merge rest
read -r last_merge rest <<<"$(git log --merges --oneline -n1)"
[[ -n $last_merge ]] || abort "failed to find last merge"
# count commits since last merge; might be zero
declare release
release=$(git log --oneline HEAD "^$last_merge" | wc -l)
output "$((release + 1))"
}
function git_custom_date {
cached git_custom_date && return
output "$(date +'%a %b %d %Y')"
}