aboutsummaryrefslogtreecommitdiffhomepage
path: root/application/Updater.php
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2017-03-22 18:50:33 +0100
committerGitHub <noreply@github.com>2017-03-22 18:50:33 +0100
commit64c34078e4782d8f41e6c7f2beb7682823e99498 (patch)
tree3ba7a75ebef8b62a1abd7e819a6c14f34091ccb3 /application/Updater.php
parent36eb71fb48aa3e752a1e32774b8eead18780bf29 (diff)
parentb786c8836f0576d4feb1543471950c5d24bc7939 (diff)
downloadShaarli-64c34078e4782d8f41e6c7f2beb7682823e99498.tar.gz
Shaarli-64c34078e4782d8f41e6c7f2beb7682823e99498.tar.zst
Shaarli-64c34078e4782d8f41e6c7f2beb7682823e99498.zip
Merge pull request #816 from ArthurHoaro/project/master-version
Use 'dev' version on the master branch
Diffstat (limited to 'application/Updater.php')
-rw-r--r--application/Updater.php44
1 files changed, 44 insertions, 0 deletions
diff --git a/application/Updater.php b/application/Updater.php
index efbfc832..0fb68c5a 100644
--- a/application/Updater.php
+++ b/application/Updater.php
@@ -396,6 +396,50 @@ class Updater
396 396
397 return true; 397 return true;
398 } 398 }
399
400 /**
401 * Update updates.check_updates_branch setting.
402 *
403 * If the current major version digit matches the latest branch
404 * major version digit, we set the branch to `latest`,
405 * otherwise we'll check updates on the `stable` branch.
406 *
407 * No update required for the dev version.
408 *
409 * Note: due to hardcoded URL and lack of dependency injection, this is not unit testable.
410 *
411 * FIXME! This needs to be removed when we switch to first digit major version
412 * instead of the second one since the versionning process will change.
413 */
414 public function updateMethodCheckUpdateRemoteBranch()
415 {
416 if (shaarli_version === 'dev' || $this->conf->get('updates.check_updates_branch') === 'latest') {
417 return true;
418 }
419
420 // Get latest branch major version digit
421 $latestVersion = ApplicationUtils::getLatestGitVersionCode(
422 'https://raw.githubusercontent.com/shaarli/Shaarli/latest/shaarli_version.php',
423 5
424 );
425 if (preg_match('/(\d+)\.\d+$/', $latestVersion, $matches) === false) {
426 return false;
427 }
428 $latestMajor = $matches[1];
429
430 // Get current major version digit
431 preg_match('/(\d+)\.\d+$/', shaarli_version, $matches);
432 $currentMajor = $matches[1];
433
434 if ($currentMajor === $latestMajor) {
435 $branch = 'latest';
436 } else {
437 $branch = 'stable';
438 }
439 $this->conf->set('updates.check_updates_branch', $branch);
440 $this->conf->write($this->isLoggedIn);
441 return true;
442 }
399} 443}
400 444
401/** 445/**