Skip to content

Commit da42902

Browse files
committed
docs: tag
1 parent 1113305 commit da42902

26 files changed

Lines changed: 321 additions & 191 deletions

DESCRIPTION

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,11 @@ Imports:
2323
sys,
2424
zip (>= 2.1.0)
2525
Suggests:
26-
spelling,
26+
spelling,
2727
knitr,
2828
rmarkdown,
29-
testthat
29+
testthat,
30+
roxygen2
3031
VignetteBuilder:
3132
knitr
3233
Encoding: UTF-8

NAMESPACE

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
# Generated by roxygen2: do not edit by hand
22

3+
S3method(format,rd_section_gitcommands)
34
S3method(print,gert_signature)
45
S3method(print,git_repo_ptr)
6+
S3method(roxygen2::roxy_tag_parse,roxy_tag_git)
7+
S3method(roxygen2::roxy_tag_rd,roxy_tag_git)
58
export(git_add)
69
export(git_ahead_behind)
710
export(git_archive_zip)

R/branch.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ 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 checkout
3132
git_branch_checkout <- function(
3233
branch,
3334
force = FALSE,

R/gert-package.R

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,42 @@
44
## usethis namespace: start
55
## usethis namespace: end
66
NULL
7+
8+
.onLoad <- function(libname, pkgname) {
9+
register_s3_method(
10+
"roxygen2",
11+
"roxy_tag_parse",
12+
"roxy_tag_git",
13+
roxy_tag_parse.roxy_tag_git
14+
)
15+
register_s3_method(
16+
"roxygen2",
17+
"roxy_tag_rd",
18+
"roxy_tag_git",
19+
roxy_tag_rd.roxy_tag_git
20+
)
21+
}
22+
23+
24+
register_s3_method <- function(pkg, generic, class, fun = NULL) {
25+
stopifnot(is.character(pkg), length(pkg) == 1)
26+
stopifnot(is.character(generic), length(generic) == 1)
27+
stopifnot(is.character(class), length(class) == 1)
28+
if (is.null(fun)) {
29+
fun <- get(paste0(generic, ".", class), envir = parent.frame())
30+
} else {
31+
stopifnot(is.function(fun))
32+
}
33+
34+
if (isNamespaceLoaded(pkg)) {
35+
registerS3method(generic, class, fun, envir = asNamespace(pkg))
36+
}
37+
38+
# Always register hook in case package is later unloaded & reloaded
39+
setHook(
40+
packageEvent(pkg, "onLoad"),
41+
function(...) {
42+
registerS3method(generic, class, fun, envir = asNamespace(pkg))
43+
}
44+
)
45+
}

R/roxygen2.R

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# nocov start
2+
3+
git_links <- function() {
4+
rlang::check_installed("tibble")
5+
tibble::tribble(
6+
~command , ~url ,
7+
"checkout" , "https://libgit2.org/docs/reference/main/checkout/index.html"
8+
)
9+
}
10+
11+
#' @exportS3Method roxygen2::roxy_tag_parse
12+
roxy_tag_parse.roxy_tag_git <- function(x) {
13+
roxygen2::tag_words(x)
14+
}
15+
16+
#' @exportS3Method roxygen2::roxy_tag_rd
17+
roxy_tag_rd.roxy_tag_git <- function(x, base_path, env) {
18+
roxygen2::rd_section("gitcommands", x$val)
19+
}
20+
21+
#' @export
22+
format.rd_section_gitcommands <- function(x, ...) {
23+
paste0(
24+
"\\section{Related libgit2 documentation}{",
25+
present_git_link(x[["value"]]),
26+
".}\n"
27+
)
28+
}
29+
30+
present_git_link <- function(value) {
31+
format_git_single_link <- function(x, git_links) {
32+
df <- git_links[git_links$command == x, ]
33+
if (nrow(df) == 0) {
34+
cli::cli_warn("Can't find libgit2 entry for {x}!")
35+
}
36+
sprintf("\\href{%s}{\\code{%s}}", df$url, df$command)
37+
}
38+
39+
strings <- purrr::map_chr(
40+
unique(value),
41+
format_git_single_link,
42+
git_links = git_links()
43+
)
44+
45+
paste(strings, collapse = ", ")
46+
}
47+
# nocov end

bundle.tar.gz

4.15 MB
Binary file not shown.

get-libgit2-linux.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
IS_MUSL=$(ldd --version 2>&1 | grep musl)
2+
if [ $? -eq 0 ] && [ "$IS_MUSL" ]; then
3+
echo "Do not use static libgit2 on MUSL C"
4+
else
5+
OLDOPENSSL=$("${R_HOME}/bin/Rscript" -e 'cat(openssl::openssl_config()$version)' | grep "OpenSSL 1.0")
6+
if [ $? -eq 0 ] && [ "$OLDOPENSSL" ]; then
7+
URL="https://r-lib.github.io/gert/libgit2-1.1.0.x86_64_legacy-linux.tar.gz"
8+
TMP_LIBS="-lstatgit2 -lrt -lpthread -lstatssh2 -lstatssl -lstatcrypto -ldl -lpcre -lz"
9+
else
10+
OPENSSL3=$("${R_HOME}/bin/Rscript" -e 'cat(openssl::openssl_config()$version)' | grep "OpenSSL 3")
11+
if [ $? -eq 0 ] && [ "$OPENSSL3" ]; then
12+
URL="https://r-lib.github.io/gert/libgit2-1.4.2-openssl3-x86_64_linux.tar.gz"
13+
echo "Found OpenSSL3"
14+
else
15+
URL="https://autobrew.github.io/archive/x86_64_linux/libgit2-1.4.2-x86_64_linux.tar.gz"
16+
fi
17+
TMP_LIBS="-lstatgit2 -lrt -lpthread -lstatssh2 -lstatssl -lstatcrypto -ldl"
18+
fi
19+
if "${R_HOME}/bin/R" -s -e "curl::curl_download('$URL','bundle.tar.gz')"; then
20+
DEPS="$PWD/.deps"
21+
LIBDIR="$DEPS/lib"
22+
mkdir -p $DEPS
23+
tar xzf bundle.tar.gz --strip 1 -C $DEPS
24+
mv $LIBDIR/libgit2.a $LIBDIR/libstatgit2.a
25+
mv $LIBDIR/libssh2.a $LIBDIR/libstatssh2.a
26+
mv $LIBDIR/libssl.a $LIBDIR/libstatssl.a
27+
mv $LIBDIR/libcrypto.a $LIBDIR/libstatcrypto.a
28+
PKG_CFLAGS="-I$DEPS/include -DSTATIC_LIBGIT2"
29+
PKG_LIBS="-L$LIBDIR $TMP_LIBS"
30+
HAVE_STATIC_LIBGIT2=TRUE
31+
fi
32+
fi

man/gert-package.Rd

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/git_archive.Rd

Lines changed: 11 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/git_branch.Rd

Lines changed: 12 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)