@@ -167,30 +167,41 @@ pr_init <- function(branch) {
167167 cfg <- github_remote_config(github_get = NA )
168168 check_for_bad_config(cfg )
169169 tr <- target_repo(cfg , ask = FALSE )
170+ online <- is_online(tr $ host )
170171
171- maybe_good_configs <- c(" maybe_ours_or_theirs" , " maybe_fork" )
172- if (cfg $ type %in% maybe_good_configs ) {
172+ if (! online ) {
173173 ui_bullets(c(
174- " x" = ' Unable to confirm the GitHub remote configuration is
175- "pull request ready".' ,
176- " i" = " You probably need to configure a personal access token for
177- {.val {tr$host}}." ,
178- " i" = " See {.run usethis::gh_token_help()} for help with that." ,
179- " i" = " (Or maybe we're just offline?)"
174+ " x" = " You are not currently online." ,
175+ " i" = " You can still create a local branch, but we can't check that your
176+ current branch is up-to-date or setup the remote branch."
180177 ))
181- if (ui_github_remote_config_wat( cfg )) {
178+ if (ui_nah( " Do you want to continue? " )) {
182179 ui_bullets(c(" x" = " Cancelling." ))
183180 return (invisible ())
184181 }
182+ } else {
183+ maybe_good_configs <- c(" maybe_ours_or_theirs" , " maybe_fork" )
184+ if (cfg $ type %in% maybe_good_configs ) {
185+ ui_bullets(c(
186+ " x" = ' Unable to confirm the GitHub remote configuration is
187+ "pull request ready".' ,
188+ " i" = " You probably need to configure a personal access token for
189+ {.val {tr$host}}." ,
190+ " i" = " See {.run usethis::gh_token_help()} for help with that." ,
191+ ))
192+ if (ui_github_remote_config_wat(cfg )) {
193+ ui_bullets(c(" x" = " Cancelling." ))
194+ return (invisible ())
195+ }
196+ }
185197 }
186198
187- default_branch <- git_default_branch_(cfg )
199+ default_branch <- if ( online ) git_default_branch_(cfg ) else guess_local_default_branch( )
188200 challenge_non_default_branch(
189201 " Are you sure you want to create a PR branch based on a non-default branch?" ,
190202 default_branch = default_branch
191203 )
192204
193- online <- is_online(tr $ host )
194205 if (online ) {
195206 # this is not pr_pull_source_override() because:
196207 # a) we may NOT be on default branch (although we probably are)
@@ -213,10 +224,6 @@ pr_init <- function(branch) {
213224 ui_bullets(c(" v" = " Pulling changes from {.val {remref}}." ))
214225 git_pull(remref = remref , verbose = FALSE )
215226 }
216- } else {
217- ui_bullets(c(
218- " !" = " Unable to pull changes for current branch, since we are offline."
219- ))
220227 }
221228
222229 ui_bullets(c(" v" = " Creating and switching to local branch {.val {branch}}." ))
0 commit comments