use git_cmd::Repo;
use release_plz_core::RepoUrl;
use crate::config::Config;
use super::manifest_command::ManifestCommand;
pub trait RepoCommand: ManifestCommand {
fn repo_url(&self) -> Option<&str>;
fn get_repo_url(&self, config: &Config) -> anyhow::Result<RepoUrl> {
match &self.user_repo_url(config) {
Some(url) => RepoUrl::new(url),
None => {
let manifest_path = self.manifest_path();
let project_dir = release_plz_core::manifest_dir(&manifest_path)?;
let repo = Repo::new(project_dir)?;
RepoUrl::from_repo(&repo)
}
}
}
fn user_repo_url<'a>(&'a self, config: &'a Config) -> Option<&str> {
self.repo_url()
.or_else(|| config.workspace.repo_url.as_ref().map(|u| u.as_str()))
}
}