Skip to content

Commit 037f27b

Browse files
committed
feat: add debugging logs marking the location of demo PR's made
1 parent 095e6bf commit 037f27b

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

scripts/update-demo.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,10 @@ def _create_demo_pr(demo_path: Path, branch: str, commit_start: str) -> None:
148148
"""Creates a PR to merge the given branch into develop."""
149149
gh("repo", "set-default", f"{DEMO.app_author}/{DEMO.app_name}")
150150
search_results: subprocess.CompletedProcess = gh("pr", "list", "--state", "open", "--search", branch)
151+
151152
if "no pull requests match your search" not in search_results.stdout:
152-
typer.secho(f"Skipping PR creation due to existing PR found for branch {branch}")
153+
url: str = _get_pr_url(branch=branch)
154+
typer.secho(f"Skipping PR creation due to existing PR found for branch {branch} at {url}")
153155
return
154156

155157
body: str = _get_demo_feature_pr_body(demo_path=demo_path, commit_start=commit_start)
@@ -162,6 +164,16 @@ def _create_demo_pr(demo_path: Path, branch: str, commit_start: str) -> None:
162164
"--repo": f"{DEMO.app_author}/{DEMO.app_name}",
163165
}
164166
gh("pr", "create", *itertools.chain.from_iterable(pr_kwargs.items()))
167+
url: str = _get_pr_url(branch=branch)
168+
typer.secho(f"Created PR URL for branch {branch} at {url}")
169+
170+
171+
def _get_pr_url(branch: str) -> str:
172+
"""Returns the url of the current branch's PR."""
173+
result: subprocess.CompletedProcess = gh("pr", "view", branch, "--json", "url", "--jq", ".url")
174+
if result.returncode != 0:
175+
raise ValueError(f"Failed to find a PR URL for branch {branch}.")
176+
return result.stdout.strip()
165177

166178

167179
def _get_demo_feature_pr_body(demo_path: Path, commit_start: str) -> str:

0 commit comments

Comments
 (0)