mirror of
https://github.com/pi-hole/pi-hole
synced 2024-12-31 19:20:54 +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
@ -35,13 +35,23 @@ source "/opt/pihole/COL_TABLE"
|
|||||||
|
|
||||||
GitCheckUpdateAvail() {
|
GitCheckUpdateAvail() {
|
||||||
local directory
|
local directory
|
||||||
|
local curBranch
|
||||||
directory="${1}"
|
directory="${1}"
|
||||||
curdir=$PWD
|
curdir=$PWD
|
||||||
cd "${directory}" || return
|
cd "${directory}" || return
|
||||||
|
|
||||||
# Fetch latest changes in this repo
|
# Fetch latest changes in this repo
|
||||||
git fetch --quiet origin
|
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
|
# @ alone is a shortcut for HEAD. Older versions of git
|
||||||
# need @{0}
|
# need @{0}
|
||||||
LOCAL="$(git rev-parse "@{0}")"
|
LOCAL="$(git rev-parse "@{0}")"
|
||||||
@ -54,6 +64,8 @@ GitCheckUpdateAvail() {
|
|||||||
# branch.<name>.merge). A missing branchname
|
# branch.<name>.merge). A missing branchname
|
||||||
# defaults to the current one.
|
# defaults to the current one.
|
||||||
REMOTE="$(git rev-parse "@{upstream}")"
|
REMOTE="$(git rev-parse "@{upstream}")"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
if [[ "${#LOCAL}" == 0 ]]; then
|
if [[ "${#LOCAL}" == 0 ]]; then
|
||||||
echo -e "\\n ${COL_LIGHT_RED}Error: Local revision could not be obtained, please contact Pi-hole Support"
|
echo -e "\\n ${COL_LIGHT_RED}Error: Local revision could not be obtained, please contact Pi-hole Support"
|
||||||
|
Loading…
Reference in New Issue
Block a user