A free open source IT asset/license management system
Add new 'git remote' management to change Snipe-IT URL's
Brady Wetheringtona657c479bec0
diff --git a/upgrade.php b/upgrade.phpindex 6bbe543e9f..721cf6f03a 100644--- a/upgrade.php+++ b/upgrade.php@@ -79,6 +79,7 @@ echo "This script will attempt to: \n\n";echo "- validate some very basic .env file settings \n";echo "- check your PHP version and extension requirements \n";echo "- check directory permissions \n";+echo "- change your 'git remote' to the new Snipe-IT GitHub URL \n"echo "- do a git pull to bring you to the latest version \n";echo "- run composer install to get your vendors up to date \n";echo "- run a backup \n";@@ -437,6 +438,30 @@ $git_version = shell_exec('git --version');if ((strpos('git version', $git_version)) === false) {echo "Git is installed. \n";++ // check remotes for legacy snipe/snipe-it URL+ $remote = shell_exec('git remote -v');+ foreach (explode("\n", $remote) as $line) {+ $remote_bits = explode("\t", $line, 2);+ if (count($remote_bits) != 2) {+ continue;+ }+ @list($url, $purpose) = explode(" ", $remote_bits[1]);+ if (in_array($url, ['[email protected]:snipe/snipe-it.git', 'https://github.com/snipe/snipe-it.git'])) {+ // SSH or HTTPS remotes+ $new_url = preg_replace("|snipe/snipe-it|", "grokability/snipe-it", $url);+ echo $success_icon . " Resetting remote " . $remote_bits[0] . " at $url to $new_url for purpose: $purpose\n";+ $push = '';+ if ($purpose == '(push)') {+ $push = '--push ';+ }+ $cmd = "git remote set-url $push" . $remote_bits[0] . " " . $new_url;+ $remote_reset = shell_exec($cmd);+ if ($remote_reset) {+ echo '-- ' . $remote_reset . "\n";+ }+ }+ }$git_fetch = shell_exec('git fetch');$git_checkout = shell_exec('git checkout '.$branch);$git_stash = shell_exec('git stash');