From d4d07f766a9cc618c52cf3071ec84f4807bb5d79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Wed, 11 Oct 2023 22:04:29 +0200 Subject: [PATCH 1/5] Fix update logic for custom branches by comparing hashes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christian König --- scripts/pi-hole/js/footer.js | 52 ++++++++++++++++++++++++------------ 1 file changed, 35 insertions(+), 17 deletions(-) diff --git a/scripts/pi-hole/js/footer.js b/scripts/pi-hole/js/footer.js index 4fd4050a..65cb4f29 100644 --- a/scripts/pi-hole/js/footer.js +++ b/scripts/pi-hole/js/footer.js @@ -474,6 +474,7 @@ function updateVersionInfo() { remote: version.core.remote.version, branch: version.core.local.branch, hash: version.core.local.hash, + hash_remote: version.core.remote.hash, url: "https://github.com/pi-hole/pi-hole/releases", }, { @@ -482,6 +483,7 @@ function updateVersionInfo() { remote: version.ftl.remote.version, branch: version.ftl.local.branch, hash: version.ftl.local.hash, + hash_remote: version.ftl.remote.hash, url: "https://github.com/pi-hole/FTL/releases", }, { @@ -490,6 +492,7 @@ function updateVersionInfo() { remote: version.web.remote.version, branch: version.web.local.branch, hash: version.web.local.hash, + hash_remote: version.web.remote.hash, url: "https://github.com/pi-hole/web/releases", }, ]; @@ -508,23 +511,38 @@ function updateVersionInfo() { '" rel="noopener" target="_blank">' + localVersion + ""; - } else localVersion = "vDev (" + v.branch + ", " + v.hash + ")"; - - if (versionCompare(v.local, v.remote) === -1) { - if (v.name === "Docker Tag") dockerUpdate = true; - else updateAvailable = true; - $("#versions").append( - "
  • " + - v.name + - " " + - localVersion + - '· Update available!
  • ' - ); - } else { - $("#versions").append("
  • " + v.name + " " + localVersion + "
  • "); - } + if (versionCompare(v.local, v.remote) === -1) { + // Update available + $("#versions").append( + "
  • " + + v.name + + " " + + localVersion + + '· Update available!
  • ' + ); + } else { + $("#versions").append("
  • " + v.name + " " + localVersion + "
  • "); + } + } else { + // non-master branch + localVersion = "vDev (" + v.branch + ", " + v.hash + ")"; + if (v.hash != v.hash_remote) { + // hash differ > Update available + $("#versions").append( + "
  • " + + v.name + + " " + + localVersion + + '· Update available!
  • ' + ); + } else { + $("#versions").append("
  • " + v.name + " " + localVersion + "
  • "); + } + } } }); From 5cd83cfa2482f95c20d92a68ee01799f91fd3f3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Wed, 11 Oct 2023 22:19:11 +0200 Subject: [PATCH 2/5] Remove duplication MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christian König --- scripts/pi-hole/js/footer.js | 47 +++++++++++++++--------------------- 1 file changed, 20 insertions(+), 27 deletions(-) diff --git a/scripts/pi-hole/js/footer.js b/scripts/pi-hole/js/footer.js index 65cb4f29..bdae70ee 100644 --- a/scripts/pi-hole/js/footer.js +++ b/scripts/pi-hole/js/footer.js @@ -513,36 +513,29 @@ function updateVersionInfo() { ""; if (versionCompare(v.local, v.remote) === -1) { // Update available - $("#versions").append( - "
  • " + - v.name + - " " + - localVersion + - '· Update available!
  • ' - ); - } else { - $("#versions").append("
  • " + v.name + " " + localVersion + "
  • "); - } - } else { - // non-master branch - localVersion = "vDev (" + v.branch + ", " + v.hash + ")"; - if (v.hash != v.hash_remote) { - // hash differ > Update available - $("#versions").append( - "
  • " + - v.name + - " " + - localVersion + - '· Update available!
  • ' - ); + updateAvailable = true; } else { - $("#versions").append("
  • " + v.name + " " + localVersion + "
  • "); + // non-master branch + localVersion = "vDev (" + v.branch + ", " + v.hash + ")"; + if (v.hash != v.hash_remote) { + // hash differ > Update available + updateAvailable = true; + } } } + if (updateAvailable) { + $("#versions").append( + "
  • " + + v.name + + " " + + localVersion + + '· Update available!
  • ' + ); + } else { + $("#versions").append("
  • " + v.name + " " + localVersion + "
  • "); + } } }); From fc542f5f86da5b45fc320d6fd478605e026f3210 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Wed, 11 Oct 2023 22:49:22 +0200 Subject: [PATCH 3/5] Close at the right place MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christian König --- scripts/pi-hole/js/footer.js | 43 ++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/scripts/pi-hole/js/footer.js b/scripts/pi-hole/js/footer.js index bdae70ee..46a619c6 100644 --- a/scripts/pi-hole/js/footer.js +++ b/scripts/pi-hole/js/footer.js @@ -514,30 +514,29 @@ function updateVersionInfo() { if (versionCompare(v.local, v.remote) === -1) { // Update available updateAvailable = true; - } else { - // non-master branch - localVersion = "vDev (" + v.branch + ", " + v.hash + ")"; - if (v.hash != v.hash_remote) { - // hash differ > Update available - updateAvailable = true; - } + } + } else { + // non-master branch + localVersion = "vDev (" + v.branch + ", " + v.hash + ")"; + if (v.hash != v.hash_remote) { + // hash differ > Update available + updateAvailable = true; } } - if (updateAvailable) { - $("#versions").append( - "
  • " + - v.name + - " " + - localVersion + - '· Update available!
  • ' - ); - } else { - $("#versions").append("
  • " + v.name + " " + localVersion + "
  • "); - } - } - }); + if (updateAvailable) { + $("#versions").append( + "
  • " + + v.name + + " " + + localVersion + + '· Update available!
  • ' + ); + } else { + $("#versions").append("
  • " + v.name + " " + localVersion + "
  • "); + } + }}); if (dockerUpdate) $("update-hint").html( From bde139638927470d876eb7a4237b9b34e3bd3862 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Wed, 11 Oct 2023 22:52:54 +0200 Subject: [PATCH 4/5] Fix tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christian König --- scripts/pi-hole/js/footer.js | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/scripts/pi-hole/js/footer.js b/scripts/pi-hole/js/footer.js index 46a619c6..a1628c89 100644 --- a/scripts/pi-hole/js/footer.js +++ b/scripts/pi-hole/js/footer.js @@ -518,25 +518,27 @@ function updateVersionInfo() { } else { // non-master branch localVersion = "vDev (" + v.branch + ", " + v.hash + ")"; - if (v.hash != v.hash_remote) { + if (v.hash !== v.hash_remote) { // hash differ > Update available updateAvailable = true; } } - if (updateAvailable) { - $("#versions").append( - "
  • " + - v.name + - " " + - localVersion + - '· Update available!
  • ' - ); - } else { - $("#versions").append("
  • " + v.name + " " + localVersion + "
  • "); - } - }}); + + if (updateAvailable) { + $("#versions").append( + "
  • " + + v.name + + " " + + localVersion + + '· Update available!
  • ' + ); + } else { + $("#versions").append("
  • " + v.name + " " + localVersion + "
  • "); + } + } + }); if (dockerUpdate) $("update-hint").html( From 45b1c667988c6ab9a435b8645116a5df67cf6aba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Wed, 11 Oct 2023 23:06:49 +0200 Subject: [PATCH 5/5] Add check for Docker tag MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christian König --- scripts/pi-hole/js/footer.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/pi-hole/js/footer.js b/scripts/pi-hole/js/footer.js index a1628c89..70bc1d39 100644 --- a/scripts/pi-hole/js/footer.js +++ b/scripts/pi-hole/js/footer.js @@ -524,6 +524,11 @@ function updateVersionInfo() { } } + if (v.name === "Docker Tag" && versionCompare(v.local, v.remote) === -1) { + updateAvailable = true; + dockerUpdate = true; + } + if (updateAvailable) { $("#versions").append( "
  • " +