From c345c1bbea5a10b2caca0c65476a4e1d24d2ff66 Mon Sep 17 00:00:00 2001 From: Greg Spencer Date: Wed, 14 Mar 2018 12:56:44 -0700 Subject: [PATCH] Fix the remote setup to only change the URL. (#15528) This changes the packaging tool to only set the remote URL instead of recreating the remote. Recreating it was removing some metadata that identified the repo as having been cloned from the "real" repo, so flutter --version would report an unknown channel and source. This just sets the URL so that it looks like it came from GitHub. I also fixed some incorrect comments, and made unzip work on platforms other than Windows (even though we don't really need it there yet). Fixes #15518 --- dev/bots/prepare_package.dart | 22 ++++++++++++++-------- dev/bots/test/prepare_package_test.dart | 6 ++---- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/dev/bots/prepare_package.dart b/dev/bots/prepare_package.dart index 9935908e6fa..8756e117bc3 100644 --- a/dev/bots/prepare_package.dart +++ b/dev/bots/prepare_package.dart @@ -298,8 +298,7 @@ class ArchiveCreator { await _runGit(['reset', '--hard', revision]); // Make the origin point to github instead of the chromium mirror. - await _runGit(['remote', 'remove', 'origin']); - await _runGit(['remote', 'add', 'origin', githubRepo]); + await _runGit(['remote', 'set-url', 'origin', githubRepo]); } /// Retrieve the MinGit executable from storage and unpack it. @@ -362,18 +361,25 @@ class ArchiveCreator { /// Unpacks the given zip file into the currentDirectory (if set), or the /// same directory as the archive. - /// - /// May only be run on Windows (since 7Zip is not available on other platforms). Future _unzipArchive(File archive, {Directory workingDirectory}) { - assert(platform.isWindows); // 7Zip is only available on Windows. workingDirectory ??= new Directory(path.dirname(archive.absolute.path)); - final List commandLine = ['7za', 'x', archive.absolute.path]; + List commandLine; + if (platform.isWindows) { + commandLine = [ + '7za', + 'x', + archive.absolute.path, + ]; + } else { + commandLine = [ + 'unzip', + archive.absolute.path, + ]; + } return _processRunner.runProcess(commandLine, workingDirectory: workingDirectory); } /// Create a zip archive from the directory source. - /// - /// May only be run on Windows (since 7Zip is not available on other platforms). Future _createZipArchive(File output, Directory source) { List commandLine; if (platform.isWindows) { diff --git a/dev/bots/test/prepare_package_test.dart b/dev/bots/test/prepare_package_test.dart index 91e9405b8ed..a6424cc1efd 100644 --- a/dev/bots/test/prepare_package_test.dart +++ b/dev/bots/test/prepare_package_test.dart @@ -113,8 +113,7 @@ void main() { 'git clone -b dev https://chromium.googlesource.com/external/github.com/flutter/flutter': null, 'git reset --hard $testRef': null, - 'git remote remove origin': null, - 'git remote add origin https://github.com/flutter/flutter.git': null, + 'git remote set-url origin https://github.com/flutter/flutter.git': null, 'git describe --tags --abbrev=0': [new ProcessResult(0, 0, 'v1.2.3', '')], }; if (platform.isWindows) { @@ -158,8 +157,7 @@ void main() { 'git clone -b dev https://chromium.googlesource.com/external/github.com/flutter/flutter': null, 'git reset --hard $testRef': null, - 'git remote remove origin': null, - 'git remote add origin https://github.com/flutter/flutter.git': null, + 'git remote set-url origin https://github.com/flutter/flutter.git': null, 'git describe --tags --abbrev=0': [new ProcessResult(0, 0, 'v1.2.3', '')], }; if (platform.isWindows) {