Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add archive argument to blah.fetch

  • Loading branch information...
commit 0c5b00a72793a7da9a033c0b69014738a5cd11cd 1 parent ce15a6d
@mwilliamson authored
Showing with 28 additions and 6 deletions.
  1. +4 −1 blah/fetcher.py
  2. +1 −1  setup.py
  3. +23 −4 tests/fetcher_tests.py
View
5 blah/fetcher.py
@@ -1,10 +1,11 @@
import os
+import shutil
import blah.systems
import blah.uri_parser
import blah.errors
-def fetch(uri_str, local_path, use_cache=False, systems=None):
+def fetch(uri_str, local_path, archive=False, use_cache=False, systems=None):
if systems is None:
systems = blah.systems.all_systems
@@ -16,6 +17,8 @@ def fetch(uri_str, local_path, use_cache=False, systems=None):
local_repo = _fetch_all_revisions(uri, local_path, vcs)
revision = _read_revision(vcs, uri)
local_repo.checkout_revision(revision)
+ if archive:
+ shutil.rmtree(os.path.join(local_path, vcs.directory_name))
def _find_vcs(uri, systems):
for vcs in systems:
View
2  setup.py
@@ -8,7 +8,7 @@ def read(fname):
setup(
name='blah',
- version='0.1.7',
+ version='0.1.8',
description='Thin wrapper around source control systems',
long_description=read("README"),
author='Michael Williamson',
View
27 tests/fetcher_tests.py
@@ -1,12 +1,13 @@
import os
import functools
-from nose.tools import istest, assert_equal
+from nose.tools import istest, assert_equal, assert_false
from blah.fetcher import fetch
from blah.files import mkdir_p, temporary_directory, write_file, read_file
from blah import UnrecognisedSourceControlSystem
from blah.errors import BlahUserError
+from blah.systems import all_systems
from test_repos import temporary_hg_repo, temporary_git_repo, add_commit_to_repo
import test_repos
@@ -15,7 +16,7 @@ def vcs_agnostic_test(func=None, params=(), **kwargs):
def wrap(func):
@functools.wraps(func)
def run_test():
- for vcs in map(VcsUnderTest, ["git", "hg"]):
+ for vcs in map(VcsUnderTest, all_systems):
test_params = [kwargs["{0}_params".format(vcs.name)][param_name] for param_name in params]
with temporary_directory() as temp_dir:
yield tuple([func, vcs, temp_dir] + test_params)
@@ -27,8 +28,16 @@ def run_test():
return wrap
class VcsUnderTest(object):
- def __init__(self, name):
- self.name = name
+ def __init__(self, vcs):
+ self.vcs = vcs
+
+ @property
+ def name(self):
+ return self.vcs.name
+
+ @property
+ def directory_name(self):
+ return self.vcs.directory_name
def temporary_repo(self):
return test_repos.temporary_repo(self.name)
@@ -115,6 +124,16 @@ def can_clone_repository_to_specific_commit_using_hash_before_commit_name(vcs, t
fetch("{0}#{1}".format(original_uri, commit), target)
assert_equal("Run it.", read_file(os.path.join(target, "README")))
+
+@vcs_agnostic_test
+def can_fetch_repo_without_vcs_files(vcs, temp_dir):
+ target = os.path.join(temp_dir, "clone")
+ with vcs.temporary_repo() as repo:
+ original_uri = "{0}+file://{1}".format(vcs.name, repo.working_directory)
+ fetch(original_uri, target, archive=True)
+ assert_equal("Run it.", read_file(os.path.join(target, "README")))
+ assert_false(os.path.exists(os.path.join(target, vcs.directory_name)))
+
@istest
def origin_is_prefixed_to_git_commit_if_necessary():
with temporary_directory() as directory:
Please sign in to comment.
Something went wrong with that request. Please try again.