@@ -167,30 +167,41 @@ pr_init <- function(branch) {
167
167
cfg <- github_remote_config(github_get = NA )
168
168
check_for_bad_config(cfg )
169
169
tr <- target_repo(cfg , ask = FALSE )
170
+ online <- is_online(tr $ host )
170
171
171
- maybe_good_configs <- c(" maybe_ours_or_theirs" , " maybe_fork" )
172
- if (cfg $ type %in% maybe_good_configs ) {
172
+ if (! online ) {
173
173
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."
180
177
))
181
- if (ui_github_remote_config_wat( cfg )) {
178
+ if (ui_nah( " Do you want to continue? " )) {
182
179
ui_bullets(c(" x" = " Cancelling." ))
183
180
return (invisible ())
184
181
}
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
+ }
185
197
}
186
198
187
- default_branch <- git_default_branch_(cfg )
199
+ default_branch <- if ( online ) git_default_branch_(cfg ) else guess_local_default_branch( )
188
200
challenge_non_default_branch(
189
201
" Are you sure you want to create a PR branch based on a non-default branch?" ,
190
202
default_branch = default_branch
191
203
)
192
204
193
- online <- is_online(tr $ host )
194
205
if (online ) {
195
206
# this is not pr_pull_source_override() because:
196
207
# a) we may NOT be on default branch (although we probably are)
@@ -213,10 +224,6 @@ pr_init <- function(branch) {
213
224
ui_bullets(c(" v" = " Pulling changes from {.val {remref}}." ))
214
225
git_pull(remref = remref , verbose = FALSE )
215
226
}
216
- } else {
217
- ui_bullets(c(
218
- " !" = " Unable to pull changes for current branch, since we are offline."
219
- ))
220
227
}
221
228
222
229
ui_bullets(c(" v" = " Creating and switching to local branch {.val {branch}}." ))
0 commit comments