diff --git a/src/commands/pr_github/mod.rs b/src/commands/pr_github/mod.rs index 1f1a4a7..ae344f2 100644 --- a/src/commands/pr_github/mod.rs +++ b/src/commands/pr_github/mod.rs @@ -192,6 +192,14 @@ where let branch_label = format_with_color(branch, |text| format!("{}", text.magenta().bold())); println!("GitHub pull request created for `{}`.", branch_label); + if let Some(pr_link) = output + .stdout + .lines() + .map(str::trim) + .find(|line| !line.is_empty()) + { + println!("{}", pr_link); + } Ok(()) } diff --git a/tests/commands/pr_github.rs b/tests/commands/pr_github.rs index 8bc39d6..6ba9c42 100644 --- a/tests/commands/pr_github.rs +++ b/tests/commands/pr_github.rs @@ -90,6 +90,7 @@ fn pr_github_invokes_gh_with_expected_arguments() -> Result<(), Box> .current_dir(repo_dir.path()) .env("PATH", &stub.path_value) .env("GH_LOG", &stub.log_path) + .env("GH_STDOUT", "https://example.com/pulls/42") .args([ "pr-github", "feature/test", @@ -104,7 +105,10 @@ fn pr_github_invokes_gh_with_expected_arguments() -> Result<(), Box> ]) .assert() .success() - .stdout(predicate::str::contains("GitHub pull request created")); + .stdout( + predicate::str::contains("GitHub pull request created") + .and(predicate::str::contains("\nhttps://example.com/pulls/42")), + ); let log_contents = fs::read_to_string(&stub.log_path)?; let worktree_path = repo_dir @@ -211,7 +215,7 @@ fn install_stub_gh() -> Result> { let gh_path = stub_dir.path().join("gh"); fs::write( &gh_path, - "#! /bin/sh\n\nprintf '%s\n' \"$PWD\" > \"$GH_LOG\"\nprintf 'args:%s\n' \"$*\" >> \"$GH_LOG\"\n", + "#! /bin/sh\n\nprintf '%s\n' \"$PWD\" > \"$GH_LOG\"\nprintf 'args:%s\n' \"$*\" >> \"$GH_LOG\"\n\nif [ -n \"${GH_STDOUT:-}\" ]; then\n printf '%s\n' \"$GH_STDOUT\"\nfi\n", )?; #[cfg(unix)] { @@ -232,3 +236,4 @@ fn install_stub_gh() -> Result> { log_path: gh_log, }) } +