add version
This commit is contained in:
+64
@@ -0,0 +1,64 @@
|
||||
---
|
||||
subtitle: "Version"
|
||||
author: ""
|
||||
---
|
||||
|
||||
### Branches
|
||||
|
||||
|
||||
```{r}
|
||||
#| echo: false
|
||||
#| output: asis
|
||||
|
||||
tibble::tibble(branch = system("git branch -a", intern = TRUE)) |>
|
||||
dplyr::filter(grepl("remotes", branch)) |>
|
||||
dplyr::filter(!grepl("HEAD", branch)) |>
|
||||
dplyr::mutate(branch = gsub("^.*\\/", "", branch)) |>
|
||||
dplyr::mutate(
|
||||
htmlstr = paste0(
|
||||
"## [**Version**: ",
|
||||
branch,
|
||||
"](https://drc.drwater.net/{{< var projtype >}}/{{< var pubtype >}}/{{< var reponame >}}/",
|
||||
branch,
|
||||
"/)<br><br>"
|
||||
)
|
||||
) |>
|
||||
dplyr::pull(htmlstr) |>
|
||||
paste(collapse = "") |>
|
||||
cat()
|
||||
```
|
||||
|
||||
### Versions
|
||||
|
||||
```{r}
|
||||
#| echo: false
|
||||
#| output: asis
|
||||
|
||||
# 方法2:先获取分支列表,再逐个查询
|
||||
branches <- system("git branch -r", intern = TRUE)
|
||||
branches <- trimws(branches) # 去除空白字符
|
||||
branches <- branches[!grepl("HEAD", branches)]
|
||||
|
||||
all_commits <- list()
|
||||
|
||||
cat("\n")
|
||||
for (branch in branches) {
|
||||
if (branch != "") {
|
||||
cat("### ", gsub("^.*/", "", branch), "\n\n")
|
||||
commits <- system(
|
||||
paste0(
|
||||
"git log --pretty=format:\"%h - %an, %ar : %s\" -5 \"",
|
||||
branch,
|
||||
"\""
|
||||
),
|
||||
intern = TRUE
|
||||
)
|
||||
all_commits[[branch]] <- paste0("- ", commits)
|
||||
cat("\n")
|
||||
cat(paste0("- ", commits), sep = "\n")
|
||||
cat("\n\n")
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user