-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
liskin-dotfiles-release
executable file
·65 lines (50 loc) · 1.48 KB
/
liskin-dotfiles-release
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
#!/usr/bin/env bash
set -eu -o pipefail
shopt -s lastpipe
# shellcheck source-path=..
. "$HOME"/bin/.o
function release-tree {
: "${1:?name}"
: "${2:?version}"
ref="refs/heads/standalone/$1"
tag="${1}-${2}"
ref_head="$(git rev-parse --verify --quiet "$ref" || :)"
tree="$(git mktree)"
commit="$(o git commit-tree ${ref_head:+-p "$ref_head"} -p @ "$tree" -m "$tag" </dev/tty)"
o git update-ref "$ref" "$commit"
o git tag -s "$tag" "$commit" </dev/tty
}
function mktree-add-from-head {
: "${1:?filename}"
git ls-tree --full-tree @:"$(dirname "$1" | grep -vxF .)" "$(basename "$1")"
}
function mktree-add-file {
: "${1:?filename}"
local blob; blob=$(git hash-object -w "$1")
printf "100${2:-644} blob %s\t%s\n" "$blob" "$(basename "$1")"
}
function mktree-add-symlink {
: "${1:?target}"
: "${2:?linkname}"
local blob; blob=$(git hash-object -w --stdin <<<"$1")
printf "120000 blob %s\t%s\n" "$blob" "$2"
}
function mktree-add-subdir {
: "${1:?subdir}"
local tree; tree=$(git mktree)
printf "040000 tree %s\t%s\n" "$tree" "$1"
}
function release-xrandr-smart {
: "${1:?version}"
make -C .local/share/man man1/xrandr-smart.1
{
mktree-add-from-head LICENSE
mktree-add-from-head bin/xrandr-smart
mktree-add-from-head .local/share/man/xrandr-smart.1.md
mktree-add-file .local/share/man/man1/xrandr-smart.1
mktree-add-symlink xrandr-smart.1.md README.md
} | release-tree xrandr-smart "$1"
}
toplevel="$(git rev-parse --show-toplevel 2>/dev/null)"
o cd "$toplevel"
o "$@"