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)
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))
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) )
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)
def find_repository_returns_none_if_there_is_no_repository(): with temporary_directory() as directory: assert_equal(None, find_repository(directory))
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)
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)
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)
def temporary_hg_repo(): with temporary_directory() as path: yield create_hg_repo(path)
def temporary_xdg_cache_dir(): key = "XDG_CACHE_HOME" with temporary_directory() as cache_dir: with updated_env({key: cache_dir}): yield
def none_is_returned_if_there_is_no_repository(): with temporary_directory() as directory: assert_equal(None, repository_at(working_directory=directory))
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)
def temporary_empty_dir(): with temporary_directory() as directory: yield os.path.join(directory, "sub")
def temporary_repo(vcs): with temporary_directory() as path: yield create_repo(vcs, path)