Beispiel #1
0
def find_repository_searches_ancestors_for_working_directory():
    with temporary_directory() as directory:
        repository_path = os.path.join(directory, ".git")
        search_path = os.path.join(directory, "one/two/three")
        mkdir_p(repository_path)
        mkdir_p(search_path)
        repository = find_repository(search_path)
        assert_equal(directory, repository.working_directory)
Beispiel #2
0
def git_fetch_raises_error_if_target_is_not_git_repository():
    with temporary_directory() as target:
        with temporary_git_repo() as git_repo:
            original_uri = "git+file://" + git_repo.working_directory
            assert_raises_message(
                MayoUserError,
                "{0} already exists and is not a git repository".format(
                    target), lambda: fetch(original_uri, target))
Beispiel #3
0
def find_repository_searches_ancestors_for_working_directory():
    with temporary_directory() as directory:
        repository_path = os.path.join(directory, ".git")
        search_path = os.path.join(directory, "one/two/three")
        mkdir_p(repository_path)
        mkdir_p(search_path)
        repository = find_repository(search_path)
        assert_equal(directory, repository.working_directory)
Beispiel #4
0
def git_fetch_raises_error_if_target_is_not_git_repository():
    with temporary_directory() as target:
        with temporary_git_repo() as git_repo:
            original_uri = "git+file://" + git_repo.working_directory
            assert_raises_message(
                MayoUserError,
                "{0} already exists and is not a git repository".format(target),
                lambda: fetch(original_uri, target)
            )
Beispiel #5
0
def find_repository_returns_git_repository_if_path_is_root_of_git_repository():
    with temporary_directory() as directory:
        mkdir_p(os.path.join(directory, ".git"))
        repository = find_repository(directory)
        assert_equal("git", repository.type)
Beispiel #6
0
def find_repository_returns_none_if_there_is_no_repository():
    with temporary_directory() as directory:
        assert_equal(None, find_repository(directory))
Beispiel #7
0
def working_directory_of_git_repository_is_directory_above_hidden_directory():
    with temporary_directory() as directory:
        mkdir_p(os.path.join(directory, ".git"))
        repository = repository_at(directory)
        assert_equal(directory, repository.working_directory)
Beispiel #8
0
def hg_repository_is_returned_if_path_is_root_of_hg_repository():
    with temporary_directory() as directory:
        mkdir_p(os.path.join(directory, ".hg"))
        repository = repository_at(directory)
        assert_equal("hg", repository.type)
Beispiel #9
0
def git_repository_is_returned_if_path_is_working_directory_of_git_repository(
):
    with temporary_directory() as directory:
        mkdir_p(os.path.join(directory, ".git"))
        repository = repository_at(directory)
        assert_equal("git", repository.type)
Beispiel #10
0
def temporary_hg_repo():
    with temporary_directory() as path:
        yield create_hg_repo(path)
Beispiel #11
0
def temporary_xdg_cache_dir():
    key = "XDG_CACHE_HOME"
    with temporary_directory() as cache_dir:
        with updated_env({key: cache_dir}):
            yield
Beispiel #12
0
def none_is_returned_if_there_is_no_repository():
    with temporary_directory() as directory:
        assert_equal(None, repository_at(working_directory=directory))
Beispiel #13
0
def none_is_returned_if_there_is_no_repository():
    with temporary_directory() as directory:
        assert_equal(None, repository_at(working_directory=directory))
Beispiel #14
0
def find_repository_returns_git_repository_if_path_is_root_of_git_repository():
    with temporary_directory() as directory:
        mkdir_p(os.path.join(directory, ".git"))
        repository = find_repository(directory)
        assert_equal("git", repository.type)
Beispiel #15
0
def find_repository_returns_none_if_there_is_no_repository():
    with temporary_directory() as directory:
        assert_equal(None, find_repository(directory))
Beispiel #16
0
def working_directory_of_git_repository_is_directory_above_hidden_directory():
    with temporary_directory() as directory:
        mkdir_p(os.path.join(directory, ".git"))
        repository = repository_at(directory)
        assert_equal(directory, repository.working_directory)
Beispiel #17
0
def hg_repository_is_returned_if_path_is_root_of_hg_repository():
    with temporary_directory() as directory:
        mkdir_p(os.path.join(directory, ".hg"))
        repository = repository_at(directory)
        assert_equal("hg", repository.type)
Beispiel #18
0
def git_repository_is_returned_if_path_is_working_directory_of_git_repository():
    with temporary_directory() as directory:
        mkdir_p(os.path.join(directory, ".git"))
        repository = repository_at(directory)
        assert_equal("git", repository.type)
Beispiel #19
0
def temporary_xdg_cache_dir():
    key = "XDG_CACHE_HOME"
    with temporary_directory() as cache_dir:
        with updated_env({key: cache_dir}):
            yield
Beispiel #20
0
def temporary_empty_dir():
    with temporary_directory() as directory:
        yield os.path.join(directory, "sub")
Beispiel #21
0
def temporary_empty_dir():
    with temporary_directory() as directory:
        yield os.path.join(directory, "sub")
Beispiel #22
0
def temporary_repo(vcs):
    with temporary_directory() as path:
        yield create_repo(vcs, path)