Skip to content

Commit

Permalink
v0.1.2 pandoc version
Browse files Browse the repository at this point in the history
  • Loading branch information
statnmap committed May 10, 2021
1 parent 7797938 commit 55f832e
Show file tree
Hide file tree
Showing 9 changed files with 155 additions and 134 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: gitdown
Title: Turn Your Git Commit Messages into a HTML Book
Version: 0.1.1.9000
Version: 0.1.2
Authors@R:
c(person(given = "Sébastien",
family = "Rochette",
Expand Down
4 changes: 3 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# gitdown (development version)
# gitdown 0.1.2

* Protect from older Pandoc versions

# gitdown 0.1.1

Expand Down
10 changes: 7 additions & 3 deletions R/get_info_files.R
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,9 @@ present_files <- function(repo = ".", path = "R",
#'
#' # Creates vignette
#' repo <- fake_repo(as.package = TRUE)
#' create_vignette_last_modif(repo, path = "R")
#' if (rmarkdown::pandoc_available("1.12.3")) {
#' create_vignette_last_modif(repo, path = "R")
#' }

create_vignette_last_modif <- function(repo = ".", path = "R",
recursive = TRUE, untracked = TRUE) {
Expand All @@ -196,8 +198,10 @@ create_vignette_last_modif <- function(repo = ".", path = "R",
#' @examples
#' # update vignette
#' repo <- fake_repo(as.package = TRUE)
#' update_vignette_last_modif(repo, path = "R")
#' rmarkdown::render(file.path(repo, "vignettes", "modification_files.Rmd"))
#' if (rmarkdown::pandoc_available("1.12.3")) {
#' update_vignette_last_modif(repo, path = "R")
#' rmarkdown::render(file.path(repo, "vignettes", "modification_files.Rmd"))
#' }
update_vignette_last_modif <- function(repo = ".", path = "R",
recursive = TRUE, untracked = TRUE) {
vig <- file.path(repo, "vignettes")
Expand Down
12 changes: 8 additions & 4 deletions R/git_down.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@
#'
#' @examples
#' repo <- fake_repo()
#' res <- git_down(repo, pattern = c("Tickets" = "ticket[[:digit:]]+", "Issues" = "#[[:digit:]]+"),
#' open = FALSE)
#' if (rmarkdown::pandoc_available("1.12.3")) {
#' res <- git_down(repo, pattern = c("Tickets" = "ticket[[:digit:]]+", "Issues" = "#[[:digit:]]+"),
#' open = FALSE)
#' }
#' \dontrun{
#' # Open the book
#' browseURL(res)
Expand All @@ -36,8 +38,10 @@
#' pattern.table <- data.frame(number = c("#2", "#1"),
#' title = c("#2 A second issue to illustrate a blog post",
#' "#1 An example of issue"))
#' res <- git_down(repo, pattern = c("Issues" = "#[[:digit:]]+"),
#' pattern.table = pattern.table, open = FALSE)
#' if (rmarkdown::pandoc_available("1.12.3")) {
#' res <- git_down(repo, pattern = c("Issues" = "#[[:digit:]]+"),
#' pattern.table = pattern.table, open = FALSE)
#' }
#' \dontrun{
#' # Open the book
#' browseURL(res)
Expand Down
2 changes: 1 addition & 1 deletion dev_history.R
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ devtools::build_readme()
urlchecker::url_check()
urlchecker::url_update()

# usethis::use_release_issue(version = "0.1.1")
usethis::use_version('patch')

rcmdcheck::rcmdcheck(args = "--as-cran")
Expand All @@ -80,6 +79,7 @@ rhub::validate_email()
rhub::check_for_cran()
rhub::check_on_windows(check_args = "--force-multiarch")
rhub::check_on_fedora()
rhub::check_on_solaris()
devtools::check_win_devel()
devtools::check_win_release()

Expand Down
10 changes: 7 additions & 3 deletions man/create_vignette_last_modif.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 8 additions & 4 deletions man/git_down.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

47 changes: 24 additions & 23 deletions tests/testthat/test-get_info_files.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,26 +51,27 @@ test_that("present_files error", {
})

# create_vignette_last_modif ----
create_vignette_last_modif(repo_pkg)
# browseURL(repo_pkg)

test_that("create_vignette_last_modif works", {
expect_true(file.exists(file.path(repo_pkg, "vignettes", "modification_files.Rmd")))
})
# Clean repo
file.remove(file.path(repo_pkg, "vignettes", "modification_files.Rmd"))

# All files
create_vignette_last_modif(repo_pkg, path = "")

test_that("create_vignette_last_modif works", {
expect_true(file.exists(file.path(repo_pkg, "vignettes", "modification_files.Rmd")))
})
# Clean repo
file.remove(file.path(repo_pkg, "vignettes", "modification_files.Rmd"))

# No vignettes/
test_that("create_vignette_last_modif error", {
expect_error(create_vignette_last_modif(repo_no_pkg))
})

if (rmarkdown::pandoc_available("1.12.3")) {
create_vignette_last_modif(repo_pkg)
# browseURL(repo_pkg)

test_that("create_vignette_last_modif works", {
expect_true(file.exists(file.path(repo_pkg, "vignettes", "modification_files.Rmd")))
})
# Clean repo
file.remove(file.path(repo_pkg, "vignettes", "modification_files.Rmd"))

# All files
create_vignette_last_modif(repo_pkg, path = "")

test_that("create_vignette_last_modif works", {
expect_true(file.exists(file.path(repo_pkg, "vignettes", "modification_files.Rmd")))
})
# Clean repo
file.remove(file.path(repo_pkg, "vignettes", "modification_files.Rmd"))

# No vignettes/
test_that("create_vignette_last_modif error", {
expect_error(create_vignette_last_modif(repo_no_pkg))
})
}
190 changes: 96 additions & 94 deletions tests/testthat/test-git_down.R
Original file line number Diff line number Diff line change
@@ -1,104 +1,106 @@
library(withr)

repo_input <- tempfile(pattern = "git2r-")
repo <- fake_repo(repo_input)

# Classic use
with_dir(repo, {
res <- git_down(author = "Cervan",
pattern = c("Issue" = "#[[:digit:]]+"),
open = FALSE
)
})
lines <- readLines(file.path(dirname(res), "section-issue.html"))
one_line_exists <- grep('<h2><span class="header-section-number">1.2</span> Issue: #1</h2>',
lines, fixed = TRUE)
sub_commit_1 <- grep('<h3><span class="header-section-number">1.2.1</span> commit: example: modification</h3>',
lines, fixed = TRUE)
sub_commit_2 <- grep('<h3><span class="header-section-number">1.2.2</span> commit: Add NEWS</h3>',
lines, fixed = TRUE)

test_that("git_down function",{
expect_match(res, regexp = ".html")
expect_true(file.exists(file.path(dirname(res), "section-issue.html")))
expect_length(one_line_exists, 1)
expect_length(sub_commit_1, 1)
expect_length(sub_commit_2, 1)
})

# clean dir
unlink(dirname(res), recursive = TRUE)

# Pattern without name and special characters cleaned
with_dir(repo, {
res <- git_down(author = "StatnMap",
pattern = c("#[[:digit:]]+"),
open = FALSE
)
})

lines <- readLines(file.path(dirname(res), "section-digit.html"))
one_line_exists <- grep('<h2><span class="header-section-number">1.2</span> <code>#--:digit:--+</code>: #1</h2>',
lines, fixed = TRUE)

test_that("git_down no name function",{
expect_match(res, regexp = ".html")
expect_true(file.exists(file.path(dirname(res), "section-digit.html")))
expect_true(length(one_line_exists) == 1)
})

# clean dir
unlink(dirname(res), recursive = TRUE)

# With multiple patterns ----
with_dir(repo, {
res <- git_down(author = "Seb",
pattern = c("Tickets" = "ticket[[:digit:]]+", "Issues" = "#[[:digit:]]+"),
open = FALSE
)
})

test_that("git_down multiple pattern works", {
expect_match(res, regexp = ".html")

issues_file <- normalizePath(file.path(dirname(res), "section-issues.html"))
tickets_file <- normalizePath(file.path(dirname(res), "section-tickets.html"))

expect_true(file.exists(issues_file))
expect_true(file.exists(tickets_file))

lines <- readLines(tickets_file)
one_line_ticket_exists <- grep('<h2><span class="header-section-number">1.2</span> Ticket: ticket1234</h2>',
lines, fixed = TRUE)

expect_true(length(one_line_ticket_exists) == 1)

lines <- readLines(issues_file)
one_line_exists <- grep('<h2><span class="header-section-number">2.2</span> Issue: #1</h2>',
lines, fixed = TRUE)
expect_true(length(one_line_exists) == 1)
})

# clean dir
unlink(dirname(res), recursive = TRUE)
if (rmarkdown::pandoc_available("1.12.3")) {
library(withr)

# 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"))
repo_input <- tempfile(pattern = "git2r-")
repo <- fake_repo(repo_input)

test_that("git_down with pattern table",{
# Classic use
with_dir(repo, {
res <- git_down(author = "Cervan",
pattern = c("Issue" = "#[[:digit:]]+"),
pattern.table = pattern.table,
open = FALSE
)
})
lines <- readLines(file.path(dirname(res), "section-issue.html"))
one_line_exists <- grep('<h2><span class="header-section-number">1.2</span> Issue: #1</h2>',
lines, fixed = TRUE)
sub_commit_1 <- grep('<h3><span class="header-section-number">1.2.1</span> commit: example: modification</h3>',
lines, fixed = TRUE)
sub_commit_2 <- grep('<h3><span class="header-section-number">1.2.2</span> commit: Add NEWS</h3>',
lines, fixed = TRUE)

test_that("git_down function",{
expect_match(res, regexp = ".html")
expect_true(file.exists(file.path(dirname(res), "section-issue.html")))
expect_length(one_line_exists, 1)
expect_length(sub_commit_1, 1)
expect_length(sub_commit_2, 1)
})

# clean dir
unlink(dirname(res), recursive = TRUE)

# Pattern without name and special characters cleaned
with_dir(repo, {
res <- git_down(author = "StatnMap",
pattern = c("#[[:digit:]]+"),
open = FALSE
)
})

lines <- readLines(file.path(dirname(res), "section-digit.html"))
one_line_exists <- grep('<h2><span class="header-section-number">1.2</span> <code>#--:digit:--+</code>: #1</h2>',
lines, fixed = TRUE)

test_that("git_down no name function",{
expect_match(res, regexp = ".html")
expect_true(file.exists(file.path(dirname(res), "section-digit.html")))
expect_true(length(one_line_exists) == 1)
})

# clean dir
unlink(dirname(res), recursive = TRUE)

# With multiple patterns ----
with_dir(repo, {
res <- git_down(author = "Seb",
pattern = c("Tickets" = "ticket[[:digit:]]+", "Issues" = "#[[:digit:]]+"),
open = FALSE
)
})

test_that("git_down multiple pattern works", {
expect_match(res, regexp = ".html")

issues_file <- normalizePath(file.path(dirname(res), "section-issues.html"))
tickets_file <- normalizePath(file.path(dirname(res), "section-tickets.html"))

expect_true(file.exists(issues_file))
expect_true(file.exists(tickets_file))

lines <- readLines(tickets_file)
one_line_ticket_exists <- grep('<h2><span class="header-section-number">1.2</span> Ticket: ticket1234</h2>',
lines, fixed = TRUE)

expect_true(length(one_line_ticket_exists) == 1)

lines <- readLines(issues_file)
one_line_exists <- grep('<h2><span class="header-section-number">2.2</span> Issue: #1</h2>',
lines, fixed = TRUE)
expect_true(length(one_line_exists) == 1)
})

# clean dir
unlink(dirname(res), recursive = TRUE)

# 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"))

test_that("git_down with pattern table",{
with_dir(repo, {
res <- git_down(author = "Cervan",
pattern = c("Issue" = "#[[:digit:]]+"),
pattern.table = pattern.table,
open = FALSE
)
expect_match(res, regexp = ".html")
})
})
})

# clean dir
unlink(dirname(res), recursive = TRUE)
# clean dir
unlink(dirname(res), recursive = TRUE)
}

0 comments on commit 55f832e

Please sign in to comment.