metrumresearchgroup / ghpm

BSD 3-Clause Clear License
1 stars 0 forks source link

conventional commits parsing incorrect regex/brittleness #6

Closed dpastoor closed 4 years ago

dpastoor commented 4 years ago

In the provided vignette:

get_pull_request_commits("metrumresearchgroup", "pkgr", 149, .cc = TRUE)
Error in stri_replace_all_regex(string, pattern, fix_replacement(replacement), : Incorrectly nested parentheses in regexp pattern. (U_REGEX_MISMATCHED_PAREN)

9. | stri_replace_all_regex(string, pattern, fix_replacement(replacement), vectorize_all = vec, opts_regex = opts(pattern))
-- | --
8. str_replace_all(commit_message, commit_summary, "") at pull_request_commits.R#61

7. 7.
parse_body(str_replace_all(commit_message, commit_summary, "")) at pull_request_commits.R#61

...
Blackglade commented 4 years ago

So the reason this is breaking is because on this commit (chore: putting back contents of simple integration test (accidentally deleted before,

https://github.com/metrumresearchgroup/pkgr/pull/149/commits/7d98017b08483fa7255c4151d7d998eb8e42b7ae

on the commit_summary it has an loose parenthesis

chore: putting back contents of simple integration test (accidentally

So the function is trying to do this:

stringr::str_replace_all("chore: putting back contents of simple integration test (accidentally deleted before)", "chore: putting back contents of simple integration test (accidentally…", "")
Blackglade commented 4 years ago

Replacing str_replace_all with gsub and setting fixed = TRUE resolved this issue. Also added in a test for broken regex characters in the commit