Skip to content
Snippets Groups Projects
Commit 31c5bb51 authored by Jared Hancock's avatar Jared Hancock
Browse files

deploy: Touch version number on deployment

parent 846bb7fc
Branches
Tags
No related merge requests found
...@@ -102,7 +102,7 @@ class Deployment extends Unpacker { ...@@ -102,7 +102,7 @@ class Deployment extends Unpacker {
# main.inc.php # main.inc.php
$include = ($upgrade) ? $this->get_include_dir() $include = ($upgrade) ? $this->get_include_dir()
: ($options['include'] ? $options['include'] : ($options['include'] ? $options['include']
: "{$this->destination}/include"); : rtrim($this->destination, '/')."/include");
$include = rtrim($include, '/').'/'; $include = rtrim($include, '/').'/';
# Locate the upload folder # Locate the upload folder
...@@ -119,9 +119,11 @@ class Deployment extends Unpacker { ...@@ -119,9 +119,11 @@ class Deployment extends Unpacker {
# Unpack the include folder # Unpack the include folder
$this->unpackage("$root/include/{,.}*", $include, -1, $this->unpackage("$root/include/{,.}*", $include, -1,
array("*/include/ost-config.php")); array("*/include/ost-config.php"));
if (!$options['dry-run'] if (!$options['dry-run']) {
&& $include != "{$this->destination}/include") if ($include != "{$this->destination}/include/")
$this->change_include_dir($include); $this->change_include_dir($include);
$this->touch_version();
}
if ($options['clean']) { if ($options['clean']) {
// Clean everything but include folder first // Clean everything but include folder first
...@@ -132,6 +134,30 @@ class Deployment extends Unpacker { ...@@ -132,6 +134,30 @@ class Deployment extends Unpacker {
"*/.htaccess")); "*/.htaccess"));
} }
} }
function touch_version($version=false) {
if (!$version)
$version = exec('git describe');
if (!$version)
return false;
$bootstrap_php = $this->destination . '/bootstrap.php';
$lines = explode("\n", file_get_contents($bootstrap_php));
# Find the line that defines INCLUDE_DIR
$match = array();
foreach ($lines as &$line) {
// TODO: Change THIS_VERSION inline to be current `git describe`
if (preg_match("/(\s*)define\s*\(\s*'THIS_VERSION'/", $line, $match)) {
# Replace the definition with the new locatin
$line = $match[1] . "define('THIS_VERSION', '"
. $version
. "'); // Set by installer";
break;
}
}
if (!file_put_contents($bootstrap_php, implode("\n", $lines)))
die("Unable to write version information to bootstrap.php\n");
}
} }
Module::register('deploy', 'Deployment'); Module::register('deploy', 'Deployment');
......
...@@ -72,7 +72,7 @@ class Unpacker extends Module { ...@@ -72,7 +72,7 @@ class Unpacker extends Module {
} }
} }
if (!file_put_contents($bootstrap_php, implode("\n", $lines))) if (!file_put_contents($bootstrap_php, implode("\n", $lines)))
die("Unable to configure location of INCLUDE_DIR in main.inc.php\n"); die("Unable to configure location of INCLUDE_DIR in bootstrap.php\n");
} }
function exclude($pattern, $match) { function exclude($pattern, $match) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment