def test_warn_on_default_change(git_worktree, record_messages): """ Test Warn on Default Change """ foo1 = git_worktree.create_git_project("foo") gitorious = Remote() gitorious.name = "gitorious" gitorious.url = "git@gitorious:libfoo/libfoo.git" gitorious.default = True gitlab = Remote() gitlab.name = "gitlab" gitlab.url = "git@gitlab:foo/libfoo.git" foo_repo = RepoConfig() foo_repo.default_branch = "master" foo_repo.remotes = [gitlab, gitorious] foo1.read_remote_config(foo_repo) foo1.apply_config() assert foo1.default_remote.name == "gitorious" gitorious2 = copy.copy(gitorious) gitorious2.default = False gitlab2 = copy.copy(gitlab) gitlab2.default = True record_messages.reset() foo_repo = RepoConfig() foo_repo.remotes = [gitlab2, gitorious2] foo_repo.default_branch = "master" foo1.read_remote_config(foo_repo) foo1.apply_config() assert record_messages.find("Default remote changed") assert foo1.default_remote.name == "gitlab"
def test_apply_remote_config(git_worktree): foo = git_worktree.create_git_project("foo") origin = Remote() origin.name = "origin" origin.url = "git@git:foo.git" origin.default = True gerrit = Remote() gerrit.name = "gerrit" gerrit.url = "git@review:foo.git" gerrit.review = True foo_repo = RepoConfig() foo_repo.remotes = [origin, gerrit] foo_repo.default_branch = "master" foo.read_remote_config(foo_repo) foo.apply_config() foo.save_config() assert foo_repo.default_remote == origin assert foo.review_remote == gerrit # Check its persistent: git_worktree = TestGitWorkTree() foo2 = git_worktree.get_git_project("foo") assert foo2.default_remote == origin assert foo2.review_remote == gerrit
def test_no_default_branch(git_worktree): """ Test No Default Branch """ foo_project = git_worktree.create_git_project("foo") foo_repo = RepoConfig() foo_project.read_remote_config(foo_repo) foo_project.apply_config()