refactor: remove legacy deprecated macros (#583)

This commit is contained in:
SteveLauC
2023-10-18 11:13:14 +08:00
committed by GitHub
parent cd380a53b3
commit e1754707d8
4 changed files with 182 additions and 208 deletions

View File

@@ -33,6 +33,7 @@ pub enum GitAction {
Pull,
}
#[derive(Debug)]
pub struct Repositories<'a> {
git: &'a Git,
pull_repositories: HashSet<String>,
@@ -387,14 +388,27 @@ impl<'a> Repositories<'a> {
}
}
/// Return true if `pull_repos` and `push_repos` are both empty.
pub fn is_empty(&self) -> bool {
self.pull_repositories.is_empty() && self.push_repositories.is_empty()
}
// The following 2 functions are `#[cfg(unix)]` because they are only used in
// the `oh-my-zsh` step, which is UNIX-only.
#[cfg(unix)]
pub fn remove(&mut self, path: &str) {
/// Return true if `pull_repos` is empty.
pub fn pull_is_empty(&self) -> bool {
self.pull_repositories.is_empty()
}
#[cfg(unix)]
/// Remove `path` from `pull_repos`
///
/// # Panic
/// Will panic if `path` is not in the `pull_repos` under a debug build.
pub fn remove_from_pull(&mut self, path: &str) {
let _removed = self.pull_repositories.remove(path);
let _removed = self.push_repositories.remove(path);
debug_assert!(_removed);
}
}

View File

@@ -230,8 +230,8 @@ pub fn run_oh_my_zsh(ctx: &ExecutionContext) -> Result<()> {
custom_repos.insert_if_repo(entry.path(), crate::steps::git::GitAction::Pull);
}
custom_repos.remove(&oh_my_zsh.to_string_lossy());
if !custom_repos.is_empty() {
custom_repos.remove_from_pull(&oh_my_zsh.to_string_lossy());
if !custom_repos.pull_is_empty() {
println!("Pulling custom plugins and themes");
ctx.git().multi_pull(&custom_repos, ctx)?;
}