Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion src/bin/new.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
")
Expand All @@ -25,11 +26,12 @@ pub fn execute(options: Options, shell: &mut MultiShell) -> CliResult<Option<()>
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,
};
Expand Down
6 changes: 3 additions & 3 deletions src/cargo/core/source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
}
Expand All @@ -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 })
}
}

Expand Down
5 changes: 5 additions & 0 deletions src/cargo/ops/cargo_new.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down Expand Up @@ -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]

Expand Down
4 changes: 2 additions & 2 deletions src/cargo/util/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<E: CargoError + Send>(mut self,
Expand Down Expand Up @@ -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<E: CargoError + Send>(mut self,
Expand Down
14 changes: 14 additions & 0 deletions tests/test_cargo_new.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down