diff options
author | Lars Wirzenius <liw@liw.fi> | 2024-01-27 17:58:17 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2024-01-27 17:58:17 +0200 |
commit | 3a3273827450350773ff60d434b7d7c22f691eaa (patch) | |
tree | 399b053b583c5c501ae2cd6b5c4ded2cc7ebb2d7 | |
parent | 88eec281b8ae41fdd3074a5b764e5114741eedf4 (diff) | |
download | ambient-driver-3a3273827450350773ff60d434b7d7c22f691eaa.tar.gz |
feat: have a per-project dependencies directory
Signed-off-by: Lars Wirzenius <liw@liw.fi>
Sponsored-by: author
-rw-r--r-- | src/action.rs | 2 | ||||
-rw-r--r-- | src/project.rs | 5 | ||||
-rw-r--r-- | src/run.rs | 7 |
3 files changed, 11 insertions, 3 deletions
diff --git a/src/action.rs b/src/action.rs index 7669a2c..142edc4 100644 --- a/src/action.rs +++ b/src/action.rs @@ -101,7 +101,7 @@ fn dput_action(state: &State, run: &RunCommand) -> Result<(), ActionError> { } fn cargo_fetch(project: &Project, state: &State) -> Result<(), ActionError> { - let cargo_home = state.statedir().join("dependencies"); // FIXME: hardcoded pathname + let cargo_home = state.dependenciesdir(); // FIXME: hardcoded pathname if !cargo_home.exists() { std::fs::create_dir(&cargo_home).map_err(|e| ActionError::Mkdir(cargo_home.clone(), e))?; } diff --git a/src/project.rs b/src/project.rs index d7dbdb7..8dd9c0d 100644 --- a/src/project.rs +++ b/src/project.rs @@ -188,6 +188,11 @@ impl State { self.statedir.join("cache") } + /// Return dependencies directory for a project. + pub fn dependenciesdir(&self) -> PathBuf { + self.statedir.join("dependencies") + } + /// Return latest commit that CI has run on. pub fn latest_commit(&self) -> Option<&str> { self.latest_commit.as_deref() @@ -37,10 +37,8 @@ fn cmd_run(config: &EffectiveConfig, run: &RunCommand) -> Result<(), RunError> { }; let statedir = config.stored_config().state().ok_or(RunError::NoState)?; - let dependencies = statedir.join("dependencies"); // FIXME hardcoded pathname if !statedir.exists() { mkdir(statedir)?; - mkdir(&dependencies)?; } for (name, project) in chosen(run, &projects) { @@ -57,6 +55,11 @@ fn cmd_run(config: &EffectiveConfig, run: &RunCommand) -> Result<(), RunError> { mkdir(&cachedir)?; } + let dependencies = state.dependenciesdir(); + if !dependencies.exists() { + mkdir(&dependencies)?; + } + debug!("Executing pre-plan steps"); for action in project.pre_plan() { action.execute(project, &state)?; |