Skip to content

Commit

Permalink
Auto merge of #1885 - alexcrichton:update-deps, r=alexcrichton
Browse files Browse the repository at this point in the history
* Picks up a few breaking changes to dependency APIs, notably the tar-rs changes
  and git2-rs changes.
* Builds should now work with VS 2015
  • Loading branch information
bors committed Aug 14, 2015
2 parents 1f24be7 + 530e1d1 commit dd3f0a7
Show file tree
Hide file tree
Showing 15 changed files with 166 additions and 132 deletions.
7 changes: 5 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ branches:

addons:
apt:
sources:
- kalakris-cmake
packages:
- g++-multilib
- lib32stdc++6
- cmake
- g++-multilib
- lib32stdc++6
173 changes: 93 additions & 80 deletions Cargo.lock

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,19 @@ docopt = "0.6"
env_logger = "0.3"
filetime = "0.1"
flate2 = "0.2"
git2 = "0.2"
git2-curl = "0.2"
git2 = "0.3"
git2-curl = "0.3"
glob = "0.2"
kernel32-sys = "0.1"
libc = "0.1"
libgit2-sys = "0.2"
libgit2-sys = "0.3"
log = "0.3"
num_cpus = "0.2"
regex = "0.1"
crates-io = { path = "src/crates-io", version = "0.1" }
rustc-serialize = "0.3"
semver = "0.1"
tar = { version = "0.2", features = ["nightly"] }
tar = "0.3"
term = "0.2"
threadpool = "0.1"
time = "0.1"
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ install:
build: false

test_script:
- cargo test
- cargo test -- --nocapture

branches:
only:
Expand Down
2 changes: 1 addition & 1 deletion src/cargo/ops/cargo_package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ fn tar(pkg: &Package, src: &PathSource, config: &Config,
}));
let path = format!("{}-{}{}{}", pkg.name(), pkg.version(),
path::MAIN_SEPARATOR, relative);
try!(ar.append(&path, &mut file).chain_error(|| {
try!(ar.append_file(&path, &mut file).chain_error(|| {
internal(format!("could not archive source file `{}`", relative))
}));
}
Expand Down
43 changes: 26 additions & 17 deletions src/cargo/sources/git/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,13 @@ impl GitRemote {
let repo = match git2::Repository::open(into) {
Ok(repo) => {
try!(self.fetch_into(&repo).chain_error(|| {
internal(format!("failed to fetch into {}", into.display()))
human(format!("failed to fetch into {}", into.display()))
}));
repo
}
Err(..) => {
try!(self.clone_into(into).chain_error(|| {
internal(format!("failed to clone into: {}", into.display()))
human(format!("failed to clone into: {}", into.display()))
}))
}
};
Expand Down Expand Up @@ -365,11 +365,21 @@ fn with_authentication<T, F>(url: &str, cfg: &git2::Config, mut f: F)
//
// * After the above two have failed, we just kinda grapple attempting to
// return *something*.
//
// Note that we keep track of the number of times we've called this callback
// because libgit2 will repeatedly give us credentials until we give it a
// reason to not do so. If we've been called once and our credentials failed
// then we'll be called again, and in this case we assume that the reason
// was because the credentials were wrong.
let mut cred_helper = git2::CredentialHelper::new(url);
cred_helper.config(cfg);
let mut cred_error = false;
let ret = f(&mut |url, username, allowed| {
let creds = if allowed.contains(git2::SSH_KEY) ||
let mut called = 0;
let res = f(&mut |url, username, allowed| {
called += 1;
if called >= 2 {
return Err(git2::Error::from_str("no authentication available"))
}
if allowed.contains(git2::SSH_KEY) ||
allowed.contains(git2::USERNAME) {
let user = username.map(|s| s.to_string())
.or_else(|| cred_helper.username.clone())
Expand All @@ -385,16 +395,14 @@ fn with_authentication<T, F>(url: &str, cfg: &git2::Config, mut f: F)
git2::Cred::default()
} else {
Err(git2::Error::from_str("no authentication available"))
};
cred_error = creds.is_err();
creds
}
});
if cred_error {
ret.chain_error(|| {
human("Failed to authenticate when downloading repository")
if called > 0 {
res.chain_error(|| {
human("failed to authenticate when downloading repository")
})
} else {
ret
res
}
}

Expand All @@ -404,11 +412,12 @@ pub fn fetch(repo: &git2::Repository, url: &str,

with_authentication(url, &try!(repo.config()), |f| {
let mut cb = git2::RemoteCallbacks::new();
cb.credentials(|a, b, c| f(a, b, c));
let mut remote = try!(repo.remote_anonymous(&url, Some(refspec)));
try!(remote.add_fetch("refs/tags/*:refs/tags/*"));
remote.set_callbacks(cb);
try!(remote.fetch(&["refs/tags/*:refs/tags/*", refspec], None));
cb.credentials(f);
let mut remote = try!(repo.remote_anonymous(&url));
let mut opts = git2::FetchOptions::new();
opts.remote_callbacks(cb)
.download_tags(git2::AutotagOption::All);
try!(remote.fetch(&[refspec], Some(&mut opts), None));
Ok(())
})
}
2 changes: 1 addition & 1 deletion src/rustversion.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2015-07-22
2015-08-13
5 changes: 2 additions & 3 deletions tests/support/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,9 @@ pub fn add_submodule<'a>(repo: &'a git2::Repository, url: &str,
let path = path.to_str().unwrap().replace(r"\", "/");
let mut s = repo.submodule(url, Path::new(&path), false).unwrap();
let subrepo = s.open().unwrap();
subrepo.remote_add_fetch("origin", "refs/heads/*:refs/heads/*").unwrap();
let mut origin = subrepo.find_remote("origin").unwrap();
origin.add_fetch("refs/heads/*:refs/heads/*").unwrap();
origin.fetch(&[], None).unwrap();
origin.save().unwrap();
origin.fetch(&[], None, None).unwrap();
subrepo.checkout_head(None).unwrap();
s.add_finalize().unwrap();
return s;
Expand Down
8 changes: 4 additions & 4 deletions tests/support/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ pub fn mock_archive(name: &str, version: &str, deps: &[(&str, &str, &str)]) {
fs::create_dir_all(dst.parent().unwrap()).unwrap();
let f = File::create(&dst).unwrap();
let a = Archive::new(GzEncoder::new(f, Default));
a.append(&format!("{}-{}/Cargo.toml", name, version),
&mut File::open(&p.root().join("Cargo.toml")).unwrap()).unwrap();
a.append(&format!("{}-{}/src/lib.rs", name, version),
&mut File::open(&p.root().join("src/lib.rs")).unwrap()).unwrap();
a.append_file(&format!("{}-{}/Cargo.toml", name, version),
&mut File::open(&p.root().join("Cargo.toml")).unwrap()).unwrap();
a.append_file(&format!("{}-{}/src/lib.rs", name, version),
&mut File::open(&p.root().join("src/lib.rs")).unwrap()).unwrap();
a.finish().unwrap();
}

Expand Down
15 changes: 9 additions & 6 deletions tests/test_cargo_build_auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ test!(http_auth_offered {
assert_eq!(req, vec![
"GET /foo/bar/info/refs?service=git-upload-pack HTTP/1.1",
"Accept: */*",
"User-Agent: git/1.0 (libgit2 0.22.0)",
"User-Agent: git/1.0 (libgit2 0.23.0)",
].into_iter().map(|s| s.to_string()).collect());
drop(s);

Expand All @@ -55,7 +55,7 @@ test!(http_auth_offered {
"GET /foo/bar/info/refs?service=git-upload-pack HTTP/1.1",
"Authorization: Basic Zm9vOmJhcg==",
"Accept: */*",
"User-Agent: git/1.0 (libgit2 0.22.0)",
"User-Agent: git/1.0 (libgit2 0.23.0)",
].into_iter().map(|s| s.to_string()).collect());
});

Expand Down Expand Up @@ -93,7 +93,7 @@ test!(http_auth_offered {
"#, addr.port()))
.file("src/main.rs", "");

assert_that(p.cargo_process("build").arg("-v"),
assert_that(p.cargo_process("build"),
execs().with_status(101).with_stdout(&format!("\
{updating} git repository `http://{addr}/foo/bar`
",
Expand All @@ -107,7 +107,9 @@ Caused by:
failed to clone into: [..]
Caused by:
[..] status code: 401
failed to authenticate when downloading repository
To learn more, run the command again with --verbose.
",
addr = addr)));

Expand Down Expand Up @@ -152,8 +154,9 @@ Caused by:
",
addr = addr,
errmsg = if cfg!(windows) {
"[[..]] failed to send request: The connection with the server \
was terminated abnormally\n"
"[[..]] failed to send request: [..]\n"
} else if cfg!(target_os = "macos") {
"[[..]] unexpected return value from ssl handshake [..]"
} else {
"[[..]] SSL error: [..]"
})));
Expand Down
3 changes: 2 additions & 1 deletion tests/test_cargo_compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1780,7 +1780,8 @@ test!(rustc_env_var {
Could not execute process `rustc-that-does-not-exist -vV` ([..])
Caused by:
[..]".to_string() + if cfg!(windows) {"\n[..]\n"} else {"\n"}));
[..]
"));
assert_that(&p.bin("a"), is_not(existing_file()));
});

Expand Down
9 changes: 5 additions & 4 deletions tests/test_cargo_compile_git_deps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -921,11 +921,12 @@ test!(dep_with_changed_submodule {
sub.sync().unwrap();
{
let subrepo = sub.open().unwrap();
subrepo.remote_add_fetch("origin",
"refs/heads/*:refs/heads/*").unwrap();
subrepo.remote_set_url("origin",
&git_project3.url().to_string()).unwrap();
let mut origin = subrepo.find_remote("origin").unwrap();
origin.set_url(&git_project3.url().to_string()).unwrap();
origin.add_fetch("refs/heads/*:refs/heads/*").unwrap();;
origin.fetch(&[], None).unwrap();
origin.save().unwrap();
origin.fetch(&[], None, None).unwrap();
let id = subrepo.refname_to_id("refs/remotes/origin/master").unwrap();
let obj = subrepo.find_object(id, None).unwrap();
subrepo.reset(&obj, git2::ResetType::Hard, None).unwrap();
Expand Down
6 changes: 4 additions & 2 deletions tests/test_cargo_doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,8 @@ test!(doc_same_name {
test!(doc_target {
const TARGET: &'static str = "arm-unknown-linux-gnueabihf";

if !::is_nightly() { return }

let p = project("foo")
.file("Cargo.toml", r#"
[package]
Expand All @@ -274,8 +276,8 @@ test!(doc_target {
authors = []
"#)
.file("src/lib.rs", r#"
#![feature(no_std)]
#![no_std]
#![feature(no_core)]
#![no_core]
extern {
pub static A: u32;
Expand Down
10 changes: 6 additions & 4 deletions tests/test_cargo_package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,11 @@ src[..]main.rs
let ar = Archive::new(Cursor::new(contents));
for f in ar.files().unwrap() {
let f = f.unwrap();
let fname = f.filename_bytes();
let fname = f.header().path_bytes();
let fname = &*fname;
assert!(fname == b"foo-0.0.1/Cargo.toml" ||
fname == b"foo-0.0.1/src/main.rs",
"unexpected filename: {:?}", f.filename())
"unexpected filename: {:?}", f.header().path())
}
});

Expand Down Expand Up @@ -363,9 +364,10 @@ src[..]main.rs
let ar = Archive::new(Cursor::new(contents));
for f in ar.files().unwrap() {
let f = f.unwrap();
let fname = f.filename_bytes();
let fname = f.header().path_bytes();
let fname = &*fname;
assert!(fname == b"nested-0.0.1/Cargo.toml" ||
fname == b"nested-0.0.1/src/main.rs",
"unexpected filename: {:?}", f.filename())
"unexpected filename: {:?}", f.header().path())
}
});
5 changes: 3 additions & 2 deletions tests/test_cargo_publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,11 @@ test!(simple {
let ar = Archive::new(inner);
for file in ar.files().unwrap() {
let file = file.unwrap();
let fname = file.filename_bytes();
let fname = file.header().path_bytes();
let fname = &*fname;
assert!(fname == b"foo-0.0.1/Cargo.toml" ||
fname == b"foo-0.0.1/src/main.rs",
"unexpected filename: {:?}", file.filename())
"unexpected filename: {:?}", file.header().path());
}
});

Expand Down

0 comments on commit dd3f0a7

Please sign in to comment.