Skip to content

Commit

Permalink
Error early when name cannot be derived from repo url
Browse files Browse the repository at this point in the history
  • Loading branch information
eikek committed Jul 18, 2024
1 parent cc024bf commit 66f6a2e
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/cli/cmd/project/clone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ pub enum Error {

#[snafu(display("Error creating config file: {}", source))]
RenkuConfig { source: ProjectConfigError },

#[snafu(display("The project name is missing: {}", repo_url))]
MissingProjectName { repo_url: String },
}

impl Input {
Expand Down Expand Up @@ -142,9 +145,11 @@ async fn clone_repository(
dir: Arc<PathBuf>,
) -> Result<(), Error> {
let name = match repo_url.rsplit_once('/') {
Some((_, n)) => n,
None => "no-name",
};
Some((_, n)) => Ok(n),
None => Err(Error::MissingProjectName {
repo_url: repo_url.clone(),
}),
}?;
let local_path = dir.join(name);
if local_path.exists() {
ctx.write_err(&SimpleMessage {
Expand Down

0 comments on commit 66f6a2e

Please sign in to comment.