Skip to content

Commit

Permalink
Keep existing package with git install
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisduerr committed Jan 19, 2020
1 parent e137ee6 commit 483ad7c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 15 deletions.
7 changes: 0 additions & 7 deletions src/cargo/core/workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -833,13 +833,6 @@ impl<'cfg> Workspace<'cfg> {
pub fn set_target_dir(&mut self, target_dir: Filesystem) {
self.target_dir = Some(target_dir);
}

// TODO: This seems like the wrong approach
pub fn set_package(&mut self, package: Package) {
let key = self.current_manifest.parent().unwrap();
let package = MaybePackage::Package(package);
self.packages.packages.insert(key.to_path_buf(), package);
}
}

impl<'cfg> Packages<'cfg> {
Expand Down
19 changes: 11 additions & 8 deletions src/cargo/ops/cargo_install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,27 +215,30 @@ fn install_one(
Some(Filesystem::new(config.cwd().join("target-install")))
};

let mut git_package = None;
let mut ws = match overidden_target_dir {
Some(dir) => Workspace::ephemeral(pkg, config, Some(dir), false)?,
None => {
let mut ws = Workspace::new(pkg.manifest_path(), config)?;
ws.set_require_optional_deps(false);

// Use tempdir to build git depedencies to prevent bloat in cargo cache
if source_id.is_git() && config.target_dir()?.is_none() {
match TempFileBuilder::new().prefix("cargo-install").tempdir() {
Ok(td) => ws.set_target_dir(Filesystem::new(td.path().to_owned())),
// If tempfile creation fails, write to cargo cache but clean up afterwards
Err(_) => needs_cleanup = true,
if source_id.is_git() {
if config.target_dir()?.is_none() {
match TempFileBuilder::new().prefix("cargo-install").tempdir() {
Ok(td) => ws.set_target_dir(Filesystem::new(td.path().to_owned())),
// If tempfile creation fails, write to cargo cache but clean up afterwards
Err(_) => needs_cleanup = true,
}
}
git_package = Some(&pkg);
}
ws.set_package(pkg);

ws
}
},
};
ws.set_ignore_lock(config.lock_update_allowed());
let pkg = ws.current()?;
let pkg = git_package.map_or_else(|| ws.current(), |pkg| Ok(pkg))?;

if from_cwd {
if pkg.manifest().edition() == Edition::Edition2015 {
Expand Down

0 comments on commit 483ad7c

Please sign in to comment.