-
Notifications
You must be signed in to change notification settings - Fork 13
/
archlog
executable file
·68 lines (55 loc) · 1.52 KB
/
archlog
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
#!/usr/bin/env bash
# archlog -- show changelog for an Arch Linux package
. lib.bash || exit
basedir="${XDG_CACHE_HOME:-$HOME/.cache}/asp"
verbose=0
while getopts :v OPT; do
case $OPT in
v) verbose=1;;
*) lib:die_getopts;;
esac
done; shift $((OPTIND-1))
if (( ! $# )); then
vdie "package name not specified"
fi
if [[ ! -d $basedir ]]; then
mkdir -p "$basedir"
fi
for pkg; do
# Fix up tab-completion
pkg=${pkg#*/}
# Look up pkgbase if a binary package is specified
pkgbase=$(expac -S -1 %e "$pkg" || echo "$pkg")
if [[ "$pkg" != "$pkgbase" ]]; then
vmsg "using '$pkgbase' as source package name for '$pkg'"
pkg=$pkgbase
fi
dir="$basedir/$pkg"
url="https://gitlab.archlinux.org/archlinux/packaging/packages/$pkg.git"
# Update the repository
if [[ ! -d $dir ]]; then
vmsg "cloning '$pkg'"
GIT_TERMINAL_PROMPT=0 git clone --quiet "$url" "$dir"
else
vmsg "updating '$pkg'"
GIT_TERMINAL_PROMPT=0 git -C "$dir" pull --quiet --ff-only
fi || vdie "repository '$pkg' could not be updated"
# Always hide really verbose PGP-key diffs
if [[ ! -e $basedir/.gitattributes ]]; then
cat > "$basedir/.gitattributes" <<-!
# Symlinked into each repository's .git/info/attributes
/keys/pgp/*.asc -diff
!
fi
if [[ ! -e $dir/.git/info/attributes ]]; then
ln -rnsf "$basedir/.gitattributes" "$dir/.git/info/attributes"
fi
# Optionally hide redundant .SRCINFO diffs
paths=()
if (( !verbose )); then
paths+=(":!/.SRCINFO")
paths+=(":!/keys/pgp")
fi
settitle "asplog [$pkg]"
tig -C "$dir" "$ref" -- "${paths[@]}"
done