From 3d9ca222d14355fa850cec113a280d9f6565b874 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Mon, 24 Apr 2017 17:51:30 +0300 Subject: Add remaining stuff from yarnhelpr to lib.py --- 000.yarn | 40 ++++++++++++++++++++-------------------- lib.py | 12 +++++++++--- 2 files changed, 29 insertions(+), 23 deletions(-) diff --git a/000.yarn b/000.yarn index adf3780..585aff9 100644 --- a/000.yarn +++ b/000.yarn @@ -312,8 +312,8 @@ WHEN admin created repository # Make a commit in master in the repo, push that. user = 'admin' - url = helper.repo_ssh_url(repo) - dirname = helper.local_checkout_dirname(user, repo) + url = repo_ssh_url(repo) + dirname = local_checkout_dirname(user, repo) git_as_checked(None, ['clone', url, dirname]) cliapp.runcmd(['git', 'config', 'user.email', user], cwd=dirname) cliapp.runcmd(['git', 'config', 'user.name', user], cwd=dirname) @@ -338,8 +338,8 @@ THEN a user can clone a repository IMPLEMENTS THEN (\S+) can clone (\S+) user = get_next_match() repo = get_next_match() - url = helper.repo_ssh_url(repo) - dirname = helper.local_checkout_dirname(user, repo) + url = repo_ssh_url(repo) + dirname = local_checkout_dirname(user, repo) git_as_checked(user, ['clone', url, dirname]) cliapp.runcmd(['git', 'config', 'user.email', user], cwd=dirname) cliapp.runcmd(['git', 'config', 'user.name', user], cwd=dirname) @@ -350,10 +350,10 @@ THEN a user can't clone a repository IMPLEMENTS THEN (\S+) cannot clone (\S+) user = get_next_match() repo = get_next_match() - url = helper.repo_ssh_url(repo) - dirname = helper.local_checkout_dirname(user, repo) + url = repo_ssh_url(repo) + dirname = local_checkout_dirname(user, repo) exit, out, err = git_as(user, ['clone', url, dirname]) - helper.assertNotEqual(exit, 0) + assertNotEqual(exit, 0) THEN a repository can be cloned over the git protocol ----------------------------------------------------------------------------- @@ -362,7 +362,7 @@ THEN a repository can be cloned over the git protocol repo = get_next_match() server = os.environ['GITANO_SERVER'] url = 'git://{}/{}'.format(server, repo) - dirname = helper.local_checkout_dirname('anonymous', repo) + dirname = local_checkout_dirname('anonymous', repo) cliapp.runcmd(['git', 'clone', url, dirname]) WHEN a user creates a local branch @@ -372,7 +372,7 @@ WHEN a user creates a local branch user = get_next_match() repo = get_next_match() branch = get_next_match() - dirname = helper.local_checkout_dirname(user, repo) + dirname = local_checkout_dirname(user, repo) cliapp.runcmd(['git', 'checkout', '-b', branch], cwd=dirname) WHEN a user changes a branch locally @@ -382,7 +382,7 @@ WHEN a user changes a branch locally user = get_next_match() repo = get_next_match() branch = get_next_match() - dirname = helper.local_checkout_dirname(user, repo) + dirname = local_checkout_dirname(user, repo) with open(os.path.join(dirname, 'foo.txt'), 'a') as f: f.write('foo\n') cliapp.runcmd(['git', 'add', 'foo.txt'], cwd=dirname) @@ -394,8 +394,8 @@ THEN a user can push all local branches IMPLEMENTS THEN (\S+) can push (\S+) user = get_next_match() repo = get_next_match() - url = helper.repo_ssh_url(repo) - dirname = helper.local_checkout_dirname(user, repo) + url = repo_ssh_url(repo) + dirname = local_checkout_dirname(user, repo) git_as_checked(user, ['push', '--all', 'origin'], cwd=dirname) THEN a user can push all local tags @@ -404,8 +404,8 @@ THEN a user can push all local tags IMPLEMENTS THEN (\S+) can push (\S+) with tags user = get_next_match() repo = get_next_match() - url = helper.repo_ssh_url(repo) - dirname = helper.local_checkout_dirname(user, repo) + url = repo_ssh_url(repo) + dirname = local_checkout_dirname(user, repo) git_as_checked(user, ['push', '--tags', 'origin'], cwd=dirname) THEN a user can't push local branches @@ -414,13 +414,13 @@ THEN a user can't push local branches IMPLEMENTS THEN (\S+) cannot push (\S+) user = get_next_match() repo = get_next_match() - dirname = helper.local_checkout_dirname(user, repo) + dirname = local_checkout_dirname(user, repo) exit, out, err = git_as( user, ['push', '--all', 'origin'], cwd=dirname) sys.stdout.write(out) sys.stderr.write(err) - helper.assertNotEqual(exit, 0) + assertNotEqual(exit, 0) THEN a user can't push local tags ----------------------------------------------------------------------------- @@ -428,11 +428,11 @@ THEN a user can't push local tags IMPLEMENTS THEN (\S+) cannot push (\S+) with tags user = get_next_match() repo = get_next_match() - dirname = helper.local_checkout_dirname(user, repo) + dirname = local_checkout_dirname(user, repo) exit, out, err = git_as( user, ['push', '--tags', 'origin'], cwd=dirname) - helper.assertNotEqual(exit, 0) + assertNotEqual(exit, 0) WHEN a user merges a branch locally ----------------------------------------------------------------------------- @@ -442,7 +442,7 @@ WHEN a user merges a branch locally repo = get_next_match() branch_from = get_next_match() branch_to = get_next_match() - dirname = helper.local_checkout_dirname(user, repo) + dirname = local_checkout_dirname(user, repo) cliapp.runcmd(['git', 'checkout', branch_to], cwd=dirname) cliapp.runcmd(['git', 'merge', branch_from], cwd=dirname) @@ -454,7 +454,7 @@ WHEN a user creates a local tag repo = get_next_match() branch = get_next_match() tag = get_next_match() - dirname = helper.local_checkout_dirname(user, repo) + dirname = local_checkout_dirname(user, repo) cliapp.runcmd(['git', 'tag', '-mrelease!', tag], cwd=dirname) FINALLY clean up anything created during tests diff --git a/lib.py b/lib.py index 611e8a1..42aede6 100644 --- a/lib.py +++ b/lib.py @@ -5,9 +5,6 @@ import sys import cliapp from yarnutils import * -import yarnhelper - -helper = yarnhelper.YarnHelper() srcdir = os.environ['SRCDIR'] datadir = os.environ['DATADIR'] @@ -97,3 +94,12 @@ def gitano_confirm_with_token(prefix, which): last_line = output.splitlines()[-1] token = last_line.split()[-1] gitano(None, '{} {} {}'.format(prefix, which, token)) + + + +def repo_ssh_url(repo): + return 'ssh://git@{}/{}'.format(os.environ['GITANO_SERVER'], repo) + + +def local_checkout_dirname(user, repo): + return '{}_{}'.format(user, repo) -- cgit v1.2.1