Example #1
0
    def _create_repo(self, project, src=None, review=False, empty=False):
        """ Helper for self.create_repo """
        if not src:
            src = project.replace(".git", "")

        if review:
            repo_srv = self.gerrit.ensure(project, dir=True)
        else:
            repo_srv = self.srv.ensure(project, dir=True)

        repo_url = "file://" + qisys.sh.to_posix_path(repo_srv.strpath)
        git = qisrc.git.Git(repo_srv.strpath)
        git.init("--bare")

        repo_src = self.src.ensure(src, dir=True)
        git = TestGit(repo_src.strpath)
        git.initialize()
        if review:
            remote_name = "gerrit"
        else:
            remote_name = "origin"

        git.set_remote(remote_name, repo_url)
        if not empty:
            git.push(remote_name, "master:master")
        return repo_src.strpath
Example #2
0
    def _create_repo(self, project, src=None, review=False, empty=False):
        """ Helper for self.create_repo """
        if not src:
            src = project.replace(".git", "")

        if review:
            repo_srv = self.gerrit.ensure(project, dir=True)
        else:
            repo_srv = self.srv.ensure(project, dir=True)

        repo_url = "file://" + qisys.sh.to_posix_path(repo_srv.strpath)
        git = qisrc.git.Git(repo_srv.strpath)
        git.init("--bare")

        repo_src = self.src.ensure(src, dir=True)
        git = TestGit(repo_src.strpath)
        git.initialize()
        if review:
            remote_name = "gerrit"
        else:
            remote_name = "origin"

        git.set_remote(remote_name, repo_url)
        if not empty:
            git.push(remote_name, "master:master")
        return repo_src.strpath
Example #3
0
def test_get_repo_root(tmpdir):
    root = tmpdir.ensure("CrazyCase", dir=True)
    git = TestGit(root.strpath)
    git.initialize()
    subdir = root.ensure("some" , "subdir", dir=True)
    actual = qisrc.git.get_repo_root(subdir.strpath)
    expected = qisys.sh.to_native_path(root.strpath)
    assert actual == expected
Example #4
0
def test_sync_skips_unconfigured_projects(qisrc_action, git_server, test_git):
    git_server.create_repo("foo.git")
    qisrc_action("init", git_server.manifest_url)
    git_worktree = TestGitWorkTree()
    # pylint: disable-msg=E1101
    cwd = py.path.local(os.getcwd())
    new_proj = cwd.mkdir("new_proj")
    git = test_git(new_proj.strpath)
    git.initialize()
    git_worktree.add_git_project(new_proj.strpath)
    qisys.script.run_action("qisrc.actions.sync")
Example #5
0
def test_changelog(cd_to_tmpdir):
    git = TestGit()
    git.initialize()
    message_1 = "mess1"
    git.commit_file("foo.txt", "foo\n", message=message_1)
    message_2 = "mess2"
    git.commit_file("foo.txt", "bar\n", message=message_2)
    commits = git.get_log("HEAD~2", "HEAD")
    assert len(commits) == 2
    assert commits[0]["message"] == message_1
    assert commits[1]["message"] == message_2
def test_sync_skips_unconfigured_projects(qisrc_action, git_server, test_git):
    """ Test Sync Skip Unconfigured Projects """
    git_server.create_repo("foo.git")
    qisrc_action("init", git_server.manifest_url)
    git_worktree = TestGitWorkTree()
    cwd = py.path.local(os.getcwd())  # pylint:disable=no-member
    new_proj = cwd.mkdir("new_proj")
    git = test_git(new_proj.strpath)
    git.initialize()
    git_worktree.add_git_project(new_proj.strpath)
    rc = qisrc_action("sync", retcode=True)
    assert rc != 0
Example #7
0
def test_sync_skips_unconfigured_projects(qisrc_action, git_server, test_git):
    """ Test Sync Skip Unconfigured Projects """
    git_server.create_repo("foo.git")
    qisrc_action("init", git_server.manifest_url)
    git_worktree = TestGitWorkTree()
    cwd = py.path.local(os.getcwd())  # pylint:disable=no-member
    new_proj = cwd.mkdir("new_proj")
    git = test_git(new_proj.strpath)
    git.initialize()
    git_worktree.add_git_project(new_proj.strpath)
    rc = qisrc_action("sync", retcode=True)
    assert rc != 0
Example #8
0
def test_ending_newlines(cd_to_tmpdir):
    """ Test Ending New Lines """
    git = TestGit()
    git.initialize()
    message_1 = "mess1"
    file_1 = "foo.txt"
    content_1 = "\nfoo\nbar\n\n"
    git.commit_file(file_1, content_1, message=message_1)
    # Test git subcommand which doesn't keep the last newline by default
    rc, out = git.status(raises=False)
    assert rc == 0
    assert out[-1] != "\n"
    rc, out = git.status(raises=False, keep_last_newline=True)
    assert rc == 0
    assert out[-1] == "\n"
    # Test git subcommand which KEEP the last newline by default
    rc, out = git.show("master:foo.txt", raises=False)
    assert rc == 0
    assert out[-1] == "\n"
    assert out == content_1
    rc, out = git.show("master:foo.txt", raises=False, keep_last_newline=False)
    assert rc == 0
    assert out[-1] != "\n"
    assert out != content_1