aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--application/Updater.php44
1 files changed, 44 insertions, 0 deletions
diff --git a/application/Updater.php b/application/Updater.php
index fd7e2073..1bc5be0c 100644
--- a/application/Updater.php
+++ b/application/Updater.php
@@ -380,6 +380,50 @@ class Updater
380 $this->conf->write($this->isLoggedIn); 380 $this->conf->write($this->isLoggedIn);
381 return true; 381 return true;
382 } 382 }
383
384 /**
385 * Update updates.check_updates_branch setting.
386 *
387 * If the current major version digit matches the latest branch
388 * major version digit, we set the branch to `latest`,
389 * otherwise we'll check updates on the `stable` branch.
390 *
391 * No update required for the dev version.
392 *
393 * Note: due to hardcoded URL and lack of dependency injection, this is not unit testable.
394 *
395 * FIXME! This needs to be removed when we switch to first digit major version
396 * instead of the second one since the versionning process will change.
397 */
398 public function updateMethodCheckUpdateRemoteBranch()
399 {
400 if (shaarli_version === 'dev' || $this->conf->get('updates.check_updates_branch') === 'latest') {
401 return true;
402 }
403
404 // Get latest branch major version digit
405 $latestVersion = ApplicationUtils::getLatestGitVersionCode(
406 'https://raw.githubusercontent.com/shaarli/Shaarli/latest/shaarli_version.php',
407 5
408 );
409 if (preg_match('/(\d+)\.\d+$/', $latestVersion, $matches) === false) {
410 return false;
411 }
412 $latestMajor = $matches[1];
413
414 // Get current major version digit
415 preg_match('/(\d+)\.\d+$/', shaarli_version, $matches);
416 $currentMajor = $matches[1];
417
418 if ($currentMajor === $latestMajor) {
419 $branch = 'latest';
420 } else {
421 $branch = 'stable';
422 }
423 $this->conf->set('updates.check_updates_branch', $branch);
424 $this->conf->write($this->isLoggedIn);
425 return true;
426 }
383} 427}
384 428
385/** 429/**