@@ -10,8 +10,8 @@ use anyhow::{anyhow, bail};
10
10
use colored:: Colorize as _;
11
11
12
12
use crate :: git_high_level;
13
- use crate :: github_api :: { self , Branch , Remote , RemoteBranch } ;
14
- use crate :: utils:: { display_link , with_uuid} ;
13
+ use crate :: github :: { self , Branch , Remote , RemoteBranch } ;
14
+ use crate :: utils:: { format_pr , format_url , with_uuid} ;
15
15
use crate :: { commands, confirm_prompt, git} ;
16
16
17
17
/// Backup for a file
@@ -23,7 +23,7 @@ struct FileBackup {
23
23
}
24
24
25
25
/// Run patchy, if `yes` then there will be no prompt
26
- pub async fn run ( yes : bool ) -> anyhow:: Result < ( ) > {
26
+ pub async fn run ( yes : bool , use_gh_cli : bool ) -> anyhow:: Result < ( ) > {
27
27
let root = config:: ROOT . as_str ( ) ;
28
28
29
29
let Ok ( config_string) = fs:: read_to_string ( & * config:: FILE_PATH ) else {
@@ -140,7 +140,7 @@ pub async fn run(yes: bool) -> anyhow::Result<()> {
140
140
if config. pull_requests . is_empty ( ) && config. branches . is_empty ( ) {
141
141
log:: warn!(
142
142
"You haven't specified any pull requests or branches to fetch in your config, {}" ,
143
- display_link (
143
+ format_url (
144
144
"see the instructions on how to configure patchy." ,
145
145
"https://github.com/nik-rev/patchy?tab=readme-ov-file#config"
146
146
)
@@ -157,13 +157,17 @@ pub async fn run(yes: bool) -> anyhow::Result<()> {
157
157
} in & config. pull_requests
158
158
{
159
159
// TODO: refactor this to not use such deep nesting
160
- let Ok ( ( response, info) ) =
161
- github_api:: fetch_pull_request ( & config. repo , * pull_request, None , commit. as_ref ( ) )
162
- . await
163
- . inspect_err ( |err| {
164
- log:: error!( "failed to fetch branch from remote:\n {err}" ) ;
165
- } )
166
- else {
160
+ let Ok ( ( response, info) ) = github:: fetch_pull_request (
161
+ & config. repo ,
162
+ * pull_request,
163
+ None ,
164
+ commit. as_ref ( ) ,
165
+ use_gh_cli,
166
+ )
167
+ . await
168
+ . inspect_err ( |err| {
169
+ log:: error!( "failed to fetch branch from remote:\n {err}" ) ;
170
+ } ) else {
167
171
continue ;
168
172
} ;
169
173
@@ -179,16 +183,7 @@ pub async fn run(yes: bool) -> anyhow::Result<()> {
179
183
180
184
log:: info!(
181
185
"Merged pull request {}" ,
182
- display_link(
183
- & format!(
184
- "{}{}{}{}" ,
185
- "#" . bright_blue( ) ,
186
- pull_request. to_string( ) . bright_blue( ) ,
187
- " " . bright_blue( ) ,
188
- & response. title. bright_blue( ) . italic( )
189
- ) ,
190
- & response. html_url
191
- ) ,
186
+ format_pr( * pull_request, & response. title, & response. html_url) ,
192
187
) ;
193
188
}
194
189
@@ -197,9 +192,12 @@ pub async fn run(yes: bool) -> anyhow::Result<()> {
197
192
let owner = & remote. owner ;
198
193
let repo = & remote. repo ;
199
194
let branch = & remote. branch ;
200
- let Ok ( ( _, info) ) = github_api:: fetch_branch ( remote) . await . inspect_err ( |err| {
201
- log:: error!( "failed to fetch branch {owner}/{repo}/{branch}: {err}" ) ;
202
- } ) else {
195
+ let Ok ( ( _, info) ) = github:: fetch_branch ( remote, use_gh_cli)
196
+ . await
197
+ . inspect_err ( |err| {
198
+ log:: error!( "failed to fetch branch {owner}/{repo}/{branch}: {err}" ) ;
199
+ } )
200
+ else {
203
201
continue ;
204
202
} ;
205
203
0 commit comments