rustpkg: Don't assume a non-numeric refspec is a tag

Just pass it directly to git, without prefixing it with tags/
This commit is contained in:
Tim Chevalier 2013-07-26 12:31:53 -07:00
parent bfac584a03
commit c8780511b9
2 changed files with 10 additions and 3 deletions

View File

@ -10,7 +10,8 @@
// Utils for working with version control repositories. Just git right now.
use std::{io, os, run, str};
use std::{os, run, str};
use std::run::{ProcessOutput, ProcessOptions, Process};
use version::*;
/// For a local git repo
@ -47,7 +48,7 @@ pub fn git_clone_general(source: &str, target: &Path, v: &Version) -> bool {
else {
match v {
&ExactRevision(ref s) | &Tagged(ref s) => {
let outp = run::process_output_in_cwd("git", [~"checkout", fmt!("tags/%s", *s)],
let outp = process_output_in_cwd("git", [~"checkout", fmt!("%s", *s)],
target);
if outp.status != 0 {
debug!(str::from_bytes_owned(outp.output.clone()));
@ -63,6 +64,12 @@ pub fn git_clone_general(source: &str, target: &Path, v: &Version) -> bool {
}
}
fn process_output_in_cwd(prog: &str, args: &[~str], cwd: &Path) -> ProcessOutput {
let mut prog = Process::new(prog, args, ProcessOptions{ dir: Some(cwd)
,..ProcessOptions::new()});
prog.finish_with_output()
}
pub fn is_git_dir(p: &Path) -> bool {
os::path_is_dir(&p.push(".git"))
}

View File

@ -1029,6 +1029,6 @@ fn test_non_numeric_tag() {
"test_pkg", "testbranch_only"]);
let file2 = repo.push_many(["mockgithub.com", "catamorphism", "test_pkg",
"master_only"]);
assert!(os::path_exists(&file1));'
assert!(os::path_exists(&file1));
assert!(!os::path_exists(&file2));
}