Git Product home page Git Product logo

gitdown's Introduction

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

  • Some commits mention an issue with #
  • Some commits mention a ticket with ticket
  • A commit is associated with a tag
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:]]+"))

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.

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())
#> 4 commits found.
#> # A tibble: 7 × 12
#>   pattern.content sha     summary message author email when                order
#>   <chr>           <chr>   <chr>   <chr>   <chr>  <chr> <dttm>              <int>
#> 1 #32             1fd238… Add NE… "Add N… Alice  alic… 2024-02-28 13:22:16     4
#> 2 #1              1fd238… Add NE… "Add N… Alice  alic… 2024-02-28 13:22:16     4
#> 3 #12             1fd238… Add NE… "Add N… Alice  alic… 2024-02-28 13:22:16     4
#> 4 #2              91e2c1… Third … "Third… Alice  alic… 2024-02-28 13:22:16     3
#> 5 #145            91e2c1… Third … "Third… Alice  alic… 2024-02-28 13:22:16     3
#> 6 #1              7e998d… exampl… "examp… Alice  alic… 2024-02-28 13:22:16     2
#> 7 <NA>            1b6cc5… First … "First… Alice  alic… 2024-02-28 13:22:16     1
#> # ℹ 4 more variables: tag.name <chr>, tag.message <chr>, pattern.type <chr>,
#> #   pattern.title <chr>

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())
#> 4 commits found.
#> # A tibble: 12 × 12
#>    pattern.type pattern.content sha                 summary message author email
#>    <chr>        <chr>           <chr>               <chr>   <chr>   <chr>  <chr>
#>  1 Tickets      ticket6789      1fd238efc602f52946… Add NE… "Add N… Alice  alic…
#>  2 Tickets      ticket1234      1fd238efc602f52946… Add NE… "Add N… Alice  alic…
#>  3 Issues       #32             1fd238efc602f52946… Add NE… "Add N… Alice  alic…
#>  4 Issues       #1              1fd238efc602f52946… Add NE… "Add N… Alice  alic…
#>  5 Issues       #12             1fd238efc602f52946… Add NE… "Add N… Alice  alic…
#>  6 Tickets      <NA>            91e2c152a0525fc589… Third … "Third… Alice  alic…
#>  7 Issues       #2              91e2c152a0525fc589… Third … "Third… Alice  alic…
#>  8 Issues       #145            91e2c152a0525fc589… Third … "Third… Alice  alic…
#>  9 Tickets      ticket1234      7e998d8e673e331274… exampl… "examp… Alice  alic…
#> 10 Issues       #1              7e998d8e673e331274… exampl… "examp… Alice  alic…
#> 11 Tickets      <NA>            1b6cc5d04920de4a60… First … "First… Alice  alic…
#> 12 Issues       <NA>            1b6cc5d04920de4a60… First … "First… Alice  alic…
#> # ℹ 5 more variables: when <dttm>, order <int>, tag.name <chr>,
#> #   tag.message <chr>, pattern.title <chr>

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:

File Tracked in git Date of creation Last modification
NEWS.md Yes 2024-02-28 13:22:17 2024-02-28 13:22:17
example.txt Yes 2024-02-28 13:22:17 2024-02-28 13:22:17
R/my_mean.R No NA 2024-02-28 13:22:17

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.

gitdown's People

Contributors

cervangirard avatar margotbr avatar margotbrd avatar statnmap avatar stewid avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

gitdown's Issues

CRAN: Doc and tempdir

Please add \value to .Rd files regarding exported methods and explain
the functions results in the documentation. Please write about the
structure of the output (class) and also what the output means. (If a
function does not return a value, please document that too, e.g.
\value{No return value, called for side effects} or similar)
Missing Rd-tags:
clean_link.Rd: \value
clean_text.Rd: \value
each_commit.Rd: \value
my_extract.Rd: \value
pipe.Rd: \value
presentation_commit.Rd: \value
replace_in_file.Rd: \value
to_singular.Rd: \value
write_in.Rd: \value

Please ensure that your functions do not write by default or in your
examples/vignettes/tests in the user's home filespace (including the
package directory and getwd()). This is not allowed by CRAN policies.
In your examples/vignettes/tests you can write to tempdir().

CRAN check date

There is a unit test that looks at the start date of the book creation and the end date.
But if it starts at 23:59 and ends the next day, it mismatches.
Add a +:- 1 day authorization on the unit tests.

Bug Report: the arg ref is not used

Here is the error message.

Error in commits(repo = repo, ref = ref, topological = TRUE, time = TRUE,  : 
  参数没有用(ref = ref)
> gitdown::git_down(
+     repo = ".",
+     book_path = "gitdown",
+     open = TRUE,
+     author = "Jiaxiang Li",
+     pattern = c("ticket[[:digit:]]+", "#[[:digit:]]+"),
+     names_section = c("Ticket", "Issues")
+ )
Error in commits(repo = repo, ref = ref, topological = TRUE, time = TRUE,  : 
  参数没有用(ref = ref)
> library(gitdown)
> get_commits_pattern(repo, pattern = "#[[:digit:]]+", ref = "master") %>%
+     select(pattern, everything())
Error in commits(repo = repo, ref = ref, topological = TRUE, time = TRUE,  : 
  参数没有用(ref = ref)
> ?get_commits_tags
> get_commits_tags()
Error in commits(repo = repo, ref = ref, topological = TRUE, time = TRUE,  : 
  参数没有用(ref = ref)
> get_commits_tags(ref = NULL)
Error in commits(repo = repo, ref = ref, topological = TRUE, time = TRUE,  : 
  参数没有用(ref = ref)

I try several functions from gitdown and get the same error message.

Here is the repo I test https://github.com/JiaxiangBU/tutoring2

Release gitdown 0.1.1

First release:

Prepare for release:

  • devtools::build_readme()
  • urlchecker::url_check()
  • devtools::check(remote = TRUE, manual = TRUE)
  • devtools::check_win_devel()
  • rhub::check_for_cran()

Submit to CRAN:

  • usethis::use_version('patch')
  • devtools::submit_cran()
  • Approve email

Wait for CRAN...

  • Accepted 🎉
  • usethis::use_github_release()
  • usethis::use_dev_version()
  • Update install instructions in README

next rmarkdown release breaks some tests

We are about to release rmarkdown 2.12 and our check of reverse dependencies show an issue with test-git_down.R

From testthat.Rout.fail

[ FAIL 6 | WARN 0 | SKIP 0 | PASS 73 ]

══ Failed tests ════════════════════════════════════════════════════════════════
── Failure (test-git_down.R:25:5): git_down function ───────────────────────────
`one_line_exists` has length 0, not length 1.
── Failure (test-git_down.R:26:5): git_down function ───────────────────────────
`sub_commit_1` has length 0, not length 1.
── Failure (test-git_down.R:27:5): git_down function ───────────────────────────
`sub_commit_2` has length 0, not length 1.
── Failure (test-git_down.R:48:5): git_down no name function ───────────────────
length(one_line_exists) == 1 is not TRUE

`actual`:   FALSE
`expected`: TRUE 
── Failure (test-git_down.R:75:5): git_down multiple pattern works ─────────────
length(one_line_ticket_exists) == 1 is not TRUE

`actual`:   FALSE
`expected`: TRUE 
── Failure (test-git_down.R:80:5): git_down multiple pattern works ─────────────
length(one_line_exists) == 1 is not TRUE

`actual`:   FALSE
`expected`: TRUE 

[ FAIL 6 | WARN 0 | SKIP 0 | PASS 73 ]
Error: Test failures
Execution halted

rmarkdown 2.12 has a new way to insert the anchor section using a Lua filter and not only a JS script. This is why the HTML code has changed. Some of the test are failing because of that. There could be other reasons too.

In general, testing the HTML code is not robust, especially using fixed string. Better ways, are regex or xml2.
Probably using regex here would solve the issue.

Also the output of rmarkdown can be quite different in HTML file depending on the Pandoc version. We're still unsure which version CRAN is using but if they change it somehow it could also break some test doing matching. Also, when running your test, I am not sure to know which version to use. Skipping on CRAN test that run pandoc could also be the way to go. if you run tests in CI too, you are covered (but not by our rev dep check)

Anyway, the tests should be updated and a patch release pushed on CRAN otherwise when we'll make the release, gitdown will have some failure.

Thanks !

CRAN check error

Hello! I'm submitting stringi 1.6.2 to CRAN now and have been notified about the auto-check problems.

Package: gitdown
Check: tests
New result: ERROR
    Running ‘testthat.R’ [5s/5s]
  Running the tests in ‘tests/testthat.R’ failed.
  Complete output:
    > library(testthat)
    > library(gitdown)
    > 
    > test_check("gitdown")
       inline R code fragments
    
    /usr/bin/pandoc +RTS -K512m -RTS index.knit.md --to html4 --from markdown+autolink_bare_uris+tex_math_single_backslash --output index.html --lua-filter /home/hornik/lib/R/Library/4.2/x86_64-linux-gnu/bookdown/rmarkdown/lua/custom-environment.lua --lua-filter /home/hornik/lib/R/Library/4.2/x86_64-linux-gnu/rmarkdown/rmarkdown/lua/pagebreak.lua --lua-filter /home/hornik/lib/R/Library/4.2/x86_64-linux-gnu/rmarkdown/rmarkdown/lua/latex-div.lua --metadata-file /home/hornik/tmp/scratch/RtmpCWdyBB/file7d733b313979 --wrap preserve --standalone --section-divs --table-of-contents --toc-depth 3 --template /home/hornik/lib/R/Library/4.2/x86_64-linux-gnu/bookdown/templates/gitbook.html --highlight-style pygments --number-sections --css style.css --include-in-header /home/hornik/tmp/scratch/RtmpCWdyBB/rmarkdown-str7d7359f98eda.html --mathjax 
       inline R code fragments
    
    /usr/bin/pandoc +RTS -K512m -RTS index.knit.md --to html4 --from markdown+autolink_bare_uris+tex_math_single_backslash --output index.html --lua-filter /home/hornik/lib/R/Library/4.2/x86_64-linux-gnu/bookdown/rmarkdown/lua/custom-environment.lua --lua-filter /home/hornik/lib/R/Library/4.2/x86_64-linux-gnu/rmarkdown/rmarkdown/lua/pagebreak.lua --lua-filter /home/hornik/lib/R/Library/4.2/x86_64-linux-gnu/rmarkdown/rmarkdown/lua/latex-div.lua --metadata-file /home/hornik/tmp/scratch/RtmpCWdyBB/file7d73ab9af20 --wrap preserve --standalone --section-divs --table-of-contents --toc-depth 3 --template /home/hornik/lib/R/Library/4.2/x86_64-linux-gnu/bookdown/templates/gitbook.html --highlight-style pygments --number-sections --css style.css --include-in-header /home/hornik/tmp/scratch/RtmpCWdyBB/rmarkdown-str7d732491a00f.html --mathjax 
       inline R code fragments
    
    /usr/bin/pandoc +RTS -K512m -RTS index.knit.md --to html4 --from markdown+autolink_bare_uris+tex_math_single_backslash --output index.html --lua-filter /home/hornik/lib/R/Library/4.2/x86_64-linux-gnu/bookdown/rmarkdown/lua/custom-environment.lua --lua-filter /home/hornik/lib/R/Library/4.2/x86_64-linux-gnu/rmarkdown/rmarkdown/lua/pagebreak.lua --lua-filter /home/hornik/lib/R/Library/4.2/x86_64-linux-gnu/rmarkdown/rmarkdown/lua/latex-div.lua --metadata-file /home/hornik/tmp/scratch/RtmpCWdyBB/file7d73484a95e0 --wrap preserve --standalone --section-divs --table-of-contents --toc-depth 3 --template /home/hornik/lib/R/Library/4.2/x86_64-linux-gnu/bookdown/templates/gitbook.html --highlight-style pygments --number-sections --css style.css --include-in-header /home/hornik/tmp/scratch/RtmpCWdyBB/rmarkdown-str7d736c53e814.html --mathjax 
       inline R code fragments
    
    /usr/bin/pandoc +RTS -K512m -RTS index.knit.md --to html4 --from markdown+autolink_bare_uris+tex_math_single_backslash --output index.html --lua-filter /home/hornik/lib/R/Library/4.2/x86_64-linux-gnu/bookdown/rmarkdown/lua/custom-environment.lua --lua-filter /home/hornik/lib/R/Library/4.2/x86_64-linux-gnu/rmarkdown/rmarkdown/lua/pagebreak.lua --lua-filter /home/hornik/lib/R/Library/4.2/x86_64-linux-gnu/rmarkdown/rmarkdown/lua/latex-div.lua --metadata-file /home/hornik/tmp/scratch/RtmpCWdyBB/file7d731cd346d9 --wrap preserve --standalone --section-divs --table-of-contents --toc-depth 3 --template /home/hornik/lib/R/Library/4.2/x86_64-linux-gnu/bookdown/templates/gitbook.html --highlight-style pygments --number-sections --css style.css --include-in-header /home/hornik/tmp/scratch/RtmpCWdyBB/rmarkdown-str7d731bf79f3e.html --mathjax 
    ══ Failed tests ════════════════════════════════════════════════════════════════
    ── Failure (test-get_info_files.R:13:3): get_info works ────────────────────────
    as.Date(infos$first_modif) not equal to setNames(today, "first").
    Mean relative difference: 5.329638e-05
    ── Failure (test-get_info_files.R:14:3): get_info works ────────────────────────
    as.Date(infos$last_modif) not equal to setNames(today, "last").
    Mean relative difference: 5.329638e-05
    ── Failure (test-get_info_files.R:19:3): get_info works ────────────────────────
    as.Date(infos_not_in_repo$last_modif) not equal to setNames(today, "last").
    Mean relative difference: 5.329638e-05
    
    [ FAIL 3 | WARN 0 | SKIP 0 | PASS 72 ]
    Error: Test failures
    Execution halted

https://cran.r-project.org/web/checks/check_results_gitdown.html lists the same issue.

I hope it is not an issue related to the update of stringi?
Weird that it's only present under r-devel-windows-x86_64-gcc10-UCRT...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.