knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)
# Copy reference/images to man/images
# reference folder is required to work with pkgdown
if (!dir.exists("man/figures")) {dir.create("man/figures")}
file.copy(list.files("reference/figures", full.names = TRUE),
          "man/figures", overwrite = TRUE)
# if (dir.exists("docs")) {
#   file.copy("reference/figures/thinkr-hex-remedy-favicon.ico",
#             "docs/favicon.ico", overwrite = TRUE)
# }

gitdown

R-CMD-check Coverage status CRAN status

The goal of {gitdown} is to build a bookdown report of commit messages arranged according to a pattern. Book can be organized according to git tags, issues mentioned (e.g. #123) or any custom character chain included in your git commit messages (e.g. category_ for use like category_ui, category_doc, ...).

Full documentation on {pkgdown} site : https://thinkr-open.github.io/gitdown/index.html

Installation

You can install the stable version of {gitdown} from CRAN:

install.packages("gitdown")

You can install the last version of {gitdown} from GitHub:

remotes::install_github("ThinkR-open/gitdown")

Create a reproducible example of a versioned directory

Create a versioned directory with some commits and a NEWS.md in a temporary directory

library(dplyr)
library(gitdown)
## Create fake repository for the example
repo <- fake_repo()

Create a gitbook of commits sorted by a pattern

The main function of {gitdown} is to build this gitbook with all commit messages ordered according to a pattern. Each commit message associated with an issue will be recorded in the section of this issue. A commit message can thus appears multiple times if it is associated with multiple issues.
If you have your own referencing system for tickets in an external software, you can also create the gitbook associated like using ticket as in the example below.

git_down(repo, pattern = c("Tickets" = "ticket[[:digit:]]+",
                           "Issues" = "#[[:digit:]]+"))
knitr::include_graphics("reference/figures/gitdown_links.png")

If you add a table of correspondence, you can change titles of the patterns.
Note that you can use {gitlabr} or {gh} to retrieve list of issues from GitLab or GitHub respectively, as presented in "Download GitLab or GitHub issues and make a summary report of your commits".

# With table of correspondence
pattern.table <- data.frame(
  number = c("#2", "#1", "#1000"),
  title = c("#2 A second issue to illustrate a blog post",
            "#1 An example of issue",
            "#1000 issue with no commit"))
git_down(
  pattern = c("Issue" = "#[[:digit:]]+"),
  pattern.table = pattern.table
)

Note that characters like [, ], _ or * will be replaced by - in the titles to avoid conflicts with markdown syntax.

knitr::include_graphics("reference/figures/issues-with-title.png")

Read list of commits and extract information

As a side effect of {gitdown}, you can get some intermediate information used to build the book with some exported functions.

Get commits with issues mentioned. The searched pattern is a # followed by at least one number: "#[[:digit:]]+". Variable pattern.content lists patterns found in the commit messages.

get_commits_pattern(repo, pattern = "#[[:digit:]]+", ref = "main") %>% 
  select(pattern.content, everything())

Get commits with issues and specific home-made pattern. Use a named vector to properly separate types of patterns.

get_commits_pattern(
  repo, 
  pattern =  c("Tickets" = "ticket[[:digit:]]+", "Issues" = "#[[:digit:]]+"),
  ref = "main"
) %>% 
  select(pattern.type, pattern.content, everything())

Create a vignette that lists all files with date of modification

repo_pkg <- fake_repo(as.package = TRUE)
# List only files in R/ directory
create_vignette_last_modif(repo_pkg)
# List all files of the git repository
create_vignette_last_modif(repo_pkg, path = "")

With this example, the vignette will show this content:

repo_pkg <- fake_repo(as.package = TRUE)
cat(present_files(repo_pkg, path = ""))

Sponsor

The development of this package has been sponsored by:

Code of Conduct

Please note that the {gitdown} project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.



ThinkR-open/gitdown documentation built on Feb. 29, 2024, 7:06 a.m.