Skip to content

Commit 841b63c

Browse files
committed
add 'collate_pkgstats' fn
1 parent a492882 commit 841b63c

File tree

4 files changed

+45
-6
lines changed

4 files changed

+45
-6
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.0.1.007
3+
Version: 0.0.1.008
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

+32-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,37 @@ githist <- function (path) {
1111
h <- gert::git_log (repo = path_cp, max = 1e6)
1212

1313
res <- pbapply::pblapply (seq_len (nrow (h)), function (i) {
14-
g <- gert::git_reset_soft (ref = h$commit [i], repo = path_cp)
15-
run_one_pkgstats (path = path_cp)
14+
g <- gert::git_reset_hard (ref = h$commit [i], repo = path_cp)
15+
pkg_date <- h$time [i]
16+
run_one_pkgstats (path = path_cp, pkg_date = pkg_date)
1617
})
18+
19+
collate_pkgstats (res)
20+
}
21+
22+
collate_pkgstats <- function (x) {
23+
nms <- names (x [[1]])
24+
nms2df <- nms [seq_len (which (nms == "loc") - 1L)]
25+
desc_data <- lapply (nms2df, function (i) {
26+
unlist (lapply (x, function (j) j [[i]]))
27+
})
28+
desc_data <- data.frame (do.call (cbind, desc_data))
29+
names (desc_data) <- nms2df
30+
desc_data$date <- lapply (x, function (i) strftime (i$date, "%y-%m-%d %H:%M:%S"))
31+
32+
nms_int <- nms2df [-seq_len (which (nms2df == "date"))]
33+
for (n in nms_int) {
34+
desc_data [[n]] <- as.integer (desc_data [[n]])
35+
}
36+
37+
loc <- do.call (rbind, lapply (x, function (i) i$loc))
38+
stats <- do.call (rbind, lapply (x, function (i) i$stats))
39+
stats$measure <- gsub ("[0-9]+$", "", rownames (stats))
40+
rownames (stats) <- NULL
41+
42+
list (
43+
desc_data = desc_data,
44+
loc = loc,
45+
stats = stats
46+
)
1747
}

R/pkgstats-data.R

+11-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
run_one_pkgstats <- function (path) {
1+
run_one_pkgstats <- function (path, pkg_date) {
22

33
s <- pkgstats::pkgstats (path)
44

@@ -26,18 +26,27 @@ run_one_pkgstats <- function (path) {
2626
n_ext_pkgs <- nrow (ext_calls) - 1L
2727
ext_calls <- mn_med_sum (ext_calls$n [ext_calls$package != "base"])
2828

29+
s$loc <- cbind (
30+
package = s$desc$package,
31+
version = s$desc$version,
32+
date = pkg_date,
33+
s$loc
34+
)
2935

3036
list (
3137
package = s$desc$package,
3238
version = s$desc$version,
33-
date = s$desc$date,
39+
date = pkg_date,
3440
n_aut = s$desc$aut,
3541
n_ctb = s$desc$ctb,
3642
n_fns = n_fns,
3743
n_ext_pkgs = n_ext_pkgs,
3844
base_calls = base_calls,
3945
loc = s$loc,
4046
stats = data.frame (
47+
package = s$desc$package,
48+
version = s$desc$version,
49+
date = pkg_date,
4150
doclines = doclines,
4251
npars = npars,
4352
loc = loc,

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.0.1.007",
11+
"version": "0.0.1.008",
1212
"programmingLanguage": {
1313
"@type": "ComputerLanguage",
1414
"name": "R",

0 commit comments

Comments
 (0)