Skip to content

Commit 9c85873

Browse files
committed
chore: replace "forking" with "mirroring"
1 parent b863cb8 commit 9c85873

File tree

2 files changed

+26
-26
lines changed

2 files changed

+26
-26
lines changed

rust/patchable/src/main.rs

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,10 @@ enum Cmd {
150150
#[clap(long)]
151151
base: String,
152152

153-
/// Assume a fork exists at stackabletech/<repo_name> and push the base ref to it.
154-
/// The fork URL will be stored in patchable.toml instead of the original upstream.
153+
/// Assume a mirror exists at stackabletech/<repo_name> and push the base ref to it.
154+
/// The mirror URL will be stored in patchable.toml instead of the original upstream.
155155
#[clap(long)]
156-
forked: bool,
156+
mirrored: bool,
157157
},
158158

159159
/// Shows the patch directory for a given product version
@@ -204,10 +204,10 @@ pub enum Error {
204204

205205
#[snafu(display("failed to parse upstream URL {url:?} to extract repository name"))]
206206
ParseUpstreamUrl { url: String },
207-
#[snafu(display("failed to add temporary fork remote for {url:?}"))]
208-
AddForkRemote { source: git2::Error, url: String },
209-
#[snafu(display("failed to push commit {commit} (as {refspec}) to fork {url:?}"))]
210-
PushToFork {
207+
#[snafu(display("failed to add temporary mirror remote for {url:?}"))]
208+
AddMirrorRemote { source: git2::Error, url: String },
209+
#[snafu(display("failed to push commit {commit} (as {refspec}) to mirror {url:?}"))]
210+
PushToMirror {
211211
source: git2::Error,
212212
url: String,
213213
refspec: String,
@@ -423,7 +423,7 @@ fn main() -> Result<()> {
423423
pv,
424424
upstream,
425425
base,
426-
forked,
426+
mirrored,
427427
} => {
428428
let ctx = ProductVersionContext {
429429
pv,
@@ -442,14 +442,14 @@ fn main() -> Result<()> {
442442
// so that it cannot be changed under our feet (without us knowing so, anyway...).
443443
tracing::info!(?base, "resolving base commit-ish");
444444

445-
let (base_commit, upstream) = if forked {
445+
let (base_commit, upstream) = if mirrored {
446446
// Parse e.g. "https://github.com/apache/druid.git" into "druid"
447447
let repo_name = upstream.split('/').last().map(|repo| repo.trim_end_matches(".git")).context(ParseUpstreamUrlSnafu { url: &upstream })?;
448448

449449
ensure!(!repo_name.is_empty(), ParseUpstreamUrlSnafu { url: &upstream });
450450

451-
let fork_url = format!("https://github.com/stackabletech/{}.git", repo_name);
452-
tracing::info!(%fork_url, "using fork repository");
451+
let mirror_url = format!("https://github.com/stackabletech/{}.git", repo_name);
452+
tracing::info!(%mirror_url, "using mirror repository");
453453

454454
// Fetch from original upstream using a temporary remote name
455455
tracing::info!(upstream = upstream, %base, "fetching base ref from original upstream");
@@ -462,14 +462,14 @@ fn main() -> Result<()> {
462462

463463
tracing::info!(commit = %base_commit_oid, "fetched base commit OID");
464464

465-
// Add fork remote
466-
let temp_fork_remote = "patchable_fork_push";
467-
let mut fork_remote = product_repo
468-
.remote(temp_fork_remote, &fork_url)
469-
.context(AddForkRemoteSnafu { url: fork_url.clone() })?;
465+
// Add mirror remote
466+
let temp_mirror_remote = "patchable_mirror_push";
467+
let mut mirror_remote = product_repo
468+
.remote(temp_mirror_remote, &mirror_url)
469+
.context(AddMirrorRemoteSnafu { url: mirror_url.clone() })?;
470470

471-
// Push the base commit to the fork
472-
tracing::info!(commit = %base_commit_oid, base = base, url = fork_url, "pushing commit to fork");
471+
// Push the base commit to the mirror
472+
tracing::info!(commit = %base_commit_oid, base = base, url = mirror_url, "pushing commit to mirror");
473473
let mut callbacks = git2::RemoteCallbacks::new();
474474
callbacks.credentials(|_url, username_from_url, _allowed_types| {
475475
git2::Cred::credential_helper(
@@ -510,20 +510,20 @@ fn main() -> Result<()> {
510510

511511
tracing::info!(refspec = refspec, "constructed push refspec");
512512

513-
fork_remote
513+
mirror_remote
514514
.push(&[&refspec], Some(&mut push_options))
515-
.context(PushToForkSnafu {
516-
url: fork_url.clone(),
515+
.context(PushToMirrorSnafu {
516+
url: mirror_url.clone(),
517517
refspec: &refspec,
518518
commit: base_commit_oid,
519519
})?;
520520

521-
product_repo.remote_delete(temp_fork_remote)
522-
.context(DeleteRemoteSnafu { name: temp_fork_remote.to_string() })?;
521+
product_repo.remote_delete(temp_mirror_remote)
522+
.context(DeleteRemoteSnafu { name: temp_mirror_remote.to_string() })?;
523523

524-
tracing::info!("successfully pushed base ref to fork");
524+
tracing::info!("successfully pushed base ref to mirror");
525525

526-
(base_commit_oid, fork_url)
526+
(base_commit_oid, mirror_url)
527527
} else {
528528
(repo::resolve_and_fetch_commitish(&product_repo, &base, &upstream).context(FetchBaseCommitSnafu)?, upstream)
529529
};

rust/patchable/src/repo.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ pub fn resolve_and_fetch_commitish(
181181
Some(
182182
FetchOptions::new()
183183
// Tags need to be present to later determine whether `commitish` is a tag or not
184-
// Patchable needs to know this when initializing a repository with the `--forked` option (to construct the refspec)
184+
// Patchable needs to know this when initializing a repository with the `--mirrored` option (to construct the refspec)
185185
.download_tags(git2::AutotagOption::Auto)
186186
.remote_callbacks(callbacks)
187187
// TODO: could be 1, CLI option maybe?

0 commit comments

Comments
 (0)