Make ./mach rustup use the latest nightly rather than master.

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`.
This commit is contained in:
Simon Sapin 2017-05-12 14:20:01 +02:00
parent 58253f545b
commit 51f33d0a62

View file

@ -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")