Script to clone the rust-lang/rust repo

This commit is contained in:
David Tolnay 2017-11-19 11:57:24 -08:00
parent 8bcc23bdb5
commit 11e6da97ac
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82
3 changed files with 25 additions and 25 deletions

3
.gitignore vendored
View File

@ -1,3 +1,4 @@
target
Cargo.lock
tests/rust
tests/rust/*
!tests/rust/clone.sh

View File

@ -4,7 +4,6 @@ extern crate walkdir;
extern crate syntax;
use std::env;
use std::path::Path;
use std::process::Command;
use std::u32;
@ -109,29 +108,7 @@ pub fn base_dir_filter(entry: &DirEntry) -> bool {
}
pub fn clone_rust() {
if Path::new("tests/rust").is_dir() {
println!("found rust repo in tests/rust");
return;
}
println!("cloning rust-lang/rust");
let result = Command::new("git")
.arg("clone")
.arg("https://github.com/rust-lang/rust")
.arg("tests/rust")
.status()
.unwrap();
println!("result: {}", result);
assert!(result.success());
println!("reset to known-good rev");
let result = Command::new("git")
.arg("reset")
.arg("--hard")
.arg("eb8f2586ebd842dec49d3d7f50e49a985ab31493")
.current_dir("tests/rust")
.status()
.unwrap();
let result = Command::new("tests/rust/clone.sh").status().unwrap();
println!("result: {}", result);
assert!(result.success());
}

22
tests/rust/clone.sh Executable file
View File

@ -0,0 +1,22 @@
#!/bin/bash
REMOTE=rust
REPO=https://github.com/rust-lang/rust
REV=eb8f2586ebd842dec49d3d7f50e49a985ab31493
set -euo pipefail
cd "$(dirname "${BASH_SOURCE[0]}")"
git init
if git remote | grep --fixed-strings --line-regexp --quiet "$REMOTE"; then
git remote set-url "$REMOTE" "$REPO"
else
git remote add "$REMOTE" "$REPO"
fi
if ! git cat-file -t "$REV" >/dev/null 2>&1; then
git fetch "$REMOTE" master
fi
git checkout "$REV"