Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/pi-hole/pi-hole.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Warner <me@adamwarner.co.uk>2020-04-13 22:58:46 +0300
committerAdam Warner <me@adamwarner.co.uk>2020-04-13 22:58:46 +0300
commit851947bbf2fa89defc972b8991e612cd95f24566 (patch)
tree4c387161bd0d79548ccf85c10ce161d553430d37 /advanced
parent413fa94e9824af924da4366f5719bdccb85fde41 (diff)
Add branch name to version output
Signed-off-by: Adam Warner <me@adamwarner.co.uk>
Diffstat (limited to 'advanced')
-rwxr-xr-xadvanced/Scripts/version.sh34
1 files changed, 29 insertions, 5 deletions
diff --git a/advanced/Scripts/version.sh b/advanced/Scripts/version.sh
index f6d4d344..16bad62a 100755
--- a/advanced/Scripts/version.sh
+++ b/advanced/Scripts/version.sh
@@ -97,28 +97,52 @@ getRemoteVersion(){
return 0
}
+getLocalBranch(){
+ # Local FTL btranch is stored in /etc/pihole/ftlbranch
+ if [[ "$1" == "FTL" ]]; then
+ cat /etc/pihole/ftlbranch
+ return 0
+ fi
+
+ # Get the checked out branch of the local directory
+ local directory="${1}"
+ local branch
+
+ cd "${directory}" 2> /dev/null || { echo "${DEFAULT}"; return 1; }
+ branch=$(git rev-parse --abbrev-ref HEAD || echo "$DEFAULT")
+ if [[ ! "${branch}" =~ ^v ]]; then
+ echo "${branch}"
+ elif [[ "${branch}" == "${DEFAULT}" ]]; then
+ echo "ERROR"
+ return 1
+ else
+ echo "No Checked out branch"
+ fi
+ return 0
+}
+
versionOutput() {
[[ "$1" == "pi-hole" ]] && GITDIR=$COREGITDIR
[[ "$1" == "AdminLTE" ]] && GITDIR=$WEBGITDIR
[[ "$1" == "FTL" ]] && GITDIR="FTL"
- [[ "$2" == "-c" ]] || [[ "$2" == "--current" ]] || [[ -z "$2" ]] && current=$(getLocalVersion $GITDIR)
+ [[ "$2" == "-c" ]] || [[ "$2" == "--current" ]] || [[ -z "$2" ]] && current=$(getLocalVersion $GITDIR) && branch=$(getLocalBranch $GITDIR)
[[ "$2" == "-l" ]] || [[ "$2" == "--latest" ]] || [[ -z "$2" ]] && latest=$(getRemoteVersion "$1")
if [[ "$2" == "-h" ]] || [[ "$2" == "--hash" ]]; then
- [[ "$3" == "-c" ]] || [[ "$3" == "--current" ]] || [[ -z "$3" ]] && curHash=$(getLocalHash "$GITDIR")
+ [[ "$3" == "-c" ]] || [[ "$3" == "--current" ]] || [[ -z "$3" ]] && curHash=$(getLocalHash "$GITDIR") && branch=$(getLocalBranch $GITDIR)
[[ "$3" == "-l" ]] || [[ "$3" == "--latest" ]] || [[ -z "$3" ]] && latHash=$(getRemoteHash "$1" "$(cd "$GITDIR" 2> /dev/null && git rev-parse --abbrev-ref HEAD)")
fi
if [[ -n "$current" ]] && [[ -n "$latest" ]]; then
- output="${1^} version is $current (Latest: $latest)"
+ output="${1^} version is $current (Latest: $latest) Branch: $branch"
elif [[ -n "$current" ]] && [[ -z "$latest" ]]; then
- output="Current ${1^} version is $current"
+ output="Current ${1^} version is $current. Branch: $branch"
elif [[ -z "$current" ]] && [[ -n "$latest" ]]; then
output="Latest ${1^} version is $latest"
elif [[ "$curHash" == "N/A" ]] || [[ "$latHash" == "N/A" ]]; then
output="${1^} hash is not applicable"
elif [[ -n "$curHash" ]] && [[ -n "$latHash" ]]; then
- output="${1^} hash is $curHash (Latest: $latHash)"
+ output="${1^} hash is $curHash (Latest: $latHash) Branch: $branch"
elif [[ -n "$curHash" ]] && [[ -z "$latHash" ]]; then
output="Current ${1^} hash is $curHash"
elif [[ -z "$curHash" ]] && [[ -n "$latHash" ]]; then