区域水环境污染数据分析实践

Version

Published

May 20, 2026

Branches

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::arrange(desc(branch)) |>
  dplyr::mutate(
    htmlstr = paste0(
      "## [**Version**: ",
      branch,
      "](https://drc.drwater.net/course/",
      ifelse(grepl("pub", branch, ignore.case = TRUE), "public", "protected"),
      "/su2026rwep/",
      branch,
      "/)"
    )
  ) |>
  dplyr::pull(htmlstr) |>
  paste(collapse = "\n\n") |>
  cat()

Version: PUB

Versions

# 方法2:先获取分支列表,再逐个查询
branches <- system("git branch -r", intern = TRUE)
branches <- trimws(branches) # 去除空白字符
branches <- branches[!grepl("HEAD", branches)]
branches <- tibble::tibble(branch = branches) |>
  dplyr::arrange(dplyr::desc(branch)) |>
  dplyr::pull(branch)

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(paste0("- ", commits), sep = "\n")
    cat("\n")
  }
}

PUB

  • 8288dac - ming, 54 seconds ago : render compile
  • 1dcd453 - ming, 6 minutes ago : render compile
  • 32a2989 - ming, 8 minutes ago : render compile
  • 845b840 - ming, 35 minutes ago : render compile
  • 61bd0be - ming, 2 hours ago : add _extensions