Check for updates on master based on tags not commits (#4475)

* Check for updates on master based on tags not commits

Signed-off-by: Christian König <ckoenig@posteo.de>

* Fix stickler

Signed-off-by: Christian König <ckoenig@posteo.de>

* Address reviewer's comments

Signed-off-by: Christian König <ckoenig@posteo.de>

* Fix stickler again

Signed-off-by: Christian König <ckoenig@posteo.de>

* Use local git instead of relying on github

Signed-off-by: Christian König <ckoenig@posteo.de>

* Add --tags

Co-authored-by: DL6ER <DL6ER@users.noreply.github.com>

Co-authored-by: DL6ER <DL6ER@users.noreply.github.com>
pull/4480/head
yubiuser 2 years ago committed by GitHub
parent 1eb31174a5
commit 920cf6de14
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -35,25 +35,37 @@ source "/opt/pihole/COL_TABLE"
GitCheckUpdateAvail() {
local directory
local curBranch
directory="${1}"
curdir=$PWD
cd "${directory}" || return
# Fetch latest changes in this repo
git fetch --quiet origin
# @ alone is a shortcut for HEAD. Older versions of git
# need @{0}
LOCAL="$(git rev-parse "@{0}")"
# The suffix @{upstream} to a branchname
# (short form <branchname>@{u}) refers
# to the branch that the branch specified
# by branchname is set to build on top of#
# (configured with branch.<name>.remote and
# branch.<name>.merge). A missing branchname
# defaults to the current one.
REMOTE="$(git rev-parse "@{upstream}")"
git fetch --tags --quiet origin
# Check current branch. If it is master, then check for the latest available tag instead of latest commit.
curBranch=$(git rev-parse --abbrev-ref HEAD)
if [[ "${curBranch}" == "master" ]]; then
# get the latest local tag
LOCAL=$(git describe --abbrev=0 --tags master)
# get the latest tag from remote
REMOTE=$(git describe --abbrev=0 --tags origin/master)
else
# @ alone is a shortcut for HEAD. Older versions of git
# need @{0}
LOCAL="$(git rev-parse "@{0}")"
# The suffix @{upstream} to a branchname
# (short form <branchname>@{u}) refers
# to the branch that the branch specified
# by branchname is set to build on top of#
# (configured with branch.<name>.remote and
# branch.<name>.merge). A missing branchname
# defaults to the current one.
REMOTE="$(git rev-parse "@{upstream}")"
fi
if [[ "${#LOCAL}" == 0 ]]; then
echo -e "\\n ${COL_LIGHT_RED}Error: Local revision could not be obtained, please contact Pi-hole Support"

Loading…
Cancel
Save