diff --git a/upgrade.php b/upgrade.php index 6bbe543e9fff..721cf6f03af4 100644 --- a/upgrade.php +++ b/upgrade.php @@ -79,6 +79,7 @@ function url_get_contents ($Url) { 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 @@ function url_get_contents ($Url) { 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, ['git@github.com: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');