我尝试进行gerrit-cherry-pick
时遇到以下错误,我做了git remote -v
,可以看到origin
指向ssh://waccount@tech-gerrit.sd.company.com:29418/tech-ci.git
,有人可以提供指导吗为什么会遇到此错误?如何进一步调试此修复程序?
2018-08-09 21:13:15 change-merged runCmd 169 INFO : Running command git --git-dir=/gerrit_v2/hooks/tech_projects/tech-ci/.git --work-tree=/gerrit_v2/hooks/tech_projects/tech-ci remote -v
2018-08-09 21:13:15 change-merged runCmd 173 INFO :
origin ssh://waccount@tech-gerrit.sd.company.com:29418/tech-ci.git (fetch)
origin ssh://waccount@tech-gerrit.sd.company.com:29418/tech-ci.git (push)
2018-08-09 21:13:15 change-merged runCmd2 180 INFO : Running command /gerrit_v2/hooks/gerrit-cherry-pick origin 20633/2
2018-08-09 21:13:15 change-merged runCmd2 187 INFO : fatal: 'origin' does not appear to be a git repository
fatal: The remote end hung up unexpectedly
樱桃樱桃采摘:
usage() {
echo >&2 "usage: $0 remote changeid..."
echo >&2 "usage: $0 --continue"
echo >&2 "usage: $0 --skip"
echo >&2 "usage: $0 --abort"
echo >&2 "usage: $0 [--close|--replace] remote"
exit 1
}
die() {
echo >&2 "fatal: $1"
exit 1
}
GIT_DIR=$(git rev-parse --git-dir) || exit
CL="$GIT_DIR/GERRIT_CHANGES"
STATE="$GIT_DIR/rebase-gerrit"
TODO="$STATE/todo"
RESOLVEMSG="
When you have resolved this problem run \"$0 --continue\".
If you would prefer to skip this patch, run \"$0 --skip\".
"
pop_action() {
sed -e 1d <"$TODO" >>"$TODO".new
mv -f "$TODO".new "$TODO"
}
mark_done() {
read commit changeid <"$TODO"
changeid=$(get_changeid "$changeid")
head_after=$(git rev-parse HEAD^0)
head_before=$(cat "$STATE/head_before")
if ! test $head_after = $head_before
then
echo $head_after >"$CL/$changeid"
fi
pop_action
}
do_next() {
while test -s "$TODO"
do
read commit changeid <"$TODO"
git rev-parse HEAD^0 >"$STATE/head_before"
git format-patch \
-k --stdout --full-index --ignore-if-in-upstream \
$commit^..$commit |
git am $git_am_opt --rebasing --resolvemsg="$RESOLVEMSG" || exit
mark_done
done
echo >&2 "Done."
rm -rf "$STATE"
}
git_am_opt=
if test -f "$STATE/git_am_opt"
then
git_am_opt=$(cat "$STATE/git_am_opt")
fi
while test $# != 0
do
case "$1" in
--continue)
test -f "$TODO" || die "No cherry-pick in progress?"
git am $git_am_opt --rebasing --resolvemsg="$RESOLVEMSG" --resolved || exit
mark_done
do_next
exit
;;
--skip)
test -f "$TODO" || die "No cherry-pick in progress?"
git reset --hard HEAD || exit
git am --skip || exit
pop_action
do_next
exit
;;
--abort)
test -f "$TODO" || die "No cherry-pick in progress?"
git reset --hard HEAD
git am --skip
rm -rf "$STATE"
;;
--close|--replace)
shift
test -d "$CL" || die "No changes to close"
test $# = 1 || usage
remote=$1
printf %s "git push $remote" >&2
rs=$(cd "$CL" && for change_id in *; do
test "$change_id" = '*' && die "No changes to close"
c=$(cat "$change_id");
echo "$c:refs/changes/$change_id";
echo ' \' >&2;
printf %s " $c:refs/changes/$change_id" >&2
done)
echo >&2
echo >&2
git push $remote $rs
rc=$?
test $rc = 0 && rm -rf "$CL"
exit $rc
;;
--whitespace=*)
git_am_opt="$git_am_opt $1"
;;
--committer-date-is-author-date|--ignore-date)
git_am_opt="$git_am_opt $1"
;;
-C*)
git_am_opt="$git_am_opt $1"
;;
-s|--signoff)
git_am_opt="$git_am_opt $1"
;;
-*)
usage
;;
*)
break
;;
esac
shift
done
get_changeid() {
case $1 in
*/*) echo ${1%%/*} ;;
*) echo $1 ;;
esac
}
to_ref() {
case $1 in
*/*)
change_id=${1%%/*}
patchset_id=${1##*/}
;;
*)
change_id=$1
patchset_id=1
;;
esac
hash=$(($change_id % 100))
case $hash in
[0-9]) hash="0$hash" ;;
esac
echo "refs/changes/$hash/$change_id/$patchset_id"
}
get_revid() {
grep $(to_ref $1) <"$GIT_DIR/FETCH_HEAD" | cut -f1
}
# Initialize state
#
test $# -lt 2 && usage
remote="$1"
shift
mkdir "$STATE" || die "cherry-pick already in progress"
echo $git_am_opt >"$STATE/git_am_opt"
if ! git fetch $remote $(for id; do to_ref $id; done)
then
rm -rf $STATE
exit 1
fi
(for id
do
if revid=$(get_revid $id)
then
echo "$revid $id"
else
echo >&2 "fatal: $id not found"
exit 1
fi
done) >"$TODO"
mkdir -p "$CL"
echo >&2
do_next
答案 0 :(得分:0)
这表示发出该命令的用户帐户未在~/.ssh/id_rsa.pub
服务器上的~waccount/.ssh/authorized_keys
中注册其tech-gerrit.sd.company.com
默认的公共SSH密钥。
如果可能,请尝试以相同的命令顺序执行
ssh -Tv -p 2941 waccount@tech-gerrit.sd.company.com
这将显示有关失败的连接尝试的更多详细信息。
如果不可能,请尝试确保将环境变量GIT_SSH_COMMAND
设置为'ssh -v
'。
答案 1 :(得分:0)
似乎您是在裸存储库(Gerrit存储库)中而不是工作树(存储库克隆)中执行命令。请记住,挂钩是在Gerrit存储库中执行的,可以触发它们。