first upload
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
#!/usr/bin/env bash
|
||||
# PKGBUILD review
|
||||
|
||||
# Review PKGBUILD in dir. Returns 0 to continue, 1 to abort.
|
||||
review_pkgbuild() {
|
||||
local dir=$1
|
||||
local name=${2:-$(basename "$dir")}
|
||||
|
||||
[[ ${MIAUR_SKIPREVIEW:-0} -eq 1 ]] && return 0
|
||||
|
||||
local pb="$dir/PKGBUILD"
|
||||
[[ -f $pb ]] || die "PKGBUILD not found: $dir"
|
||||
|
||||
msg "Reviewing the PKGBUILD for $name"
|
||||
if command -v "${MIAUR_BAT}" >/dev/null 2>&1; then
|
||||
"${MIAUR_BAT}" --style=plain --paging=always --language=bash "$pb" || true
|
||||
elif command -v less >/dev/null 2>&1; then
|
||||
less -R "$pb" || true
|
||||
else
|
||||
cat "$pb"
|
||||
fi
|
||||
|
||||
# Also show install script / other files briefly
|
||||
local f
|
||||
for f in "$dir"/*.install "$dir"/PKGBUILD; do
|
||||
[[ -f $f ]] || continue
|
||||
done
|
||||
|
||||
while true; do
|
||||
printf '%s::%s View diff (d), edit (e), continue (y), skip (s), or quit (q)? [Y/d/e/s/q] ' \
|
||||
"${C_BOLD}${C_BLUE}" "${C_RESET}"
|
||||
local ans=
|
||||
read -r ans || return 1
|
||||
ans=${ans:-y}
|
||||
case "${ans,,}" in
|
||||
y | yes | '') return 0 ;;
|
||||
q | quit | n | no)
|
||||
warn "Cancelled by user"
|
||||
return 1
|
||||
;;
|
||||
s | skip) return 2 ;;
|
||||
e | edit)
|
||||
"${MIAUR_EDITOR}" "$pb"
|
||||
;;
|
||||
d | diff)
|
||||
if [[ -d $dir/.git ]]; then
|
||||
(cd "$dir" && ${MIAUR_GIT} diff -- PKGBUILD) || true
|
||||
else
|
||||
warn "No Git history is available for comparison"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
warn "Invalid input"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
Reference in New Issue
Block a user