@@ -36,7 +36,9 @@ git_fetch <- function(
3636) {
3737 repo <- git_open(repo )
3838 info <- git_info(repo )
39- if (! length(remote )) remote <- info $ remote
39+ if (! length(remote )) {
40+ remote <- info $ remote
41+ }
4042 remote <- as.character(remote )
4143 if (! length(remote ) || is.na(remote )) {
4244 if (is.na(match(" origin" , git_remote_list(repo = repo )$ name ))) {
@@ -77,7 +79,9 @@ git_remote_ls <- function(
7779) {
7880 repo <- git_open(repo )
7981 info <- git_info(repo )
80- if (! length(remote )) remote <- info $ remote
82+ if (! length(remote )) {
83+ remote <- info $ remote
84+ }
8185 remote <- as.character(remote )
8286 if (! length(remote ) || is.na(remote )) {
8387 if (is.na(match(" origin" , git_remote_list(repo = repo )$ name ))) {
@@ -115,7 +119,9 @@ git_push <- function(
115119 info <- git_info(repo )
116120 verbose <- as.logical(verbose )
117121
118- if (! length(remote )) remote <- info $ remote
122+ if (! length(remote )) {
123+ remote <- info $ remote
124+ }
119125
120126 remote <- as.character(remote )
121127
@@ -136,17 +142,22 @@ git_push <- function(
136142 refs <- refs [! grepl(" ^refs/pull" , refs )]
137143 refspec <- paste0(refs , " :" , refs )
138144 }
139- if (! length(refspec )) refspec <- info $ head
145+ if (! length(refspec )) {
146+ refspec <- info $ head
147+ }
140148 refspec <- as.character(refspec )
141- if (isTRUE(force )) refspec <- sub(" ^\\ +?" , " +" , refspec )
149+ if (isTRUE(force )) {
150+ refspec <- sub(" ^\\ +?" , " +" , refspec )
151+ }
142152
143153 host <- remote_to_host(repo , remote )
144154 key_cb <- make_key_cb(ssh_key , host = host , password = password )
145155 cred_cb <- make_cred_cb(password = password , verbose = verbose )
146156
147157 .Call(R_git_remote_push , repo , remote , refspec , key_cb , cred_cb , verbose )
148- if (is.null(set_upstream ))
158+ if (is.null(set_upstream )) {
149159 set_upstream <- isTRUE(is.na(info $ upstream )) && ! isTRUE(info $ bare )
160+ }
150161
151162 if (isTRUE(set_upstream )) {
152163 git_branch_set_upstream(paste0(remote , " /" , info $ shorthand ), repo = repo )
@@ -207,7 +218,9 @@ git_clone <- function(
207218 verbose = interactive()
208219) {
209220 stopifnot(is.character(url ))
210- if (! length(path )) path <- file.path(getwd(), basename(url ))
221+ if (! length(path )) {
222+ path <- file.path(getwd(), basename(url ))
223+ }
211224 stopifnot(is.character(path ))
212225 stopifnot(is.null(branch ) || is.character(branch ))
213226 verbose <- as.logical(verbose )
@@ -238,16 +251,19 @@ git_pull <- function(remote = NULL, rebase = FALSE, ..., repo = '.') {
238251 repo <- git_open(repo )
239252 info <- git_info(repo )
240253 branch <- info $ shorthand
241- if (branch == " HEAD" ) stop(" Repository is currently in a detached head state" )
254+ if (branch == " HEAD" ) {
255+ stop(" Repository is currently in a detached head state" )
256+ }
242257
243258 upstream <- if (length(remote ) && nchar(remote )) {
244259 paste0(remote , ' /' , branch )
245260 } else {
246261 info $ upstream
247262 }
248263
249- if (! length(upstream ) || is.na(upstream ) || ! nchar(upstream ))
264+ if (! length(upstream ) || is.na(upstream ) || ! nchar(upstream )) {
250265 stop(" No upstream configured for current branch, please specify a remote" )
266+ }
251267
252268 if (grepl(" .*/pr/\\ d+$" , upstream )) {
253269 pr <- utils :: tail(strsplit(upstream , ' /pr/' , fixed = TRUE )[[1 ]], 1 )
@@ -257,13 +273,15 @@ git_pull <- function(remote = NULL, rebase = FALSE, ..., repo = '.') {
257273 inform(" Local upstream, skipping fetch" )
258274 } else {
259275 git_fetch(remote , ... , repo = repo )
260- if (! git_branch_exists(upstream , local = FALSE , repo = repo ))
276+ if (! git_branch_exists(upstream , local = FALSE , repo = repo )) {
261277 stop(" Failed to fetch upstream branch: " , upstream )
278+ }
262279 }
263280 if (isTRUE(rebase )) {
264281 rebase_df <- git_rebase_list(upstream = upstream , repo = repo )
265- if (any(rebase_df $ conflicts ))
282+ if (any(rebase_df $ conflicts )) {
266283 stop(" Found conflicts, rebase not possible. Retry with rebase = FALSE" )
284+ }
267285 git_rebase_commit(upstream = upstream , repo = repo )
268286 } else {
269287 git_merge(upstream , repo = repo )
0 commit comments