1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-11-01 14:57:52 +01:00

remote-hg: add check_push() helper

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Felipe Contreras 2013-05-24 21:29:59 -05:00 committed by Junio C Hamano
parent 2b02a40587
commit 42cbbcc73b

View file

@ -48,6 +48,38 @@ check_bookmark () {
fi
}
check_push () {
local expected_ret=$1 ret=0 ref_ret=0 IFS=':'
shift
git push origin "$@" 2> error
ret=$?
cat error
while read branch kind
do
case "$kind" in
'new')
grep "^ \* \[new branch\] *${branch} -> ${branch}$" error || ref_ret=1
;;
'non-fast-forward')
grep "^ ! \[rejected\] *${branch} -> ${branch} (non-fast-forward)$" error || ref_ret=1
;;
'')
grep "^ [a-f0-9]*\.\.[a-f0-9]* *${branch} -> ${branch}$" error || ref_ret=1
;;
esac
let 'ref_ret' && echo "match for '$branch' failed" && break
done
if let 'expected_ret != ret || ref_ret'
then
return 1
fi
return 0
}
setup () {
(
echo "[ui]"
@ -344,8 +376,9 @@ test_expect_success 'remote push diverged' '
cd gitrepo &&
echo diverge > content &&
git commit -a -m diverged &&
test_expect_code 1 git push 2> error &&
grep "^ ! \[rejected\] *master -> master (non-fast-forward)$" error
check_push 1 <<-EOF
master:non-fast-forward
EOF
) &&
check_branch hgrepo default bump
@ -373,8 +406,9 @@ test_expect_success 'remote update bookmark diverge' '
git checkout --quiet diverge &&
echo diverge > content &&
git commit -a -m diverge &&
test_expect_code 1 git push 2> error &&
grep "^ ! \[rejected\] *diverge -> diverge (non-fast-forward)$" error
check_push 1 <<-EOF
diverge:non-fast-forward
EOF
) &&
check_bookmark hgrepo diverge "bump bookmark"
@ -468,19 +502,17 @@ test_expect_success 'remote big push' '
(
cd gitrepo &&
test_expect_code 1 git push origin master \
good_bmark bad_bmark1 bad_bmark2 new_bmark \
branches/good_branch branches/bad_branch \
branches/new_branch 2> error &&
grep "^ [a-f0-9]*\.\.[a-f0-9]* *master -> master$" error &&
grep "^ [a-f0-9]*\.\.[a-f0-9]* *good_bmark -> good_bmark$" error &&
grep "^ \* \[new branch\] *new_bmark -> new_bmark$" error &&
grep "^ ! \[rejected\] *bad_bmark2 -> bad_bmark2 (non-fast-forward)$" error &&
grep "^ ! \[rejected\] *bad_bmark1 -> bad_bmark1 (non-fast-forward)$" error &&
grep "^ [a-f0-9]*\.\.[a-f0-9]* *branches/good_branch -> branches/good_branch$" error &&
grep "^ ! \[rejected\] *branches/bad_branch -> branches/bad_branch (non-fast-forward)$" error &&
grep "^ \* \[new branch\] *branches/new_branch -> branches/new_branch$" error
check_push 1 --all <<-EOF
master
good_bmark
branches/good_branch
new_bmark:new
branches/new_branch:new
bad_bmark1:non-fast-forward
bad_bmark2:non-fast-forward
branches/bad_branch:non-fast-forward
EOF
) &&
check_branch hgrepo default one &&