import time
from .config import config
+from .exceptions import BranchNotFoundError
log = logging.getLogger(__name__)
raise BranchNotFoundError(branch, repo_url)
-class BranchNotFoundError(ValueError):
- def __init__(self, branch, repo=None):
- self.branch = branch
- self.repo = repo
-
- def __str__(self):
- if self.repo:
- repo_str = " in repo: %s" % self.repo
- else:
- repo_str = ""
- return "Branch '{branch}' not found{repo_str}!".format(
- branch=self.branch, repo_str=repo_str)
-
-
def validate_branch(branch):
if ' ' in branch:
raise ValueError("Illegal branch name: '%s'" % branch)
import shutil
import subprocess
+from ..exceptions import BranchNotFoundError
from .. import repo_utils
from .. import parallel
repo_utils.log.setLevel(logging.WARNING)
assert os.path.exists(self.dest_path)
def test_clone_repo_non_existing_branch(self):
- with raises(repo_utils.BranchNotFoundError):
+ with raises(BranchNotFoundError):
repo_utils.clone_repo(self.repo_url, self.dest_path, 'nobranch')
assert not os.path.exists(self.dest_path)
def test_fetch_branch_fake_branch(self):
repo_utils.clone_repo(self.repo_url, self.dest_path, 'master')
- with raises(repo_utils.BranchNotFoundError):
+ with raises(BranchNotFoundError):
repo_utils.fetch_branch(self.dest_path, 'nobranch')
def test_enforce_existing_branch(self):
assert os.path.exists(self.dest_path)
def test_enforce_non_existing_branch(self):
- with raises(repo_utils.BranchNotFoundError):
+ with raises(BranchNotFoundError):
repo_utils.enforce_repo_state(self.repo_url, self.dest_path,
'blah')
assert not os.path.exists(self.dest_path)
assert os.path.exists(self.dest_path)
def test_enforce_multiple_calls_different_branches(self):
- with raises(repo_utils.BranchNotFoundError):
+ with raises(BranchNotFoundError):
repo_utils.enforce_repo_state(self.repo_url, self.dest_path,
'blah1')
assert not os.path.exists(self.dest_path)
repo_utils.enforce_repo_state(self.repo_url, self.dest_path,
'master')
assert os.path.exists(self.dest_path)
- with raises(repo_utils.BranchNotFoundError):
+ with raises(BranchNotFoundError):
repo_utils.enforce_repo_state(self.repo_url, self.dest_path,
'blah2')
assert not os.path.exists(self.dest_path)
branch)
p.spawn(
raises,
- repo_utils.BranchNotFoundError,
+ BranchNotFoundError,
func,
)
for result in p:
from . import report
from . import safepath
from .config import config as teuth_config
+from .exceptions import BranchNotFoundError
from .kill import kill_job
from .misc import read_config
-from .repo_utils import BranchNotFoundError
from .repo_utils import fetch_qa_suite, fetch_teuthology_branch
log = logging.getLogger(__name__)