Skip to content

Commit

Permalink
write a few Git vignettes
Browse files Browse the repository at this point in the history
  • Loading branch information
ErdaradunGaztea committed Apr 14, 2024
1 parent 110edf1 commit 4572a96
Show file tree
Hide file tree
Showing 5 changed files with 128 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,4 @@ vignettes/*.pdf
*.Rproj
.Rproj.user
docs
inst/doc
3 changes: 3 additions & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,13 @@ Imports:
Suggests:
covr,
httptest2,
knitr,
rmarkdown,
testthat (>= 3.0.0),
usethis,
withr,
xml2
Config/testthat/edition: 3
URL: https://github.com/turtletopia/woodendesc,
https://turtletopia.github.io/woodendesc/
VignetteBuilder: knitr
2 changes: 2 additions & 0 deletions vignettes/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.html
*.R
65 changes: 65 additions & 0 deletions vignettes/github.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
---
title: "Analysing GitHub"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{Analysing GitHub}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---

```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
)
library(woodendesc)
```

GitHub is a site offering Git version control system. It's the most popular website for hosting open-source R packages, including this one. A wide set of metadata is available.

## Packages

A user or an organization may be (and in most cases is) an owner of several repositories. Not all repositories are R packages, thus the repository character is approximated by the presence of a `DESCRIPTION` file, one of very few required files for R packages, in the root folder.

```{r github_packages, cache=TRUE}
wood_github_packages("turtletopia")
```

By default, forks of other repositories are not listed, but this setting can be changed using `include_forks` parameter:

```{r github_packages_w_forks, cache=TRUE}
wood_github_packages("ErdaradunGaztea", include_forks = TRUE)
```

## Available tags

GitHub allows referencing to certain commits through specifying tags associated with them. To list all tags available for a given repository the user should use `wood_github_tags()`. Note that some repositories may not have any tags defined, in which case an empty character vector would be returned.

```{r github_tags, cache=TRUE}
wood_github_tags("gglgbtq", "turtletopia")
```

## Available package versions

Repository tags do not have to follow the specific guidelines of version codes. To extract package version codes associated with each GitHub tag the user should use `wood_github_versions()`. This extracts the data from the `DESCRIPTION` file corresponding to each tagged commit.

```{r github_versions, cache=TRUE}
wood_github_versions("versionsort", "turtletopia")
```

## Latest package version

To query the latest package version, i.e. the one that'd be installed by calling `remotes::install_github()`, the user should use `wood_github_latest()`. This function queries GitHub for the version code associated with the latest commit to the default branch of the specified repository. Note that this commit may be untagged, in which case the returned version code may not be among the ones listed by `wood_github_versions()`.

```{r github_latest, cache=TRUE}
wood_github_latest("gglgbtq", "turtletopia")
```

## Package dependencies

To list package dependencies the user should use `wood_github_dependencies()`. This function extracts dependencies from the `DESCRIPTION` file. By default the latest commit is queried (the same behaviour can be obtained using `tag = "latest"` parameter) but it is possible to list dependencies for any tagged version.

```{r github_deps, cache=TRUE}
wood_github_dependencies("gglgbtq", "turtletopia")
wood_github_dependencies("versionsort", "turtletopia", tag = "v1.0.0")
```
57 changes: 57 additions & 0 deletions vignettes/gitlab.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---
title: "Analysing GitLab"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{Analysing GitLab}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---

```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
)
library(woodendesc)
```

GitLab is a site providing, among other services, code repositories with Git version control system. This allows for accessing a wide set of metadata.

## Packages

A user or a group may be (and in most cases is) an owner of several repositories. Not all repositories are R packages, thus the repository character is approximated by the presence of a `DESCRIPTION` file, one of very few required files for R packages, in the root folder.

```{r gitlab_packages, cache=TRUE}
wood_gitlab_packages("r-packages")
```

By default, forks of other repositories are not listed, but this setting can be changed using `include_forks` parameter:

```{r gitlab_packages_w_forks, cache=TRUE}
wood_gitlab_packages("r-packages", include_forks = TRUE)
```

## Available tags

<!-- TODO: wood_gitlab_tags() -->

## Available package versions

<!-- TODO: wood_gitlab_versions() -->

## Latest package version

To query the latest package version, i.e. the one that'd be installed by calling `remotes::install_gitlab()`, the user should use `wood_gitlab_latest()`. This function queries GitLab for the version code associated with the latest commit to the default branch of the specified repository. Note that this commit may be untagged, in which case the returned version code may not be among the ones listed by `wood_gitlab_versions()`.

```{r gitlab_latest, cache=TRUE}
wood_gitlab_latest("rock", "r-packages")
```

## Package dependencies

To list package dependencies the user should use `wood_gitlab_dependencies()`. This function extracts dependencies from the `DESCRIPTION` file. By default the latest commit is queried (the same behaviour can be obtained using `tag = "latest"` parameter) but it is possible to list dependencies for any tagged version.

```{r gitlab_deps, cache=TRUE}
wood_gitlab_dependencies("limonaid", "r-packages")
wood_gitlab_dependencies("rock", "r-packages", tag = "0.6.3")
```

0 comments on commit 4572a96

Please sign in to comment.