aboutsummaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
authorSimon Sapin <simon.sapin@exyr.org>2017-05-12 14:20:01 +0200
committerSimon Sapin <simon.sapin@exyr.org>2017-05-13 12:01:05 +0200
commit51f33d0a62cf8c6e3ef372a1954d3dc4e8b0e842 (patch)
tree89c0a2b8f5660a5f71abcfd9bcb768a170aac2f0 /python
parent58253f545bfed82f4503069c5dd8e22e2dd5e2d4 (diff)
downloadservo-51f33d0a62cf8c6e3ef372a1954d3dc4e8b0e842.tar.gz
servo-51f33d0a62cf8c6e3ef372a1954d3dc4e8b0e842.zip
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`.
Diffstat (limited to 'python')
-rw-r--r--python/servo/devenv_commands.py20
1 files 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")