Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/commands/pr_github/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}

Expand Down
9 changes: 7 additions & 2 deletions tests/commands/pr_github.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ fn pr_github_invokes_gh_with_expected_arguments() -> Result<(), Box<dyn Error>>
.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",
Expand All @@ -104,7 +105,10 @@ fn pr_github_invokes_gh_with_expected_arguments() -> Result<(), Box<dyn Error>>
])
.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
Expand Down Expand Up @@ -211,7 +215,7 @@ fn install_stub_gh() -> Result<StubGh, Box<dyn Error>> {
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)]
{
Expand All @@ -232,3 +236,4 @@ fn install_stub_gh() -> Result<StubGh, Box<dyn Error>> {
log_path: gh_log,
})
}