File tree Expand file tree Collapse file tree 1 file changed +26
-1
lines changed Expand file tree Collapse file tree 1 file changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -1094,7 +1094,7 @@ impl GitChain {
10941094 // .arg("rev-parse")
10951095 // .arg(format!("{}^{{tree}}", branch_name))
10961096 // .output()
1097- // .unwrap_or_else(|_| panic!("Unable to get tree id of branch {}", branch_name.bold()));
1097+ // .unwrap_or_else(|_| panic!("Unable to get tree id of branch {}", branch_name.bold()))) ;
10981098
10991099 // if output.status.success() {
11001100 // let raw_output = String::from_utf8(output.stdout).unwrap();
@@ -2255,6 +2255,31 @@ impl GitChain {
22552255 & chain. branches [ i - 1 ] . branch_name
22562256 } ;
22572257
2258+ // Check for existing open PRs for the branch
2259+ let output = Command :: new ( "gh" )
2260+ . arg ( "pr" )
2261+ . arg ( "list" )
2262+ . arg ( "--head" )
2263+ . arg ( & branch. branch_name )
2264+ . arg ( "--json" )
2265+ . arg ( "url" )
2266+ . output ( ) ;
2267+
2268+ match output {
2269+ Ok ( output) if output. status . success ( ) => {
2270+ let stdout = String :: from_utf8_lossy ( & output. stdout ) ;
2271+ let pr_objects: Vec < serde_json:: Value > = serde_json:: from_str ( & stdout) . unwrap_or_default ( ) ;
2272+ if !pr_objects. is_empty ( ) {
2273+ println ! ( "🔗 Open PR already exists for branch {}" , branch. branch_name. bold( ) ) ;
2274+ continue ;
2275+ }
2276+ }
2277+ _ => {
2278+ eprintln ! ( " Failed to check existing PRs for branch {}." , branch. branch_name. bold( ) ) ;
2279+ continue ;
2280+ }
2281+ }
2282+
22582283 let mut gh_command = Command :: new ( "gh" ) ;
22592284 gh_command. arg ( "pr" ) . arg ( "create" ) . arg ( "--base" ) . arg ( base_branch) . arg ( "--head" ) . arg ( & branch. branch_name ) ;
22602285
You can’t perform that action at this time.
0 commit comments