-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathappendix-document-metadata.qmd
More file actions
41 lines (33 loc) · 1.57 KB
/
appendix-document-metadata.qmd
File metadata and controls
41 lines (33 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# Document Generation Metadata {.unnumbered}
This document was generated from the following git commit:
```{r}
#| echo: false
#| output: asis
# Get git branch
branch <- system2("git", c("rev-parse", "--abbrev-ref", "HEAD"),
stdout = TRUE, stderr = NULL)
if (length(branch) == 0 || branch == "" || branch == "HEAD") {
# In CI or detached HEAD state, try to get branch from environment variables
branch <- Sys.getenv("GITHUB_HEAD_REF", "")
if (branch == "") branch <- Sys.getenv("GITHUB_REF_NAME", "unknown")
}
# Get short commit hash
commit_short <- system2("git", c("rev-parse", "--short", "HEAD"),
stdout = TRUE, stderr = NULL)
if (length(commit_short) == 0 || commit_short == "") commit_short <- "unknown"
# Get full commit hash
commit_full <- system2("git", c("rev-parse", "HEAD"),
stdout = TRUE, stderr = NULL)
if (length(commit_full) == 0 || commit_full == "") commit_full <- "unknown"
# Get commit date
commit_date <- system2("git", c("show", "-s", "--format=%ci", "HEAD"),
stdout = TRUE, stderr = NULL)
if (length(commit_date) == 0 || commit_date == "") commit_date <- "unknown"
# Print formatted output
cat("- **Branch:**", branch, "\n")
cat("- **Commit:**", commit_short, "\n")
cat("- **Full commit hash:**", commit_full, "\n")
cat("- **Commit date:**", commit_date, "\n")
```
When transferring edits from this document back to the Quarto source files,
use this commit information to set up the PR correctly and account for any commits that have been added since this document was generated.