【问题标题】:git commit throws error '[<-'git commit 抛出错误'[<-'
【发布时间】:2016-12-04 03:11:35
【问题描述】:

有没有人有想法,我该如何解决这个问题? git commit -a -m "message here 适用于其他项目,并且今天之前的提交都可以。 现在,它抛出错误:

[&lt;-(*tmp*, 1, "Date", value = "2016-07-29") 中的错误:
Indizierung außerhalb der Grenzen
安然无恙

错误信息类似于:

索引超出范围

如果您需要更多信息,请告诉我。

这是截图:

编辑:@Carsten 猜对了!我有一个钩子在运行。但我不明白为什么它应该从一分钟停止工作......(它仍然不起作用)

#!C:/R/R-3.2.2/bin/x64/Rscript

# License: CC0 (just be nice and point others to where you got this)
# Author: Robert M Flight <rflight79@gmail.com>, github.com/rmflight
inc <- TRUE # default
# get the environment variable and modify if necessary
tmpEnv <- as.logical(Sys.getenv("inc"))
if (!is.na(tmpEnv)) {
  inc <- tmpEnv
}

# check that there are files that will be committed, don't want to increment version if there won't be a commit
fileDiff <- system("git diff HEAD --name-only", intern = TRUE)

if ((length(fileDiff) > 0) && inc) {

  currDir <- getwd() # this should be the top level directory of the git repo
  currDCF <- read.dcf("DESCRIPTION")
  currVersion <- currDCF[1,"Version"]
  splitVersion <- strsplit(currVersion, ".", fixed = TRUE)[[1]]
  nVer <- length(splitVersion)
  currEndVersion <- as.integer(splitVersion[nVer])
  newEndVersion <- as.character(currEndVersion + 1)
  splitVersion[nVer] <- newEndVersion
  newVersion <- paste(splitVersion, collapse = ".")
  currDCF[1,"Version"] <- newVersion
  currDCF[1, "Date"] <- strftime(as.POSIXlt(Sys.Date()), "%Y-%m-%d")
  write.dcf(currDCF, "DESCRIPTION")
  system("git add DESCRIPTION")
  cat("Incremented package version and added to commit!\n")
}

【问题讨论】:

  • 最后缺少 " 有帮助吗?
  • 没有。我从 RStudio 和终端尝试过……我还尝试了git init,重新启动 RStudio,重新启动笔记本电脑。我什至 reverted 对上一个提交进行了拉取,做了一个微小的更改 - 但即便如此,一个简单的提交 git commit -a -m "Test"throwed 错误。
  • 输出看起来更像是“R”错误而不是 git 错误。也许一个 git 钩子失败了?查看文件夹.git/hooks/,您可能会发现一个文件prepare-commit-msg 或pre-commit 执行一些R 脚本。欲了解更多信息,请参阅git-scm.com/docs/githooks
  • @Carsten:谢谢你的提示。我对 R 代码感到惊讶,但现在它变得有意义了。你知道我该如何解决这个问题吗?我张贴了钩子,但不知道如何在钩子中大喊大叫。

标签: r windows git rstudio githooks


【解决方案1】:

感谢@Carsten:使用print 语句,我可以跟踪挂钩文件中的错误。最后这是一个愚蠢的错误,Date 在description 文件中被意外删除(=丢失)。

【讨论】:

    猜你喜欢
    • 2021-07-04
    • 1970-01-01
    • 2018-03-03
    • 2016-06-26
    • 2018-06-06
    • 2010-12-24
    • 1970-01-01
    • 1970-01-01
    • 2018-09-03
    相关资源
    最近更新 更多