From eab22bd5d56bf91ee0edfc7156023c159c7f65f9 Mon Sep 17 00:00:00 2001 From: Shaun Hamilton Date: Fri, 13 Oct 2023 12:02:44 +0200 Subject: [PATCH 1/2] fix: set binary name for completions --- src/plumbing/main.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/plumbing/main.rs b/src/plumbing/main.rs index 9cbedce83fd..a8fe18f39ec 100644 --- a/src/plumbing/main.rs +++ b/src/plumbing/main.rs @@ -1221,13 +1221,17 @@ pub fn main() -> Result<()> { }, Subcommands::Completions { shell, out_dir } => { let mut app = Args::command(); + + let bin_name = "gix"; + app.set_bin_name(bin_name); + let shell = shell .or_else(clap_complete::Shell::from_env) .ok_or_else(|| anyhow!("The shell could not be derived from the environment"))?; if let Some(out_dir) = out_dir { - clap_complete::generate_to(shell, &mut app, env!("CARGO_PKG_NAME"), &out_dir)?; + clap_complete::generate_to(shell, &mut app, bin_name, &out_dir)?; } else { - clap_complete::generate(shell, &mut app, env!("CARGO_PKG_NAME"), &mut std::io::stdout()); + clap_complete::generate(shell, &mut app, bin_name, &mut std::io::stdout()); } Ok(()) } From 7f2bc08e5713758c6188428221aac518cc6ecf2f Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Fri, 13 Oct 2023 13:19:30 +0200 Subject: [PATCH 2/2] refactor Don't hard-code a name that is already set elesewhere. Reuse it instead. --- src/plumbing/main.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/plumbing/main.rs b/src/plumbing/main.rs index a8fe18f39ec..94b085dd85e 100644 --- a/src/plumbing/main.rs +++ b/src/plumbing/main.rs @@ -1222,12 +1222,11 @@ pub fn main() -> Result<()> { Subcommands::Completions { shell, out_dir } => { let mut app = Args::command(); - let bin_name = "gix"; - app.set_bin_name(bin_name); - let shell = shell .or_else(clap_complete::Shell::from_env) .ok_or_else(|| anyhow!("The shell could not be derived from the environment"))?; + + let bin_name = app.get_name().to_owned(); if let Some(out_dir) = out_dir { clap_complete::generate_to(shell, &mut app, bin_name, &out_dir)?; } else {