From 51f33d0a62cf8c6e3ef372a1954d3dc4e8b0e842 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Fri, 12 May 2017 14:20:01 +0200 Subject: [PATCH] Make `./mach rustup` use the latest nightly rather than master. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This will help avoid situation where we upgrade Servo and dependencies for a Rust breaking change that hasn’t reach Nightly yet. The old behavior is still available with `./mach rustup --master`. --- python/servo/devenv_commands.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/python/servo/devenv_commands.py b/python/servo/devenv_commands.py index 314c5c2b8c1..f7df09ce754 100644 --- a/python/servo/devenv_commands.py +++ b/python/servo/devenv_commands.py @@ -226,11 +226,23 @@ class MachCommands(CommandBase): env=self.build_env()) @Command('rustup', - description='Update the Rust version to latest master', + description='Update the Rust version to latest Nightly', category='devenv') - def rustup(self): - url = "https://api.github.com/repos/rust-lang/rust/git/refs/heads/master" - commit = json.load(urllib2.urlopen(url))["object"]["sha"] + @CommandArgument('--master', + action='store_true', + help='Use the latest commit of the "master" branch') + def rustup(self, master=False): + if master: + url = "https://api.github.com/repos/rust-lang/rust/git/refs/heads/master" + commit = json.load(urllib2.urlopen(url))["object"]["sha"] + else: + import toml + import re + url = "https://static.rust-lang.org/dist/channel-rust-nightly.toml" + version = toml.load(urllib2.urlopen(url))["pkg"]["rustc"]["version"] + short_commit = re.search("\(([0-9a-f]+) ", version).group(1) + url = "https://api.github.com/repos/rust-lang/rust/commits/" + short_commit + commit = json.load(urllib2.urlopen(url))["sha"] filename = path.join(self.context.topdir, "rust-commit-hash") with open(filename, "w") as f: f.write(commit + "\n")