Skip to content

Commit 7b8efa7

Browse files
committed
run air
1 parent f681605 commit 7b8efa7

24 files changed

+480
-318
lines changed

.Rbuildignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,5 @@ README.md
1515
^get-libgit2-linux.sh$
1616
^libgit2$
1717
^libgit2-.*_linux$
18+
^[.]?air[.]toml$
19+
^\.vscode$

.vscode/extensions.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"recommendations": [
3+
"Posit.air-vscode"
4+
]
5+
}

.vscode/settings.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"[r]": {
3+
"editor.formatOnSave": true,
4+
"editor.defaultFormatter": "Posit.air-vscode"
5+
},
6+
"[quarto]": {
7+
"editor.formatOnSave": true,
8+
"editor.defaultFormatter": "quarto.quarto"
9+
}
10+
}

R/archive.R

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,26 @@
1111
#' @param file name of the output zip file. Default is returned
1212
#' by the function
1313
#' @return path to the zip file that was created
14-
git_archive_zip <- function(file = NULL, repo = "."){
14+
git_archive_zip <- function(file = NULL, repo = ".") {
1515
repo <- git_open(repo = repo)
1616
tmp <- tempfile(fileext = '.zip')
1717
git_archive_internal(tmp, repo = repo)
18-
if(!length(file)){
18+
if (!length(file)) {
1919
file <- paste0(basename(git_info(repo)$path), ".zip")
2020
}
2121
file.copy(tmp, file, overwrite = TRUE)
2222
return(file)
2323
}
2424

25-
git_archive_internal <- function(outfile, repo){
26-
tryCatch({
27-
git_stash_save(repo = repo)
28-
on.exit(git_stash_pop(repo = repo))
29-
}, GIT_ENOTFOUND = function(e){})
25+
git_archive_internal <- function(outfile, repo) {
26+
tryCatch(
27+
{
28+
git_stash_save(repo = repo)
29+
on.exit(git_stash_pop(repo = repo))
30+
},
31+
GIT_ENOTFOUND = function(e) {
32+
}
33+
)
3034
files <- git_ls(repo = repo)$path
3135
wd <- getwd()
3236
on.exit(setwd(wd), add = TRUE)

R/branch.R

Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@
88
#' @family git
99
#' @inheritParams git_open
1010
#' @useDynLib gert R_git_branch_current
11-
git_branch <- function(repo = '.'){
11+
git_branch <- function(repo = '.') {
1212
repo <- git_open(repo)
1313
.Call(R_git_branch_current, repo)
1414
}
1515

1616
#' @export
1717
#' @rdname git_branch
1818
#' @useDynLib gert R_git_branch_list
19-
git_branch_list <- function(local = NULL, repo = '.'){
19+
git_branch_list <- function(local = NULL, repo = '.') {
2020
repo <- git_open(repo)
2121
local <- as.logical(local)
2222
.Call(R_git_branch_list, repo, local)
@@ -28,21 +28,29 @@ git_branch_list <- function(local = NULL, repo = '.'){
2828
#' @param force ignore conflicts and overwrite modified files
2929
#' @param orphan if branch does not exist, checkout unborn branch
3030
#' @useDynLib gert R_git_checkout_branch R_git_checkout_unborn
31-
git_branch_checkout <- function(branch, force = FALSE, orphan = FALSE, repo = '.'){
31+
git_branch_checkout <- function(
32+
branch,
33+
force = FALSE,
34+
orphan = FALSE,
35+
repo = '.'
36+
) {
3237
repo <- git_open(repo)
3338
branch <- as.character(branch)
3439
force <- as.logical(force)
35-
if(!git_branch_exists(branch, repo = repo)){
36-
if(isTRUE(orphan)){
40+
if (!git_branch_exists(branch, repo = repo)) {
41+
if (isTRUE(orphan)) {
3742
ref <- paste0('refs/heads/', branch)
3843
.Call(R_git_checkout_unborn, repo, ref)
3944
return(ref)
4045
}
4146
all_branches <- subset(git_branch_list(repo = repo), local == FALSE)$name
4247
candidate <- sub("^[^/]+/", "", all_branches) == branch
43-
if(sum(candidate) > 1){
44-
stop(sprintf("Local branch '%s' does not exist and multiple remote candidates found.", branch))
45-
} else if(sum(candidate) == 0){
48+
if (sum(candidate) > 1) {
49+
stop(sprintf(
50+
"Local branch '%s' does not exist and multiple remote candidates found.",
51+
branch
52+
))
53+
} else if (sum(candidate) == 0) {
4654
stop(sprintf("No local or remote branch '%s' found.", branch))
4755
} else {
4856
remote_branch <- unname(all_branches[candidate])
@@ -59,7 +67,13 @@ git_branch_checkout <- function(branch, force = FALSE, orphan = FALSE, repo = '.
5967
#' @param ref string with a branch/tag/commit
6068
#' @param checkout move HEAD to the newly created branch
6169
#' @param force overwrite existing branch
62-
git_branch_create <- function(branch, ref = "HEAD", checkout = TRUE, force = FALSE, repo = '.'){
70+
git_branch_create <- function(
71+
branch,
72+
ref = "HEAD",
73+
checkout = TRUE,
74+
force = FALSE,
75+
repo = '.'
76+
) {
6377
repo <- git_open(repo)
6478
branch <- as.character(branch)
6579
ref <- as.character(ref)
@@ -71,7 +85,7 @@ git_branch_create <- function(branch, ref = "HEAD", checkout = TRUE, force = FAL
7185
#' @export
7286
#' @rdname git_branch
7387
#' @useDynLib gert R_git_delete_branch
74-
git_branch_delete <- function(branch, repo = '.'){
88+
git_branch_delete <- function(branch, repo = '.') {
7589
repo <- git_open(repo)
7690
branch <- as.character(branch)
7791
.Call(R_git_delete_branch, repo, branch)
@@ -82,7 +96,7 @@ git_branch_delete <- function(branch, repo = '.'){
8296
#' @rdname git_branch
8397
#' @useDynLib gert R_git_branch_move
8498
#' @param new_branch target name of the branch once the move is performed; this name is validated for consistency.
85-
git_branch_move <- function(branch, new_branch, force = FALSE, repo = '.'){
99+
git_branch_move <- function(branch, new_branch, force = FALSE, repo = '.') {
86100
repo <- git_open(repo)
87101
branch <- as.character(branch)
88102
new_branch <- as.character(new_branch)
@@ -92,9 +106,9 @@ git_branch_move <- function(branch, new_branch, force = FALSE, repo = '.'){
92106

93107
#' @export
94108
#' @rdname git_branch
95-
git_branch_fast_forward <- function(ref, repo = '.'){
109+
git_branch_fast_forward <- function(ref, repo = '.') {
96110
analysis <- git_merge_analysis(ref = ref, repo = repo)
97-
if(analysis != "fastforward")
111+
if (analysis != "fastforward")
98112
stop("Branch cannot be fast-forwarded. Use git_merge() instead")
99113
git_branch_set_target(ref = ref, repo = repo)
100114
}
@@ -103,10 +117,14 @@ git_branch_fast_forward <- function(ref, repo = '.'){
103117
#' @rdname git_branch
104118
#' @param upstream remote branch from [git_branch_list], for example `"origin/master"`
105119
#' @useDynLib gert R_git_branch_set_upstream
106-
git_branch_set_upstream <- function(upstream, branch = git_branch(repo), repo = '.'){
120+
git_branch_set_upstream <- function(
121+
upstream,
122+
branch = git_branch(repo),
123+
repo = '.'
124+
) {
107125
repo <- git_open(repo)
108126
stopifnot(is.character(upstream))
109-
if(!git_branch_exists(upstream, local = FALSE, repo = repo))
127+
if (!git_branch_exists(upstream, local = FALSE, repo = repo))
110128
stop(sprintf("No remote branch found: %s, maybe fetch first?", upstream))
111129
.Call(R_git_branch_set_upstream, repo, upstream, branch)
112130
git_repo_path(repo)
@@ -117,15 +135,15 @@ git_branch_set_upstream <- function(upstream, branch = git_branch(repo), repo =
117135
#' @param local set TRUE to only check for local branches, FALSE to check for remote
118136
#' branches. Use NULL to return all branches.
119137
#' @useDynLib gert R_git_branch_exists
120-
git_branch_exists <- function(branch, local = TRUE, repo = '.'){
138+
git_branch_exists <- function(branch, local = TRUE, repo = '.') {
121139
repo <- git_open(repo)
122140
branch <- as.character(branch)
123141
local <- as.logical(local)
124142
.Call(R_git_branch_exists, repo, branch, local)
125143
}
126144

127145
#' @useDynLib gert R_git_branch_set_target
128-
git_branch_set_target <- function(ref, branch, repo){
146+
git_branch_set_target <- function(ref, branch, repo) {
129147
repo <- git_open(repo)
130148
ref <- as.character(ref)
131149
.Call(R_git_branch_set_target, repo, ref)

R/certs.R

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,41 @@
11
# This is only used for static builds and on Solaris.
22
# It is not needed if you're using a system libgit2.
33
#' @useDynLib gert R_static_libgit2
4-
have_static_libgit2 <- function(){
4+
have_static_libgit2 <- function() {
55
.Call(R_static_libgit2)
66
}
77

88
#' @useDynLib gert R_set_cert_locations
9-
set_cert_locations <- function(file, path){
9+
set_cert_locations <- function(file, path) {
1010
file <- as.character(file)
1111
path <- as.character(path)
1212
.Call(R_set_cert_locations, file, path)
1313
}
1414

15-
file_exists <- function(x){
15+
file_exists <- function(x) {
1616
length(x) && file.exists(x)
1717
}
1818

19-
find_cert_dir <- function(){
20-
if(nchar(Sys.which('openssl')) > 0){
19+
find_cert_dir <- function() {
20+
if (nchar(Sys.which('openssl')) > 0) {
2121
out <- sys::exec_internal('openssl', c('version', '-d'), error = FALSE)
22-
if(out$status == 0){
22+
if (out$status == 0) {
2323
txt <- sys::as_text(out$stdout)
2424
path <- utils::tail(strsplit(txt, ' ', fixed = TRUE)[[1]], 1)
2525
path <- gsub('"', "", path, fixed = TRUE)
2626
path <- file.path(path, 'certs')
27-
if(file_exists(path)){
27+
if (file_exists(path)) {
2828
return(path)
2929
}
3030
}
3131
}
32-
default_paths <- c('/etc/pki/tls/certs', '/etc/ssl/certs/', '/etc/opt/csw/ssl/certs')
33-
for(x in default_paths){
34-
if(file_exists(x)){
32+
default_paths <- c(
33+
'/etc/pki/tls/certs',
34+
'/etc/ssl/certs/',
35+
'/etc/opt/csw/ssl/certs'
36+
)
37+
for (x in default_paths) {
38+
if (file_exists(x)) {
3539
return(x)
3640
}
3741
}

0 commit comments

Comments
 (0)