Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: toolness/tinyserv
base: 5d52664d64
...
head fork: toolness/tinyserv
compare: ead41a315c
Checking mergeability… Don't worry, you can still create the pull request.
  • 4 commits
  • 5 files changed
  • 0 commit comments
  • 1 contributor
View
2  test/smoke_test.py
@@ -86,6 +86,8 @@ def main():
remote = environ['TINYSERV_REMOTE']
host = remote.split('@')[-1]
+ print "Running smoke test on %s." % host
+
describe("Setting up sample 'tinysmoke' repository.")
chdir(ROOT)
View
13 vendor/tinyservlib/client.py
@@ -6,8 +6,17 @@ class TinyservClient(object):
def __init__(self, host):
self.host = host
+ def make_remote_url(self, repodir):
+ if self.host == 'localhost':
+ return repodir
+ else:
+ return '%s:%s' % (self.host, repodir)
+
def make_remote_cmd(self, cmd):
- return ['ssh', self.host, cmd]
+ if self.host == 'localhost':
+ return ['bash', '-c', cmd]
+ else:
+ return ['ssh', self.host, cmd]
def _remote(self, cmd, ignore_errors=False):
fullcmd = self.make_remote_cmd(cmd)
@@ -65,4 +74,4 @@ def destroy_project(self, name):
def create_project(self, name):
result = self._remote('tinyserv-remote apps:create %s' % name)
repodir = result.splitlines()[-1].split()[-1].strip()
- return '%s:%s' % (self.host, repodir)
+ return self.make_remote_url(repodir)
View
30 vendor/tinyservlib/cmdline/local.py
@@ -1,9 +1,10 @@
import os
+import sys
import subprocess
from .run import make_run
from ..client import TinyservClient
-from ..git_utils import git, get_push_url
+from ..git_utils import git, get_push_url, in_git_repo
remote = None
@@ -14,9 +15,18 @@ def cmd_apps__create(args):
if args.name is None:
args.name = os.path.basename(os.getcwd())
-
+
url = remote.create_project(args.name)
- git(None, 'remote', 'add', 'tinyserv', url)
+
+ if in_git_repo():
+ if get_push_url('tinyserv') is None:
+ git(None, 'remote', 'add', 'tinyserv', url)
+ print "Added remote 'tinyserv'."
+ else:
+ print "This repository is already configured for app '%s'." % \
+ _get_current_project_name()
+
+ print "Remote repository URL is %s." % url
def cmd_apps__create_args(parser):
parser.add_argument('name', nargs='?', default=None)
@@ -25,20 +35,28 @@ def _get_current_project_name():
# This is semi-fragile and always assumes the last part of the URL
# is the project name.
- return get_push_url(remote='tinyserv').split('/')[-1]
+ push_url = get_push_url(remote='tinyserv')
+ if push_url is not None:
+ return push_url.split('/')[-1]
def cmd_apps__destroy(args):
"""
Destroy an existing app.
"""
- if args.name is None:
+ if args.name is None and in_git_repo():
args.name = _get_current_project_name()
+ if args.name is None:
+ print "Please provide a project name."
+ sys.exit(1)
+
print "Destroying project %s..." % args.name
remote.destroy_project(args.name)
print "Project %s destroyed." % args.name
- git(None, 'remote', 'rm', 'tinyserv')
+ if in_git_repo() and _get_current_project_name() == args.name:
+ git(None, 'remote', 'rm', 'tinyserv')
+ print "Removed remote '%s'." % args.name
cmd_apps__destroy_args = cmd_apps__create_args
View
13 vendor/tinyservlib/git_utils.py
@@ -17,6 +17,9 @@ def _mkenv(cwd):
env['GIT_DIR'] = _realrepo(cwd)
return env
+def in_git_repo():
+ return os.path.exists('.git')
+
def git(cwd, *args):
subprocess.check_call(['git'] + list(args), cwd=cwd, env=_mkenv(cwd))
@@ -37,7 +40,13 @@ def get_head_ref(cwd):
def get_push_url(remote, cwd=None):
output = get_git_output(['remote', 'show', '-n', remote], cwd=cwd)
-
+
# This is fragile and assumes the "Push URL" is always on the second
# line of the output.
- return output.splitlines()[2].split("URL:")[1].strip()
+ url = output.splitlines()[2].split("URL:")[1].strip()
+
+ if url == remote:
+ # No remote defined..
+ return None
+
+ return url
View
5 vendor/tinyservlib/manager.py
@@ -171,8 +171,9 @@ def find_unused_port(self):
return max_port + 1
def create_project(self, name):
- if name not in self.projects:
- self.projects[name] = Project(self, name)
+ if name in self.projects:
+ raise ValueError("app '%s' already exists" % name)
+ self.projects[name] = Project(self, name)
return self.projects[name]
def destroy_project(self, name):

No commit comments for this range

Something went wrong with that request. Please try again.