From fd97176583ed7a13d4fd63ecbad3d436fe14d0b2 Mon Sep 17 00:00:00 2001 From: Natanael Copa Date: Fri, 13 Apr 2018 14:34:34 +0000 Subject: [PATCH] abuild: simplify optional git usage set git=true if git is missing so all git commands are ignored. This simplifies the code a bit --- abuild.in | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/abuild.in b/abuild.in index db74f2d..a10bca3 100644 --- a/abuild.in +++ b/abuild.in @@ -12,7 +12,7 @@ sysconfdir=@sysconfdir@ datadir=@datadir@ abuild_path=$(readlink -f $0) -git_path=$(command -v git || true) +git=$(command -v git) || git=true if ! [ -f "$datadir/functions.sh" ]; then echo "$datadir/functions.sh: not found" >&2 @@ -809,14 +809,12 @@ prepare_language_packs() { # echo '-dirty' if git is not clean 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 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() { @@ -1546,11 +1544,7 @@ update_abuildrepo_index() { subpkg_unset if [ -z "$DESCRIPTION" ]; then - if [ -n "$git_path" ]; then - DESCRIPTION="$repo $(cd $startdir && git describe)" - else - DESCRIPTION="$repo" - fi + DESCRIPTION="$repo $(cd $startdir && $git describe)" fi for i in $allarch; do @@ -2404,7 +2398,7 @@ snapshot() { # clone git repo and archive if [ -n "$giturl" ]; then 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}" [ "$_rev" = "HEAD" ] && local _depth="--depth=1" msg "Creating git snapshot: $pkgname-$_version"