Skip to content
This repository has been archived by the owner on Feb 13, 2020. It is now read-only.

Commit

Permalink
Merge pull request #540 from gamechanger/tnt-rel-path
Browse files Browse the repository at this point in the history
Make a better attempt at parsing relative repo paths
  • Loading branch information
thieman committed Aug 25, 2015
2 parents 53478c1 + 0904825 commit 86f2ab2
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 8 deletions.
3 changes: 2 additions & 1 deletion docs/changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Changelog

## 0.4.1 (In Progress)
## 0.5.0 (In Progress)

* **Breaking**
* Dusty now uses NFS instead of rsync to get repository code from your host Mac to running containers.
Expand All @@ -13,6 +13,7 @@
* `test.once` commands that fail now cause the entire test run to fail immediately.
* When running all test suites, a tabular summary of test results is now printed at the end of the run
* Repos specified with `https:` or `file:` now are successfully mounted to containers by Docker Compose
* Fixed various issues with using fully specified `ssh://user@host:port/path` URLs for repos

## 0.4.0 (August 3, 2015)

Expand Down
14 changes: 9 additions & 5 deletions dusty/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import os
import logging
from contextlib import contextmanager
import urlparse

import git

Expand Down Expand Up @@ -96,11 +97,14 @@ def vm_path(self):

@property
def rel_path(self):
local_folder = self.remote_path
if ':' in local_folder:
local_folder = local_folder.split(':')[1]
local_folder = local_folder.lstrip('/')
return local_folder
parsed = urlparse.urlparse(self.remote_path.lstrip('/'))
if parsed.hostname:
local_folder = parsed.hostname + parsed.path
else:
local_folder = parsed.path
if local_folder.endswith('.git'):
local_folder = local_folder[:-4]
return local_folder.lstrip('/')

def assemble_remote_path(self):
if self.is_local_repo:
Expand Down
21 changes: 19 additions & 2 deletions tests/unit/source_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ class TestSource(DustyTestCase):
def setUp(self):
super(TestSource, self).setUp()
self.temp_dir = tempfile.mkdtemp()

self.MockableRepo = type("MockableRepo", (Repo, object), {})

def tearDown(self):
Expand Down Expand Up @@ -62,7 +61,25 @@ def test_managed_path_file(self):
self.assertEqual(Repo('file:///github.com/app/a').managed_path, '/etc/dusty/repos/github.com/app/a')

def test_managed_path_ssh(self):
self.assertEqual(Repo('ssh://[email protected]/app/a').managed_path, '/etc/dusty/repos/[email protected]/app/a')
self.assertEqual(Repo('ssh://[email protected]/app/a').managed_path, '/etc/dusty/repos/github.com/app/a')

def test_rel_path(self):
self.assertEqual(Repo('github.com/app/a').rel_path, 'github.com/app/a')
self.assertEqual(Repo('github.com/app/a.js').rel_path, 'github.com/app/a.js')
self.assertEqual(Repo('/gc/repos/dusty').rel_path, 'gc/repos/dusty')

def test_rel_path_http(self):
self.assertEqual(Repo('http://github.com/app/a').rel_path, 'github.com/app/a')

def test_rel_path_file(self):
self.assertEqual(Repo('file:///github.com/app/a.git').rel_path, 'github.com/app/a')
self.assertEqual(Repo('file:///github.com/app/a.js.git').rel_path, 'github.com/app/a.js')

def test_rel_path_ssh(self):
self.assertEqual(Repo('ssh://[email protected]/app/a.git').rel_path, 'github.com/app/a')
self.assertEqual(Repo('ssh://[email protected]:2222/app/a').rel_path, 'github.com/app/a')
self.assertEqual(Repo('ssh://[email protected]:2222/app/a.js').rel_path, 'github.com/app/a.js')
self.assertEqual(Repo('ssh://[email protected]:2222/app/a.js.git').rel_path, 'github.com/app/a.js')

def test_override_path(self):
override_repo('github.com/app/a', self.temp_dir)
Expand Down

0 comments on commit 86f2ab2

Please sign in to comment.