R 获取运行时使用的版本的SHA
是否可以获取正在R中运行的代码版本的SHA 我有以下代码,它从总负责人那里输出SHA:R 获取运行时使用的版本的SHA,r,git,R,Git,是否可以获取正在R中运行的代码版本的SHA 我有以下代码,它从总负责人那里输出SHA: readme<-file("info.txt") writeLines(paste(c("Document produced using Version", paste(readChar("./.git/refs/heads/master", 10)), "of code")), readme) clo
readme<-file("info.txt")
writeLines(paste(c("Document produced using Version",
paste(readChar("./.git/refs/heads/master", 10)),
"of code")),
readme)
close(readme)
我认为您只需要运行
git rev parse HEAD
(只有当当前分支是master
并且master
不是“打包”引用时,读取文件master
才有效)。但我不确定在R中如何实现这一点。读取/.git/refs/heads/master
无论如何都不会起作用,即使是从master运行,因为git也可以打包refs。有关更多信息,请参阅。:(好的,无论如何,谢谢!我知道这有点长。
readme<-file("Code version info.txt")
writeLines(paste(c("Document produced using Version",
paste(readChar(paste("./.git/refs/heads/", ACTIVEBRANCH, collapse = ""),
10)),
"of Git Instructions")),
readme)
close(readme)