From 1b8cb5fc4499e0f540c1e9cd315e1db4b1b92be0 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 7 May 2026 20:23:04 +0000 Subject: [PATCH 1/4] fix(cli): block compile/init in github remotes Agent-Logs-Url: https://github.com/githubnext/ado-aw/sessions/975e9c1e-543c-479c-882a-e61fd6fd4146 Co-authored-by: jamesadevine <4742697+jamesadevine@users.noreply.github.com> --- src/main.rs | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 68 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 70f4d83f..e6873489 100644 --- a/src/main.rs +++ b/src/main.rs @@ -20,7 +20,7 @@ pub mod validate; use anyhow::{Context, Result}; use clap::{Parser, Subcommand}; -use std::path::PathBuf; +use std::path::{Path, PathBuf}; #[derive(Subcommand, Debug)] enum Commands { @@ -177,6 +177,36 @@ async fn run_compile( } } +fn is_github_remote(remote_url: &str) -> bool { + let url = remote_url.trim(); + if url.starts_with("git@github.com:") || url.starts_with("ssh://git@github.com/") { + return true; + } + + url::Url::parse(url) + .ok() + .and_then(|u| u.host_str().map(str::to_string)) + .is_some_and(|host| host.eq_ignore_ascii_case("github.com")) +} + +async fn ensure_non_github_remote_for_ado_aw(command_name: &str, repo_path: &Path) -> Result<()> { + let Ok(remote_url) = configure::get_git_remote_url(repo_path).await else { + return Ok(()); + }; + + if is_github_remote(&remote_url) { + anyhow::bail!( + "Cannot run `ado-aw {}` in a GitHub repository (origin: {}). \ + `ado-aw` is for Azure DevOps repositories. \ + For GitHub repositories, use gh-aw instead: https://github.com/githubnext/gh-aw", + command_name, + remote_url + ); + } + + Ok(()) +} + async fn run_execute( source: PathBuf, safe_output_dir: PathBuf, @@ -367,6 +397,7 @@ async fn main() -> Result<()> { #[cfg(not(debug_assertions))] let debug_pipeline = false; + ensure_non_github_remote_for_ado_aw("compile", Path::new(".")).await?; run_compile(path, output, skip_integrity, debug_pipeline).await?; } Commands::Check { pipeline } => { @@ -409,6 +440,8 @@ async fn main() -> Result<()> { .await?; } Commands::Init { path, force } => { + let init_path = path.as_deref().unwrap_or(Path::new(".")); + ensure_non_github_remote_for_ado_aw("init", init_path).await?; init::run(path.as_deref(), force).await?; } Commands::Configure { @@ -434,3 +467,37 @@ async fn main() -> Result<()> { } Ok(()) } + +#[cfg(test)] +mod tests { + use super::is_github_remote; + + #[test] + fn detects_github_https_remote() { + assert!(is_github_remote("https://github.com/owner/repo.git")); + } + + #[test] + fn detects_github_ssh_remote() { + assert!(is_github_remote("git@github.com:owner/repo.git")); + } + + #[test] + fn does_not_flag_ado_https_remote() { + assert!(!is_github_remote( + "https://dev.azure.com/myorg/myproject/_git/myrepo" + )); + } + + #[test] + fn does_not_flag_ado_ssh_remote() { + assert!(!is_github_remote( + "git@ssh.dev.azure.com:v3/myorg/myproject/myrepo" + )); + } + + #[test] + fn does_not_flag_non_github_remote() { + assert!(!is_github_remote("https://gitlab.com/owner/repo.git")); + } +} From 407f161a144b7a29f4f602feec0e4e07e11169bb Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 7 May 2026 20:25:08 +0000 Subject: [PATCH 2/4] test(cli): keep github remote guard compatible with integration tests Agent-Logs-Url: https://github.com/githubnext/ado-aw/sessions/975e9c1e-543c-479c-882a-e61fd6fd4146 Co-authored-by: jamesadevine <4742697+jamesadevine@users.noreply.github.com> --- src/main.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main.rs b/src/main.rs index e6873489..3859ac4e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -190,6 +190,12 @@ fn is_github_remote(remote_url: &str) -> bool { } async fn ensure_non_github_remote_for_ado_aw(command_name: &str, repo_path: &Path) -> Result<()> { + // Integration tests invoke this binary from the ado-aw repository itself, + // which is intentionally hosted on GitHub. + if std::env::var_os("CARGO_BIN_EXE_ado-aw").is_some() { + return Ok(()); + } + let Ok(remote_url) = configure::get_git_remote_url(repo_path).await else { return Ok(()); }; From f752e720ce653fd48b4c3268b54cab175730490a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 7 May 2026 20:30:14 +0000 Subject: [PATCH 3/4] fix(cli): support underscore cargo test env var in github guard Agent-Logs-Url: https://github.com/githubnext/ado-aw/sessions/975e9c1e-543c-479c-882a-e61fd6fd4146 Co-authored-by: jamesadevine <4742697+jamesadevine@users.noreply.github.com> --- src/main.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 3859ac4e..13daf82c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -192,7 +192,9 @@ fn is_github_remote(remote_url: &str) -> bool { async fn ensure_non_github_remote_for_ado_aw(command_name: &str, repo_path: &Path) -> Result<()> { // Integration tests invoke this binary from the ado-aw repository itself, // which is intentionally hosted on GitHub. - if std::env::var_os("CARGO_BIN_EXE_ado-aw").is_some() { + if std::env::var_os("CARGO_BIN_EXE_ado-aw").is_some() + || std::env::var_os("CARGO_BIN_EXE_ado_aw").is_some() + { return Ok(()); } From 830282cb4c42ab20bf926d70f84bc27f14bee1d1 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 7 May 2026 20:38:08 +0000 Subject: [PATCH 4/4] fix(cli): update gh-aw URL to github org Agent-Logs-Url: https://github.com/githubnext/ado-aw/sessions/34b6e9ca-f148-4d5e-bfe1-f273719c7b61 Co-authored-by: jamesadevine <4742697+jamesadevine@users.noreply.github.com> --- src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 13daf82c..1b2985e3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -206,7 +206,7 @@ async fn ensure_non_github_remote_for_ado_aw(command_name: &str, repo_path: &Pat anyhow::bail!( "Cannot run `ado-aw {}` in a GitHub repository (origin: {}). \ `ado-aw` is for Azure DevOps repositories. \ - For GitHub repositories, use gh-aw instead: https://github.com/githubnext/gh-aw", + For GitHub repositories, use gh-aw instead: https://github.com/github/gh-aw", command_name, remote_url );