11//! `run` subcommand
22
3- use crate :: config:: { Config , Ref } ;
3+ use crate :: config:: { BranchName , Config , PullRequest } ;
44use std:: ffi:: OsString ;
55use std:: fs:: { self , File } ;
66use std:: io:: Write as _;
@@ -51,8 +51,8 @@ pub async fn run(yes: bool) -> anyhow::Result<()> {
5151 anyhow ! ( "Could not parse `{root}/{CONFIG_FILE}` configuration file:\n {err}" , )
5252 } ) ?;
5353
54- let Ref {
55- item : remote_branch,
54+ let crate :: config :: Branch {
55+ name : remote_branch,
5656 commit,
5757 } = config. remote_branch ;
5858
@@ -103,7 +103,8 @@ pub async fn run(yes: bool) -> anyhow::Result<()> {
103103 } ,
104104 branch : Branch {
105105 upstream_branch_name : remote_branch. clone ( ) ,
106- local_branch_name : with_uuid ( & remote_branch) ,
106+ local_branch_name : BranchName :: try_new ( with_uuid ( remote_branch. as_ref ( ) ) )
107+ . expect ( "adding UUID to branch name does not invalidate it" ) ,
107108 } ,
108109 } ;
109110
@@ -128,14 +129,14 @@ pub async fn run(yes: bool) -> anyhow::Result<()> {
128129 // TODO: make this concurrent, see https://users.rust-lang.org/t/processing-subprocesses-concurrently/79638/3
129130 // Git cannot handle multiple threads executing commands in the same repository,
130131 // so we can't use threads, but we can run processes in the background
131- for Ref {
132- item : pull_request,
132+ for PullRequest {
133+ number : pull_request,
133134 commit,
134135 } in & config. pull_requests
135136 {
136137 // TODO: refactor this to not use such deep nesting
137138 let Ok ( ( response, info) ) =
138- git:: fetch_pull_request ( & config. repo , pull_request, None , commit. as_ref ( ) )
139+ git:: fetch_pull_request ( & config. repo , * pull_request, None , commit. as_ref ( ) )
139140 . await
140141 . inspect_err ( |err| {
141142 log:: error!( "failed to fetch branch from remote:\n {err}" ) ;
@@ -145,7 +146,7 @@ pub async fn run(yes: bool) -> anyhow::Result<()> {
145146 } ;
146147
147148 if let Err ( err) =
148- git:: merge_pull_request ( & info, pull_request, & response. title , & response. html_url )
149+ git:: merge_pull_request ( & info, * pull_request, & response. title , & response. html_url )
149150 {
150151 log:: error!( "failed to merge {pull_request}: {err}" ) ;
151152 continue ;
@@ -157,7 +158,7 @@ pub async fn run(yes: bool) -> anyhow::Result<()> {
157158 & format!(
158159 "{}{}{}{}" ,
159160 "#" . bright_blue( ) ,
160- pull_request. bright_blue( ) ,
161+ pull_request. to_string ( ) . bright_blue( ) ,
161162 " " . bright_blue( ) ,
162163 & response. title. bright_blue( ) . italic( )
163164 ) ,
@@ -188,7 +189,7 @@ pub async fn run(yes: bool) -> anyhow::Result<()> {
188189 "Merged branch {}/{}/{} {}" ,
189190 owner. bright_blue( ) ,
190191 repo. bright_blue( ) ,
191- branch. bright_blue( ) ,
192+ branch. as_ref ( ) . bright_blue( ) ,
192193 remote
193194 . commit
194195 . as_ref( )
@@ -274,7 +275,7 @@ pub async fn run(yes: bool) -> anyhow::Result<()> {
274275 if yes
275276 || confirm_prompt ! (
276277 "Overwrite branch {}? This is irreversible." ,
277- config. local_branch. cyan( )
278+ config. local_branch. as_ref ( ) . cyan( )
278279 )
279280 {
280281 // forcefully renames the branch we are currently on into the branch specified
@@ -285,12 +286,12 @@ pub async fn run(yes: bool) -> anyhow::Result<()> {
285286 "--move" ,
286287 "--force" ,
287288 & temporary_branch,
288- & config. local_branch ,
289+ config. local_branch . as_ref ( ) ,
289290 ] ) ?;
290291 if yes {
291292 log:: info!(
292293 "Automatically overwrote branch {} since you supplied the {} flag" ,
293- config. local_branch. cyan( ) ,
294+ config. local_branch. as_ref ( ) . cyan( ) ,
294295 "--yes" . bright_magenta( )
295296 ) ;
296297 }
@@ -304,7 +305,7 @@ pub async fn run(yes: bool) -> anyhow::Result<()> {
304305 ) ;
305306 log:: info!(
306307 "You can still manually overwrite {} with:\n {overwrite_command}\n " ,
307- config. local_branch. cyan( ) ,
308+ config. local_branch. as_ref ( ) . cyan( ) ,
308309 ) ;
309310
310311 Ok ( ( ) )
0 commit comments