mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-12-24 13:50:17 +00:00
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>
This commit is contained in:
parent
1eb31174a5
commit
920cf6de14
1 changed files with 24 additions and 12 deletions
|
@ -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
|
||||
git fetch --tags --quiet origin
|
||||
|
||||
# @ alone is a shortcut for HEAD. Older versions of git
|
||||
# need @{0}
|
||||
LOCAL="$(git rev-parse "@{0}")"
|
||||
# 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
|
||||
|
||||
# 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}")"
|
||||
|
||||
if [[ "${#LOCAL}" == 0 ]]; then
|
||||
echo -e "\\n ${COL_LIGHT_RED}Error: Local revision could not be obtained, please contact Pi-hole Support"
|
||||
|
|
Loading…
Reference in a new issue