Skip to content

Commit

Permalink
Merge branch 'rh/remote-hg-bzr-updates'
Browse files Browse the repository at this point in the history
Updates to remote-bzr and remote-hg in contrib.

* rh/remote-hg-bzr-updates:
  remote-bzr, remote-hg: fix email address regular expression
  test-hg.sh: help user correlate verbose output with email test
  test-hg.sh: fix duplicate content strings in author tests
  test-hg.sh: avoid obsolete 'test' syntax
  test-hg.sh: eliminate 'local' bashism
  test-bzr.sh, test-hg.sh: prepare for change to push.default=simple
  test-bzr.sh, test-hg.sh: allow running from any dir
  test-lib.sh: convert $TEST_DIRECTORY to an absolute path
  • Loading branch information
Junio C Hamano committed Dec 6, 2013
2 parents 128c5d0 + 6c68a40 commit ef63eb5
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 24 deletions.
7 changes: 3 additions & 4 deletions contrib/remote-helpers/git-remote-bzr
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ import StringIO
import atexit, shutil, hashlib, urlparse, subprocess

NAME_RE = re.compile('^([^<>]+)')
AUTHOR_RE = re.compile('^([^<>]+?)? ?<([^<>]*)>$')
EMAIL_RE = re.compile('^([^<>]+[^ \\\t<>])?\\b(?:[ \\t<>]*?)\\b([^ \\t<>]+@[^ \\t<>]+)')
AUTHOR_RE = re.compile('^([^<>]+?)? ?[<>]([^<>]*)(?:$|>)')
EMAIL_RE = re.compile(r'([^ \t<>]+@[^ \t<>]+)')
RAW_AUTHOR_RE = re.compile('^(\w+) (.+)? <(.*)> (\d+) ([+-]\d+)')

def die(msg, *args):
Expand Down Expand Up @@ -193,8 +193,7 @@ def fixup_user(user):
else:
m = EMAIL_RE.match(user)
if m:
name = m.group(1)
mail = m.group(2)
mail = m.group(1)
else:
m = NAME_RE.match(user)
if m:
Expand Down
7 changes: 3 additions & 4 deletions contrib/remote-helpers/git-remote-hg
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ import time as ptime
#

NAME_RE = re.compile('^([^<>]+)')
AUTHOR_RE = re.compile('^([^<>]+?)? ?<([^<>]*)>$')
EMAIL_RE = re.compile('^([^<>]+[^ \\\t<>])?\\b(?:[ \\t<>]*?)\\b([^ \\t<>]+@[^ \\t<>]+)')
AUTHOR_RE = re.compile('^([^<>]+?)? ?[<>]([^<>]*)(?:$|>)')
EMAIL_RE = re.compile(r'([^ \t<>]+@[^ \t<>]+)')
AUTHOR_HG_RE = re.compile('^(.*?) ?<(.*?)(?:>(.+)?)?$')
RAW_AUTHOR_RE = re.compile('^(\w+) (?:(.+)? )?<(.*)> (\d+) ([+-]\d+)')

Expand Down Expand Up @@ -316,8 +316,7 @@ def fixup_user_git(user):
else:
m = EMAIL_RE.match(user)
if m:
name = m.group(1)
mail = m.group(2)
mail = m.group(1)
else:
m = NAME_RE.match(user)
if m:
Expand Down
5 changes: 3 additions & 2 deletions contrib/remote-helpers/test-bzr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

test_description='Test remote-bzr'

. ./test-lib.sh
test -n "$TEST_DIRECTORY" || TEST_DIRECTORY=${0%/*}/../../t
. "$TEST_DIRECTORY"/test-lib.sh

if ! test_have_prereq PYTHON
then
Expand Down Expand Up @@ -378,7 +379,7 @@ test_expect_success 'export utf-8 authors' '
git add content &&
git commit -m one &&
git remote add bzr "bzr::../bzrrepo" &&
git push bzr
git push bzr master
) &&
(
Expand Down
30 changes: 16 additions & 14 deletions contrib/remote-helpers/test-hg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@

test_description='Test remote-hg'

. ./test-lib.sh
test -n "$TEST_DIRECTORY" || TEST_DIRECTORY=${0%/*}/../../t
. "$TEST_DIRECTORY"/test-lib.sh

if ! test_have_prereq PYTHON
then
Expand Down Expand Up @@ -53,14 +54,14 @@ check_bookmark () {
}

check_push () {
local expected_ret=$1 ret=0 ref_ret=0 IFS=':'
expected_ret=$1 ret=0 ref_ret=0

shift
git push origin "$@" 2>error
ret=$?
cat error

while read branch kind
while IFS=':' read branch kind
do
case "$kind" in
'new')
Expand All @@ -82,7 +83,7 @@ check_push () {
test $ref_ret -ne 0 && echo "match for '$branch' failed" && break
done

if test $expected_ret -ne $ret -o $ref_ret -ne 0
if test $expected_ret -ne $ret || test $ref_ret -ne 0
then
return 1
fi
Expand Down Expand Up @@ -205,16 +206,17 @@ test_expect_success 'authors' '
>../expected &&
author_test alpha "" "H G Wells <wells@example.com>" &&
author_test beta "test" "test <unknown>" &&
author_test beta "test <test@example.com> (comment)" "test <test@example.com>" &&
author_test gamma "<test@example.com>" "Unknown <test@example.com>" &&
author_test delta "name<test@example.com>" "name <test@example.com>" &&
author_test epsilon "name <test@example.com" "name <test@example.com>" &&
author_test zeta " test " "test <unknown>" &&
author_test eta "test < test@example.com >" "test <test@example.com>" &&
author_test theta "test >test@example.com>" "test <test@example.com>" &&
author_test iota "test < test <at> example <dot> com>" "test <unknown>" &&
author_test kappa "test@example.com" "Unknown <test@example.com>"
author_test beta "beta" "beta <unknown>" &&
author_test gamma "gamma <test@example.com> (comment)" "gamma <test@example.com>" &&
author_test delta "<delta@example.com>" "Unknown <delta@example.com>" &&
author_test epsilon "epsilon<test@example.com>" "epsilon <test@example.com>" &&
author_test zeta "zeta <test@example.com" "zeta <test@example.com>" &&
author_test eta " eta " "eta <unknown>" &&
author_test theta "theta < test@example.com >" "theta <test@example.com>" &&
author_test iota "iota >test@example.com>" "iota <test@example.com>" &&
author_test kappa "kappa < test <at> example <dot> com>" "kappa <unknown>" &&
author_test lambda "lambda@example.com" "Unknown <lambda@example.com>" &&
author_test mu "mu.mu@example.com" "Unknown <mu.mu@example.com>"
) &&
git clone "hg::hgrepo" gitrepo &&
Expand Down
4 changes: 4 additions & 0 deletions t/test-lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ then
# outside of t/, e.g. for running tests on the test library
# itself.
TEST_DIRECTORY=$(pwd)
else
# ensure that TEST_DIRECTORY is an absolute path so that it
# is valid even if the current working directory is changed
TEST_DIRECTORY=$(cd "$TEST_DIRECTORY" && pwd) || exit 1
fi
if test -z "$TEST_OUTPUT_DIRECTORY"
then
Expand Down

0 comments on commit ef63eb5

Please sign in to comment.