Simplify git subroutines

Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
DL6ER 2017-11-08 19:11:41 +01:00
parent 0db76aada0
commit 90efa3b610
No known key found for this signature in database
GPG Key ID: 00135ACBD90B28DD
1 changed files with 4 additions and 18 deletions

View File

@ -33,15 +33,8 @@ echo "${GITHUB_CORE_VERSION} ${GITHUB_WEB_VERSION} ${GITHUB_FTL_VERSION}" > "/et
function get_local_branch() { function get_local_branch() {
# Return active branch # Return active branch
local directory cd "${1}" 2> /dev/null || return 1
directory="${1}" git rev-parse --abbrev-ref HEAD || return 1
local output
cd "${directory}" 2> /dev/null || return 1
# Store STDERR as STDOUT variable
output=$( { git rev-parse --abbrev-ref HEAD; } 2>&1 )
echo "$output"
return
} }
CORE_BRANCH="$(get_local_branch /etc/.pihole)" CORE_BRANCH="$(get_local_branch /etc/.pihole)"
@ -55,15 +48,8 @@ echo "${CORE_BRANCH} ${WEB_BRANCH} ${FTL_BRANCH}" > "/etc/pihole/localbranches"
function get_local_version() { function get_local_version() {
# Return active branch # Return active branch
local directory cd "${1}" 2> /dev/null || return 1
directory="${1}" git describe --long --dirty --tags || return 1
local output
cd "${directory}" 2> /dev/null || return 1
# Store STDERR as STDOUT variable
output=$( { git describe --long --dirty --tags; } 2>&1 )
echo "$output"
return
} }
CORE_VERSION="$(get_local_version /etc/.pihole)" CORE_VERSION="$(get_local_version /etc/.pihole)"