2

我正在尝试第一次使用 git 设置 gerrit。我正在按照https://www.mediawiki.org/wiki/Gerrit/Tutorial的说明进行操作。我已经安装了 git,创建了一个 gerrit 用户帐户,并设置了我的 ssh 密钥,现在运行后sudo apt-get install git-reviewgit review -s -v在我的 git 目录中运行并得到以下输出:

2018-06-28 08:54:15.098084 Running: git config --get gitreview.remote
2018-06-28 08:54:15.102217 result: origin
2018-06-28 08:54:15.102337 Running: git config --get gitreview.scheme
2018-06-28 08:54:15.106441 using default: None
2018-06-28 08:54:15.106556 Running: git config --get gitreview.hostname
2018-06-28 08:54:15.111010 using default: None
2018-06-28 08:54:15.111106 Running: git config --get gitreview.port
2018-06-28 08:54:15.116715 using default: None
2018-06-28 08:54:15.116873 Running: git config --get gitreview.project
2018-06-28 08:54:15.121874 using default: None
2018-06-28 08:54:15.122029 Running: git log --color=never --oneline HEAD^1..HEAD
2018-06-28 08:54:15.127908 Running: git remote
2018-06-28 08:54:15.134383 Running: git branch -a --color=never
2018-06-28 08:54:15.141301 Running: git rev-parse --show-toplevel --git-dir
2018-06-28 08:54:15.147041 Running: git config --get remote.origin.pushurl
2018-06-28 08:54:15.152315 using default: None
2018-06-28 08:54:15.152473 Running: git config --get remote.origin.url
2018-06-28 08:54:15.157253 result: file:///home/jd/gitrepos/newrepo
2018-06-28 08:54:15.157356 Running: git config --list
Found origin Push URL: file:///home/jd/gitrepos/newrepo
Fetching commit hook from: scp:///hooks/commit-msg
2018-06-28 08:54:15.163017 Running: scp :hooks/commit-msg .git/hooks/commit-msg
Problems encountered installing commit-msg hook
The following command failed with exit code 1
    "scp :hooks/commit-msg .git/hooks/commit-msg"
-----------------------
cp: cannot stat ':hooks/commit-msg': No such file or directory

因此,我尝试使用此链接中的说明手动在挂钩中预先安装 commit-msg:https ://www.mediawiki.org/wiki/Gerrit/Alternatives_to_git-review ,它修复了出现此特定错误。但在那之后运行 `git review -s -v' 实际上似乎并没有做任何事情。这是输出:

2018-06-28 09:07:13.356813 Running: git config --get gitreview.remote
2018-06-28 09:07:13.360779 result: origin
2018-06-28 09:07:13.360892 Running: git config --get gitreview.scheme
2018-06-28 09:07:13.364968 using default: None
2018-06-28 09:07:13.365102 Running: git config --get gitreview.hostname
2018-06-28 09:07:13.369144 using default: None
2018-06-28 09:07:13.369363 Running: git config --get gitreview.port
2018-06-28 09:07:13.375098 using default: None
2018-06-28 09:07:13.375383 Running: git config --get gitreview.project
2018-06-28 09:07:13.380644 using default: None
2018-06-28 09:07:13.380934 Running: git log --color=never --oneline HEAD^1..HEAD
2018-06-28 09:07:13.387931 Running: git remote
2018-06-28 09:07:13.396294 Running: git branch -a --color=never
2018-06-28 09:07:13.403513 Running: git rev-parse --show-toplevel --git-dir

我以为git review -s应该设置一个 gerrit 遥控器,但现在当我运行时,git remote -v我看到的是:

origin  file:///home/jd/gitrepos/newrepo (fetch)
origin  file:///home/jd/gitrepos/newrepo (push)

格里特没有。

我被困在这里,我认为这可能是我的 .gitreview 文件的问题。我已经研究了一段时间,所以我已经阅读了许多各种各样的说明,现在我在我的存储库中有一个手动创建的 .gitreview 文件,其中包含以下内容:

[gerrit]
host=gerrit.wikimedia.org
project=newrepo.git

关于我的设置的更多背景信息:我的存储库位于 ~/gitrepos/newrepo 中,我正在从该位置拉到 ~/gitworkspace/newrepo。它来自 ~/gitworkspace/newrepo,我在其中运行所有这些命令来尝试设置 gerrit。我最终希望能够从 ~/gitworkspace/newrepo 推送,并在批准将其推送到 ~/gitrepos/newrepo 之前查看有关 gerrit 的评论。

4

1 回答 1

0

这些行:

2018-06-28 09:07:13.356813 Running: git config --get gitreview.remote
2018-06-28 09:07:13.360779 result: origin

表明默认遥控器是origin并且看起来确实设置了该遥控器。所以这似乎按预期工作。

您指出的另一个问题是 git-review 无法复制 commit-msg 挂钩。这个我不太确定。看起来 gerrit 找不到 commit-msg 挂钩。这使我认为这是两个原因之一:

  1. 提交钩子不在它应该在的地方(你的 gerrit 安装不是默认的吗?)
  2. 您的遥控器在 gerrit 内未正确配置,因此对该遥控器的 scp 调用无法正常工作。

我的猜测是因为你的遥控器不在

于 2018-06-29T14:06:33.283 回答