diff --git a/Cargo.lock b/Cargo.lock index 2f70d286694..e4882091c9d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -35,7 +35,7 @@ dependencies = [ [[package]] name = "encoding" version = "0.1.0" -source = "git+https://github.com/lifthrasiir/rust-encoding#15de58b9cb1fb5998aa6217e794d557eaf80a31f" +source = "git+https://github.com/lifthrasiir/rust-encoding#35f0d70f65f73ba16f296f9ec675eddee661ba79" [[package]] name = "flate2" @@ -99,6 +99,6 @@ name = "url" version = "0.1.0" source = "git+https://github.com/servo/rust-url#bb68de835ad945a72fba44979944a587ba83941a" dependencies = [ - "encoding 0.1.0 (git+https://github.com/lifthrasiir/rust-encoding#15de58b9cb1fb5998aa6217e794d557eaf80a31f)", + "encoding 0.1.0 (git+https://github.com/lifthrasiir/rust-encoding#35f0d70f65f73ba16f296f9ec675eddee661ba79)", ] diff --git a/src/bin/new.rs b/src/bin/new.rs index c2e56945aa1..7511746c04c 100644 --- a/src/bin/new.rs +++ b/src/bin/new.rs @@ -17,6 +17,7 @@ Options: --no-git Don't initialize a new git repository --git Initialize a new git repository, overriding a global `git = false` configuration + --travis Create a .travis.yml file --bin Use a binary instead of a library template -v, --verbose Use verbose output ") @@ -25,11 +26,12 @@ pub fn execute(options: Options, shell: &mut MultiShell) -> CliResult debug!("executing; cmd=cargo-new; args={}", os::args()); shell.set_verbose(options.flag_verbose); - let Options { flag_no_git, flag_bin, arg_path, flag_git, .. } = options; + let Options { flag_no_git, flag_travis, flag_bin, arg_path, flag_git, .. } = options; let opts = ops::NewOptions { no_git: flag_no_git, git: flag_git, + travis: flag_travis, path: arg_path.as_slice(), bin: flag_bin, }; diff --git a/src/cargo/core/source.rs b/src/cargo/core/source.rs index 1a92b6052d0..1335293c3ab 100644 --- a/src/cargo/core/source.rs +++ b/src/cargo/core/source.rs @@ -291,14 +291,14 @@ impl<'a> SourceMap<'a> { let source = self.map.find(id); source.map(|s| { - let s: &Source+'a = *s; + let s: &Source+'a = &**s; s }) } pub fn get_mut(&mut self, id: &SourceId) -> Option<&mut Source+'a> { self.map.find_mut(id).map(|s| { - let s: &mut Source+'a = *s; + let s: &mut Source+'a = &mut **s; s }) } @@ -320,7 +320,7 @@ impl<'a> SourceMap<'a> { } pub fn sources_mut(&'a mut self) -> SourcesMut<'a> { - self.map.mut_iter().map(|(_, v)| { let s: &mut Source+'a = *v; s }) + self.map.mut_iter().map(|(_, v)| { let s: &mut Source+'a = &mut **v; s }) } } diff --git a/src/cargo/ops/cargo_new.rs b/src/cargo/ops/cargo_new.rs index 85a60c5ae8d..d74e381e1d8 100644 --- a/src/cargo/ops/cargo_new.rs +++ b/src/cargo/ops/cargo_new.rs @@ -9,6 +9,7 @@ use core::shell::MultiShell; pub struct NewOptions<'a> { pub no_git: bool, pub git: bool, + pub travis: bool, pub bin: bool, pub path: &'a str, } @@ -56,6 +57,10 @@ fn mk(path: &Path, name: &str, opts: &NewOptions) -> CargoResult<()> { (None, None, name, None) => name, }; + if opts.travis { + try!(File::create(&path.join(".travis.yml")).write_str("language: rust\n")); + } + try!(File::create(&path.join("Cargo.toml")).write_str(format!( r#"[package] diff --git a/src/cargo/util/errors.rs b/src/cargo/util/errors.rs index a33ca305c47..e4f7c92877f 100644 --- a/src/cargo/util/errors.rs +++ b/src/cargo/util/errors.rs @@ -197,7 +197,7 @@ impl CargoError for ProcessError { } fn cause(&self) -> Option<&CargoError> { - self.cause.as_ref().map(|c| { let err: &CargoError = *c; err }) + self.cause.as_ref().map(|c| { let err: &CargoError = &**c; err }) } fn with_cause(mut self, @@ -230,7 +230,7 @@ impl CargoError for ConcreteCargoError { } fn cause(&self) -> Option<&CargoError> { - self.cause.as_ref().map(|c| { let err: &CargoError = *c; err }) + self.cause.as_ref().map(|c| { let err: &CargoError = &**c; err }) } fn with_cause(mut self, diff --git a/tests/test_cargo_new.rs b/tests/test_cargo_new.rs index dd469649391..47a3f6e6b48 100644 --- a/tests/test_cargo_new.rs +++ b/tests/test_cargo_new.rs @@ -66,6 +66,20 @@ test!(simple_git { execs().with_status(0)); }) +test!(simple_travis { + os::setenv("USER", "foo"); + assert_that(cargo_process("new").arg("foo").arg("--travis"), + execs().with_status(0)); + + assert_that(&paths::root().join("foo"), existing_dir()); + assert_that(&paths::root().join("foo/Cargo.toml"), existing_file()); + assert_that(&paths::root().join("foo/src/lib.rs"), existing_file()); + assert_that(&paths::root().join("foo/.travis.yml"), existing_file()); + + assert_that(cargo_process("build").cwd(paths::root().join("foo")), + execs().with_status(0)); +}) + test!(no_argument { assert_that(cargo_process("new"), execs().with_status(1)