Auto merge of #16836 - servo:nightly, r=nox

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

<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/16836)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-05-13 06:07:11 -05:00 committed by GitHub
commit d2fa2ae934

View file

@ -226,11 +226,23 @@ class MachCommands(CommandBase):
env=self.build_env()) env=self.build_env())
@Command('rustup', @Command('rustup',
description='Update the Rust version to latest master', description='Update the Rust version to latest Nightly',
category='devenv') category='devenv')
def rustup(self): @CommandArgument('--master',
url = "https://api.github.com/repos/rust-lang/rust/git/refs/heads/master" action='store_true',
commit = json.load(urllib2.urlopen(url))["object"]["sha"] 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") filename = path.join(self.context.topdir, "rust-commit-hash")
with open(filename, "w") as f: with open(filename, "w") as f:
f.write(commit + "\n") f.write(commit + "\n")