Skip to content

Commit 8a5898e

Browse files
committed
separate 'extract_pkgstats_data' with main loop for #1
1 parent 5148451 commit 8a5898e

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

DESCRIPTION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: githist
22
Title: Code analyses traced along the 'git' history of a package
3-
Version: 0.1.0.028
3+
Version: 0.1.0.029
44
Authors@R:
55
person("Mark", "Padgham", , "mark.padgham@email.com", role = c("aut", "cre"),
66
comment = c(ORCID = "0000-0003-2172-5265"))

R/githist-fn.R

+13-5
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ githist <- function (path, n = NULL, step_size = 1L, num_cores = -1L) {
3535
}
3636
checkmate::assert_int (num_cores)
3737

38+
num_cores <- set_num_cores (num_cores)
39+
3840
path_cp <- fs::path (fs::path_temp (), basename (path))
3941
clean_after <- FALSE
4042
if (fs::path (fs::path_dir (path)) != fs::path_temp () &&
@@ -51,11 +53,7 @@ githist <- function (path, n = NULL, step_size = 1L, num_cores = -1L) {
5153
h <- h [seq_len (n), ]
5254
}
5355

54-
res <- pbapply::pblapply (seq_len (nrow (h)), function (i) {
55-
g <- gert::git_reset_hard (ref = h$commit [i], repo = path_cp)
56-
pkg_date <- h$time [i]
57-
run_one_pkgstats (path = path_cp, pkg_date = pkg_date)
58-
})
56+
res <- extract_pkgstats_data (h, path_cp, num_cores)
5957

6058
if (clean_after) {
6159
fs::dir_delete (path_cp)
@@ -64,6 +62,16 @@ githist <- function (path, n = NULL, step_size = 1L, num_cores = -1L) {
6462
collate_pkgstats (res)
6563
}
6664

65+
extract_pkgstats_data <- function (log, path, num_cores) {
66+
67+
res <- pbapply::pblapply (seq_len (nrow (log)), function (i) {
68+
g <- gert::git_reset_hard (ref = log$commit [i], repo = path)
69+
run_one_pkgstats (path = path, pkg_date = log$time [i])
70+
})
71+
72+
return (res)
73+
}
74+
6775
collate_pkgstats <- function (x) {
6876
nms <- names (x [[1]])
6977
nms2df <- nms [seq_len (which (nms == "loc") - 1L)]

codemeta.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"codeRepository": "https://github.com/ropensci-review-tools/githist",
99
"issueTracker": "https://github.com/ropensci-review-tools/githist/issues",
1010
"license": "https://spdx.org/licenses/GPL-3.0",
11-
"version": "0.1.0.028",
11+
"version": "0.1.0.029",
1212
"programmingLanguage": {
1313
"@type": "ComputerLanguage",
1414
"name": "R",

0 commit comments

Comments
 (0)