@@ -50,6 +50,7 @@ def update_demo(
5050 demo_name : str = get_demo_name (add_rust_extension = add_rust_extension )
5151 demo_path : Path = demos_cache_folder / demo_name
5252
53+ typer .secho (f"template:\n \t current_branch: { get_current_branch ()} \n \t current_commit: { get_current_commit ()} " )
5354 if branch_override is not None :
5455 typer .secho (f"Overriding current branch name for demo reference. Using '{ branch_override } ' instead." )
5556 desired_branch_name : str = branch_override
@@ -76,6 +77,7 @@ def update_demo(
7677
7778 typer .secho (f"Updating demo project at { demo_path = } ." , fg = "yellow" )
7879 with work_in (demo_path ):
80+ typer .secho (f"demo:\n \t current_branch: { get_current_branch ()} \n \t current_commit: { get_current_commit ()} " )
7981 if get_current_branch () != desired_branch_name :
8082 git ("checkout" , "-b" , desired_branch_name , DEMO .develop_branch )
8183
@@ -146,8 +148,10 @@ def _create_demo_pr(demo_path: Path, branch: str, commit_start: str) -> None:
146148 """Creates a PR to merge the given branch into develop."""
147149 gh ("repo" , "set-default" , f"{ DEMO .app_author } /{ DEMO .app_name } " )
148150 search_results : subprocess .CompletedProcess = gh ("pr" , "list" , "--state" , "open" , "--search" , branch )
149- if "no pull requests match your search" not in search_results .stdout :
150- typer .secho (f"Skipping PR creation due to existing PR found for branch { branch } " )
151+
152+ if search_results .returncode == 0 :
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 } " )
151155 return
152156
153157 body : str = _get_demo_feature_pr_body (demo_path = demo_path , commit_start = commit_start )
@@ -160,6 +164,16 @@ def _create_demo_pr(demo_path: Path, branch: str, commit_start: str) -> None:
160164 "--repo" : f"{ DEMO .app_author } /{ DEMO .app_name } " ,
161165 }
162166 gh ("pr" , "create" , * itertools .chain .from_iterable (pr_kwargs .items ()))
167+ url : str = _get_pr_url (branch = branch )
168+ typer .secho (f"Created PR 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 ()
163177
164178
165179def _get_demo_feature_pr_body (demo_path : Path , commit_start : str ) -> str :
0 commit comments