Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 获取运行时使用的版本的SHA_R_Git - Fatal编程技术网

R 获取运行时使用的版本的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

是否可以获取正在R中运行的代码版本的SHA

我有以下代码,它从总负责人那里输出SHA:

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)