mirror of
https://github.com/orhun/git-cliff.git
synced 2024-11-25 13:22:17 +03:00
fix(remote): avoid setting multiple remotes (#885)
This commit is contained in:
parent
a5786bea61
commit
a344c68238
@ -146,6 +146,29 @@ pub struct RemoteConfig {
|
||||
pub bitbucket: Remote,
|
||||
}
|
||||
|
||||
impl RemoteConfig {
|
||||
/// Returns `true` if any remote is set.
|
||||
pub fn is_any_set(&self) -> bool {
|
||||
#[cfg(feature = "github")]
|
||||
if self.github.is_set() {
|
||||
return true;
|
||||
}
|
||||
#[cfg(feature = "gitlab")]
|
||||
if self.gitlab.is_set() {
|
||||
return true;
|
||||
}
|
||||
#[cfg(feature = "gitea")]
|
||||
if self.gitea.is_set() {
|
||||
return true;
|
||||
}
|
||||
#[cfg(feature = "bitbucket")]
|
||||
if self.bitbucket.is_set() {
|
||||
return true;
|
||||
}
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
/// A single remote.
|
||||
#[derive(Debug, Default, Clone, Serialize, Deserialize)]
|
||||
pub struct Remote {
|
||||
|
@ -123,52 +123,33 @@ fn process_repository<'a>(
|
||||
count && !ignore
|
||||
});
|
||||
|
||||
if !config.remote.github.is_set() {
|
||||
if !config.remote.is_any_set() {
|
||||
match repository.upstream_remote() {
|
||||
Ok(remote) => {
|
||||
debug!("No GitHub remote is set, using remote: {}", remote);
|
||||
config.remote.github.owner = remote.owner;
|
||||
config.remote.github.repo = remote.repo;
|
||||
config.remote.github.is_custom = remote.is_custom;
|
||||
if !config.remote.github.is_set() {
|
||||
debug!("No GitHub remote is set, using remote: {}", remote);
|
||||
config.remote.github.owner = remote.owner;
|
||||
config.remote.github.repo = remote.repo;
|
||||
config.remote.github.is_custom = remote.is_custom;
|
||||
} else if !config.remote.gitlab.is_set() {
|
||||
debug!("No GitLab remote is set, using remote: {}", remote);
|
||||
config.remote.gitlab.owner = remote.owner;
|
||||
config.remote.gitlab.repo = remote.repo;
|
||||
config.remote.gitlab.is_custom = remote.is_custom;
|
||||
} else if !config.remote.gitea.is_set() {
|
||||
debug!("No Gitea remote is set, using remote: {}", remote);
|
||||
config.remote.gitea.owner = remote.owner;
|
||||
config.remote.gitea.repo = remote.repo;
|
||||
config.remote.gitea.is_custom = remote.is_custom;
|
||||
} else if !config.remote.bitbucket.is_set() {
|
||||
debug!("No Bitbucket remote is set, using remote: {}", remote);
|
||||
config.remote.bitbucket.owner = remote.owner;
|
||||
config.remote.bitbucket.repo = remote.repo;
|
||||
config.remote.bitbucket.is_custom = remote.is_custom;
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
debug!("Failed to get remote from GitHub repository: {:?}", e);
|
||||
}
|
||||
}
|
||||
} else if !config.remote.gitlab.is_set() {
|
||||
match repository.upstream_remote() {
|
||||
Ok(remote) => {
|
||||
debug!("No GitLab remote is set, using remote: {}", remote);
|
||||
config.remote.gitlab.owner = remote.owner;
|
||||
config.remote.gitlab.repo = remote.repo;
|
||||
config.remote.gitlab.is_custom = remote.is_custom;
|
||||
}
|
||||
Err(e) => {
|
||||
debug!("Failed to get remote from GitLab repository: {:?}", e);
|
||||
}
|
||||
}
|
||||
} else if !config.remote.gitea.is_set() {
|
||||
match repository.upstream_remote() {
|
||||
Ok(remote) => {
|
||||
debug!("No Gitea remote is set, using remote: {}", remote);
|
||||
config.remote.gitea.owner = remote.owner;
|
||||
config.remote.gitea.repo = remote.repo;
|
||||
config.remote.gitea.is_custom = remote.is_custom;
|
||||
}
|
||||
Err(e) => {
|
||||
debug!("Failed to get remote from Gitea repository: {:?}", e);
|
||||
}
|
||||
}
|
||||
} else if !config.remote.bitbucket.is_set() {
|
||||
match repository.upstream_remote() {
|
||||
Ok(remote) => {
|
||||
debug!("No Bitbucket remote is set, using remote: {}", remote);
|
||||
config.remote.bitbucket.owner = remote.owner;
|
||||
config.remote.bitbucket.repo = remote.repo;
|
||||
config.remote.bitbucket.is_custom = remote.is_custom;
|
||||
}
|
||||
Err(e) => {
|
||||
debug!("Failed to get remote from Bitbucket repository: {:?}", e);
|
||||
debug!("Failed to get remote from repository: {:?}", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user