abuild: simplify optional git usage

set git=true if git is missing so all git commands are ignored. This
simplifies the code a bit
This commit is contained in:
Natanael Copa 2018-04-13 14:34:34 +00:00
parent 6fc2f40a0d
commit fd97176583
1 changed files with 5 additions and 11 deletions

View File

@ -12,7 +12,7 @@ sysconfdir=@sysconfdir@
datadir=@datadir@ datadir=@datadir@
abuild_path=$(readlink -f $0) abuild_path=$(readlink -f $0)
git_path=$(command -v git || true) git=$(command -v git) || git=true
if ! [ -f "$datadir/functions.sh" ]; then if ! [ -f "$datadir/functions.sh" ]; then
echo "$datadir/functions.sh: not found" >&2 echo "$datadir/functions.sh: not found" >&2
@ -809,14 +809,12 @@ prepare_language_packs() {
# echo '-dirty' if git is not clean # echo '-dirty' if git is not clean
git_dirty() { git_dirty() {
[ -z "$git_path" ] && return [ $($git status -s "$startdir" | wc -l) -ne 0 ] && echo "-dirty"
[ $(git status -s "$startdir" | wc -l) -ne 0 ] && echo "-dirty"
} }
# echo last commit hash id # echo last commit hash id
git_last_commit() { git_last_commit() {
[ -z "$git_path" ] && return $git log --format=oneline -n 1 "$startdir" | awk '{print $1}'
git log --format=oneline -n 1 "$startdir" | awk '{print $1}'
} }
get_maintainer() { get_maintainer() {
@ -1546,11 +1544,7 @@ update_abuildrepo_index() {
subpkg_unset subpkg_unset
if [ -z "$DESCRIPTION" ]; then if [ -z "$DESCRIPTION" ]; then
if [ -n "$git_path" ]; then DESCRIPTION="$repo $(cd $startdir && $git describe)"
DESCRIPTION="$repo $(cd $startdir && git describe)"
else
DESCRIPTION="$repo"
fi
fi fi
for i in $allarch; do for i in $allarch; do
@ -2404,7 +2398,7 @@ snapshot() {
# clone git repo and archive # clone git repo and archive
if [ -n "$giturl" ]; then if [ -n "$giturl" ]; then
local _version=${verbase:-0}_git${_date} local _version=${verbase:-0}_git${_date}
[ -z "$git_path" ] && die "Missing git! Install git to support git clone." [ "$git" = "true" ] && die "Missing git! Install git to support git clone."
local _rev="${reporev:-HEAD}" local _rev="${reporev:-HEAD}"
[ "$_rev" = "HEAD" ] && local _depth="--depth=1" [ "$_rev" = "HEAD" ] && local _depth="--depth=1"
msg "Creating git snapshot: $pkgname-$_version" msg "Creating git snapshot: $pkgname-$_version"