-
Notifications
You must be signed in to change notification settings - Fork 12.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
auto merge of #7681 : catamorphism/rust/rustpkg-local-repos, r=catamo…
…rphism r? @graydon rustpkg can now build code from a local git repository. In the case where the local repo is in a directory not in the RUST_PATH, it checks out the repository into a directory in the first workspace in the RUST_PATH. The tests no longer try to connect to github.com, which should solve some of the sporadic failures we've been seeing.
- Loading branch information
Showing
10 changed files
with
378 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
// Utils for working with version control repositories. Just git right now. | ||
|
||
use std::{io, os, run, str}; | ||
use version::*; | ||
|
||
/// For a local git repo | ||
pub fn git_clone(source: &Path, target: &Path, v: &Version) { | ||
assert!(os::path_is_dir(source)); | ||
assert!(is_git_dir(source)); | ||
if !os::path_exists(target) { | ||
let version_args = match v { | ||
&ExactRevision(ref s) => ~[~"--branch", s.to_owned()], | ||
_ => ~[] | ||
}; | ||
debug!("Running: git clone %s %s %s", version_args.to_str(), source.to_str(), | ||
target.to_str()); | ||
let outp = run::process_output("git", ~[~"clone"] + version_args + | ||
~[source.to_str(), target.to_str()]); | ||
if outp.status != 0 { | ||
io::println(str::from_bytes_owned(outp.output.clone())); | ||
io::println(str::from_bytes_owned(outp.error)); | ||
fail!("Couldn't `git clone` %s", source.to_str()); | ||
} | ||
} | ||
else { | ||
// Pull changes | ||
debug!("Running: git --work-tree=%s --git-dir=%s pull --no-edit %s", | ||
target.to_str(), target.push(".git").to_str(), source.to_str()); | ||
let outp = run::process_output("git", [fmt!("--work-tree=%s", target.to_str()), | ||
fmt!("--git-dir=%s", target.push(".git").to_str()), | ||
~"pull", ~"--no-edit", source.to_str()]); | ||
assert!(outp.status == 0); | ||
} | ||
} | ||
|
||
pub fn is_git_dir(p: &Path) -> bool { | ||
os::path_is_dir(&p.push(".git")) | ||
} |
Oops, something went wrong.