[-] Remove legacy features

This commit is contained in:
2026-05-09 17:41:20 +00:00
parent f3c0b90a0d
commit 10c55062eb
14 changed files with 107 additions and 200 deletions
-2
View File
@@ -66,8 +66,6 @@ pub struct MirrorConfig {
#[serde(default)]
pub visibility: Visibility,
#[serde(default)]
pub allow_force: bool,
#[serde(default)]
pub conflict_resolution: ConflictResolutionStrategy,
}
+2 -43
View File
@@ -166,7 +166,6 @@ impl GitMirror {
pub fn branch_decisions(
&self,
remotes: &[RemoteSpec],
allow_force: bool,
) -> Result<(Vec<BranchDecision>, Vec<BranchConflict>)> {
let mut by_branch: BTreeMap<String, Vec<(String, String)>> = BTreeMap::new();
for remote in remotes {
@@ -218,20 +217,6 @@ impl GitMirror {
source_remotes,
target_remotes,
});
} else if allow_force {
let winner = self.newest_commit(unique.iter())?;
let source_remotes = tips
.iter()
.filter_map(|(remote, sha)| (sha == &winner).then_some(remote))
.cloned()
.collect::<Vec<_>>();
let target_remotes = missing_remotes(&all_remote_names, &source_remotes);
decisions.push(BranchDecision {
branch,
sha: winner,
source_remotes,
target_remotes,
});
} else {
conflicts.push(BranchConflict { branch, tips });
}
@@ -286,22 +271,13 @@ impl GitMirror {
Ok((decisions, conflicts))
}
pub fn push_branches(
&self,
remotes: &[RemoteSpec],
branches: &[BranchDecision],
force: bool,
) -> Result<()> {
pub fn push_branches(&self, remotes: &[RemoteSpec], branches: &[BranchDecision]) -> Result<()> {
for remote in remotes {
for branch in branches {
if !branch.target_remotes.contains(&remote.name) {
continue;
}
let refspec = if force {
format!("+{}:refs/heads/{}", branch.sha, branch.branch)
} else {
format!("{}:refs/heads/{}", branch.sha, branch.branch)
};
let refspec = format!("{}:refs/heads/{}", branch.sha, branch.branch);
crate::logln!(
" {} {} {} {}",
style("push").green().bold(),
@@ -533,23 +509,6 @@ impl GitMirror {
Ok(None)
}
fn newest_commit<'a>(&self, shas: impl Iterator<Item = &'a String>) -> Result<String> {
let mut newest: Option<(i64, String)> = None;
for sha in shas {
let timestamp = self
.output(["show", "-s", "--format=%ct", sha])?
.trim()
.parse::<i64>()?;
match &newest {
Some((old, _)) if *old >= timestamp => {}
_ => newest = Some((timestamp, sha.clone())),
}
}
newest
.map(|(_, sha)| sha)
.context("no commits found while choosing force winner")
}
fn merge_base(&self, left: &str, right: &str) -> Result<String> {
Ok(self.output(["merge-base", left, right])?.trim().to_string())
}
-1
View File
@@ -126,7 +126,6 @@ fn add_sync_group_styled(config: &mut Config, theme: &ColorfulTheme) -> Result<(
repo_blacklist: repo_filters.blacklist,
create_missing: true,
visibility: Visibility::Private,
allow_force: false,
conflict_resolution,
});
prompt_webhook_setup_styled(config, theme)?;
+5 -15
View File
@@ -49,24 +49,18 @@ struct SyncCommand {
group: Option<String>,
#[arg(long)]
dry_run: bool,
/// Do not create repositories that are missing from an endpoint.
#[arg(long)]
no_create: bool,
#[arg(long)]
force: bool,
#[arg(long, value_name = "REGEX")]
repo_pattern: Option<String>,
/// Sync only repositories that failed during the previous non-dry-run sync.
#[arg(long)]
retry_failed: bool,
#[arg(long, value_name = "PATH")]
work_dir: Option<PathBuf>,
}
#[derive(Args, Debug)]
struct ServeCommand {
#[arg(long, default_value = "127.0.0.1:8787", value_name = "HOST:PORT")]
listen: String,
#[arg(long, value_name = "PATH")]
work_dir: Option<PathBuf>,
}
#[derive(Subcommand, Debug)]
@@ -96,8 +90,6 @@ struct WebhookUpdateCommand {
url: String,
#[arg(long)]
dry_run: bool,
#[arg(long, value_name = "PATH")]
work_dir: Option<PathBuf>,
}
fn main() -> Result<()> {
@@ -127,11 +119,9 @@ fn main() -> Result<()> {
group: command.group,
dry_run: command.dry_run,
create_missing_override: command.no_create.then_some(false),
force_override: command.force.then_some(true),
repo_pattern: command.repo_pattern,
retry_failed: command.retry_failed,
work_dir: command.work_dir,
jobs: config.jobs,
..SyncOptions::default()
},
)
}
@@ -154,7 +144,7 @@ fn main() -> Result<()> {
listen: command.listen,
secret,
workers,
work_dir: command.work_dir,
work_dir: None,
full_sync_interval_minutes,
reachability_url,
reachability_check_interval_minutes,
@@ -206,7 +196,7 @@ fn main() -> Result<()> {
new_url: command.url.clone(),
secret,
dry_run: command.dry_run,
work_dir: command.work_dir,
work_dir: None,
jobs: config.jobs,
},
)?;
+3 -8
View File
@@ -41,7 +41,6 @@ pub struct SyncOptions {
pub group: Option<String>,
pub dry_run: bool,
pub create_missing_override: Option<bool>,
pub force_override: Option<bool>,
pub repo_pattern: Option<String>,
pub retry_failed: bool,
pub work_dir: Option<PathBuf>,
@@ -54,7 +53,6 @@ impl Default for SyncOptions {
group: None,
dry_run: false,
create_missing_override: None,
force_override: None,
repo_pattern: None,
retry_failed: false,
work_dir: None,
@@ -97,7 +95,7 @@ pub fn sync_all(config: &Config, options: SyncOptions) -> Result<()> {
.as_deref()
.map(Regex::new)
.transpose()
.with_context(|| "invalid --repo-pattern regex")?;
.with_context(|| "invalid repository filter regex")?;
let retry_failed_repos = if options.retry_failed {
Some(load_failure_state(&work_dir)?.repos_by_group())
} else {
@@ -163,7 +161,6 @@ fn sync_group(
.options
.create_missing_override
.unwrap_or(mirror.create_missing);
let allow_force = context.options.force_override.unwrap_or(mirror.allow_force);
let repo_filter = mirror.repo_filter()?;
let all_endpoint_repos = list_group_repos(context.config, mirror, &repo_filter)?;
@@ -283,7 +280,6 @@ fn sync_group(
work_dir,
redactor: redactor.clone(),
dry_run,
allow_force,
};
let result = sync_repo(
&repo_context,
@@ -511,7 +507,6 @@ struct RepoSyncContext<'a> {
work_dir: &'a Path,
redactor: Redactor,
dry_run: bool,
allow_force: bool,
}
#[derive(Default)]
@@ -890,7 +885,7 @@ fn push_repo_refs(
fail_on_unresolved_conflict(context, "branch deletion conflict")?;
}
let (branches, conflicts) = mirror_repo.branch_decisions(remotes, context.allow_force)?;
let (branches, conflicts) = mirror_repo.branch_decisions(remotes)?;
let branches_to_push = branches
.into_iter()
.filter(|branch| !is_internal_conflict_branch(&branch.branch))
@@ -992,7 +987,7 @@ fn push_repo_refs(
}
if !branches_to_push.is_empty() {
print_branch_decisions(&branches_to_push);
mirror_repo.push_branches(remotes, &branches_to_push, context.allow_force)?;
mirror_repo.push_branches(remotes, &branches_to_push)?;
close_resolved_pull_requests(context, mirror_repo, remotes, repos, &pushed_branch_names)?;
}
if !rebased_branch_updates.is_empty() {