Skip to content

armgit / xerj

Public Imported from GitHub
0

AI search engine and MCP server for bots and agents. One Rust binary indexes code, docs, logs, JSONL/CSV and PDFs for BM25 full-text, vector and hybrid search, code search without grep, agent memory and RAG. Elasticsearch-compatible API; Corpus Hub serves hundreds of reference memory corpora.

fix(feedback): fork without gh --remote, add the xerj-fork remote ourselves (#2596)

xerj-org21f2da0a0efd
diff --git a/engine/crates/xerj-autoindex/src/feedback.rs b/engine/crates/xerj-autoindex/src/feedback.rs
index 5362785e8..b1b6bfa54 100644
--- a/engine/crates/xerj-autoindex/src/feedback.rs
+++ b/engine/crates/xerj-autoindex/src/feedback.rs
@@ -439,7 +439,8 @@ pub fn pr_commands(d: &Draft) -> String {
# Run these in a clone of xerj-org/xerj, not in the project you are working in.\n\
git clone https://github.com/xerj-org/xerj.git\n\
cd xerj\n\
- gh repo fork xerj-org/xerj --remote --remote-name xerj-fork\n\
+ gh repo fork xerj-org/xerj --clone=false\n\
+ git remote add xerj-fork https://github.com/YOUR_LOGIN/xerj.git\n\
xerj feedback{agent_line} \\\n\
\x20 --used-for {used_for:?} --pointed-at {pointed_at:?} \\\n\
\x20 --verdict {verdict:?} --numbers {numbers:?} \\\n\
@@ -912,43 +913,55 @@ fn has_push_rights() -> Result<bool, String> {
}
}
-/// `gh repo fork` adds the `xerj-fork` remote. A remote that is already there
-/// is enough — forking twice would fail on the second run.
+/// Make sure the `xerj-fork` remote points at the caller's fork. A remote that
+/// is already there is enough. Recent `gh` releases reject `--remote` when a
+/// repository argument is given (#2596), so fork without it (a no-op when the
+/// fork exists) and add the remote ourselves.
fn ensure_fork(dir: Option<&Path>) -> Result<(), String> {
if git_config_remote_exists(dir) {
return Ok(());
}
- if run_cmd(
+ if !run_cmd(
dir,
"gh",
&[
"repo".into(),
"fork".into(),
"xerj-org/xerj".into(),
- "--remote".into(),
- "--remote-name".into(),
+ "--clone=false".into(),
+ ],
+ ) {
+ return Err("`gh repo fork xerj-org/xerj --clone=false` failed".into());
+ }
+ let login = gh_login()?;
+ if !run_cmd(
+ dir,
+ "git",
+ &[
+ "remote".into(),
+ "add".into(),
"xerj-fork".into(),
+ format!("https://github.com/{login}/xerj.git"),
],
) {
- // A fork that lags main would refuse a push from a shallow clone.
- // Best effort: a failure here shows up as a failed push.
- if let Ok(login) = gh_login() {
- let _ = run_cmd(
- dir,
- "gh",
- &[
- "repo".into(),
- "sync".into(),
- format!("{login}/xerj"),
- "--branch".into(),
- "main".into(),
- ],
- );
- }
- Ok(())
- } else {
- Err("`gh repo fork xerj-org/xerj --remote --remote-name xerj-fork` failed".into())
+ return Err(format!(
+ "`git remote add xerj-fork https://github.com/{login}/xerj.git` failed"
+ ));
}
+ // A fork that lags main would refuse a push from a shallow clone.
+ // Best effort: a failure here shows up as a failed push.
+ let _ = run_cmd(
+ dir,
+ "gh",
+ &[
+ "repo".into(),
+ "sync".into(),
+ format!("{login}/xerj"),
+ "--branch".into(),
+ "main".into(),
+ ],
+ );
+ Ok(())
}
fn git_config_remote_exists(dir: Option<&Path>) -> bool {
@@ -1980,7 +1993,8 @@ mod tests {
let commands = pr_commands(&filled);
for needle in [
"git clone https://github.com/xerj-org/xerj.git",
- "gh repo fork xerj-org/xerj --remote --remote-name xerj-fork",
+ "gh repo fork xerj-org/xerj --clone=false",
+ "git remote add xerj-fork https://github.com/YOUR_LOGIN/xerj.git",
"--agent \"Claude Code\"",
"git push -u xerj-fork field-report/",
"--head YOUR_LOGIN:field-report/",