mirror of
https://gitee.com/openharmony/third_party_rust_syn
synced 2024-11-23 07:50:04 +00:00
Script to clone the rust-lang/rust repo
This commit is contained in:
parent
8bcc23bdb5
commit
11e6da97ac
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,3 +1,4 @@
|
||||
target
|
||||
Cargo.lock
|
||||
tests/rust
|
||||
tests/rust/*
|
||||
!tests/rust/clone.sh
|
||||
|
@ -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
22
tests/rust/clone.sh
Executable 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"
|
Loading…
Reference in New Issue
Block a user