コード例 #1
0
 def _import_manifest(self, import_manifest=None):
     """ Import Manifest """
     if import_manifest.project is None:
         return
     repo_name = os.path.split(import_manifest.project)[1].replace(
         ".git", "")
     repo = os.path.join(self.git_worktree.root, ".qi", "manifests",
                         repo_name)
     import_manifest.repo = repo
     if not os.path.exists(repo):
         qisys.sh.mkdir(repo, recursive=True)
         git = qisrc.git.Git(repo)
         git.init()
         manifest_xml = os.path.join(repo, "manifest.xml")
         with open(manifest_xml, "w") as fp:
             fp.write("<manifest />")
         git.add(".")
         git.commit("-m", "initial commit")
     if import_manifest.branch:
         import_manifest.default_branch = import_manifest.branch
     else:
         import_manifest.default_branch = self.manifest.branch
     self._sync_git(repo, import_manifest.remotes[0].url,
                    import_manifest.default_branch,
                    import_manifest.fixed_ref)
コード例 #2
0
ファイル: conftest.py プロジェクト: alkino/qibuild
    def push_file(self, project, filename, contents,
                  branch="master", fast_forward=True,
                  message=None):
        """ Push a new file with the given contents to the given project
        It is assumed that the project has beed created

        """
        src = project.replace(".git", "")
        repo_src = self.src.join(src)
        git = qisrc.git.Git(repo_src.strpath)
        if git.get_current_branch() != branch:
            git.checkout("--force", "-B", branch)
        if not fast_forward:
            git.reset("--hard", "HEAD~1")
        to_write = repo_src.join(filename)
        if not message:
            if to_write.check(file=True):
                message = "Update %s" % filename
            else:
                message = "Add %s" % filename
        repo_src.ensure(filename, file=True)
        repo_src.join(filename).write(contents)
        git.add(filename)
        git.commit("--message", message)
        if fast_forward:
            git.push("origin", "%s:%s" % (branch, branch))
        else:
            git.push("origin", "--force", "%s:%s" % (branch, branch))
コード例 #3
0
    def push_file(self, project, filename, contents,
                  branch="master", fast_forward=True,
                  message=None):
        """ Push a new file with the given contents to the given project
        It is assumed that the project has been created

        """
        src = project.replace(".git", "")
        repo_src = self.src.join(src)
        git = qisrc.git.Git(repo_src.strpath)
        if git.get_current_branch() != branch:
            git.checkout("--force", "-B", branch)
        if not fast_forward:
            git.reset("--hard", "HEAD~1")
        to_write = repo_src.join(filename)
        if not message:
            if to_write.check(file=True):
                message = "Update %s" % filename
            else:
                message = "Add %s" % filename
        repo_src.ensure(filename, file=True)
        repo_src.join(filename).write(contents)
        git.add(filename)
        git.commit("--message", message)
        if fast_forward:
            git.push("origin", "%s:%s" % (branch, branch))
        else:
            git.push("origin", "--force", "%s:%s" % (branch, branch))
コード例 #4
0
    def push_submodule(self, project, submodule_url, destination_dir,
                       branch="master", fast_forward=True,
                       message=None):
        """
        Push a submodule to the given project.
        It is assumed that the project has been created.
        """
        src = project.replace(".git", "")
        repo_src = self.src.join(src)
        git = qisrc.git.Git(repo_src.strpath)
        if git.get_current_branch() != branch:
            git.checkout("--force", "-B", branch)
        if not fast_forward:
            git.reset("--hard", "HEAD~1")

        to_write = repo_src.join(destination_dir)
        if to_write.exists():
            raise RuntimeError("path %s already exists" % destination_dir)

        if not message:
            message = "Add submodule %s" % destination_dir

        git.call("submodule", "add", submodule_url, destination_dir)
        git.add(destination_dir)
        git.commit("--message", message)
        if fast_forward:
            git.push("origin", "%s:%s" % (branch, branch))
        else:
            git.push("origin", "--force", "%s:%s" % (branch, branch))
コード例 #5
0
ファイル: test_git.py プロジェクト: bithium/qibuild
def test_is_ff(tmpdir):
    a_git = tmpdir.mkdir("a_git_project")
    a_src = a_git.strpath

    git = qisrc.git.Git(a_src)
    git.init()
    write_readme(a_src, "readme\n")
    git.add(".")
    git.commit("-m", "initial commit")
    git.call("branch", "A")

    write_readme(a_src, "readme2\n")
    git.add(".")
    git.commit("-m", "second commit")
    git.call("branch", "B")

    (ret, out) = git.call("show-ref", "--verify", "refs/heads/A", raises=False)
    A_sha1 = out.split()[0]
    (ret, out) = git.call("show-ref", "--verify", "refs/heads/B", raises=False)
    B_sha1 = out.split()[0]

    class Status:
        pass
    status = Status()
    status.mess = ""
    assert qisrc.git.is_ff(git, status, A_sha1, B_sha1) == True
    assert qisrc.git.is_ff(git, status, B_sha1, A_sha1) == False
    assert qisrc.git.is_ff(git, status, A_sha1, A_sha1) == True
コード例 #6
0
def test_relative_path(qisrc_action, tmpdir):
    git = qisrc.git.Git(tmpdir.strpath)
    git.init()
    manifest = tmpdir.join("manifest.xml")
    manifest.write("<manifest />")
    git.add("manifest.xml")
    git.commit("-m", "Initial commit")
    qisrc_action("init", os.path.relpath(tmpdir.strpath))
    assert os.path.isfile(os.path.join(".qi", "manifests", "default", "manifest.xml"))
コード例 #7
0
def test_relative_path(qisrc_action, tmpdir):
    git = qisrc.git.Git(tmpdir.strpath)
    git.init()
    manifest = tmpdir.join("manifest.xml")
    manifest.write("<manifest />")
    git.add("manifest.xml")
    git.commit("-m", "Initial commit")
    qisrc_action("init", os.path.relpath(tmpdir.strpath))
    assert os.path.isfile(
        os.path.join(".qi", "manifests", "default", "manifest.xml"))
コード例 #8
0
ファイル: sync.py プロジェクト: Grimy/qibuild
 def manifest_repo(self):
     # the repo is always in manifests/default for backward-compatible reasons
     res = os.path.join(self.git_worktree.root, ".qi", "manifests", "default")
     if not os.path.exists(res):
         qisys.sh.mkdir(res, recursive=True)
         git = qisrc.git.Git(res)
         git.init()
         manifest_xml = os.path.join(res, "manifest.xml")
         with open(manifest_xml, "w") as fp:
             fp.write("<manifest />")
         git.add(".")
         git.commit("-m", "initial commit")
     return res
コード例 #9
0
 def add_qibuild_test_project(self, src):
     project_name = src + ".git"
     repo_src = self._create_repo(project_name, src=src, review=False)
     this_dir = os.path.dirname(__file__)
     src_path = os.path.join(this_dir, "..", "..", "qibuild", "test", "projects", src)
     qisys.sh.copy_git_src(src_path, repo_src)
     git = TestGit(repo_src)
     git.add(".")
     git.commit("--message", "Add sources from qibuild test project %s" % src)
     git.push("origin", "master:master")
     self.manifest.add_repo(project_name, src, ["origin"])
     repo = self.manifest.get_repo(project_name)
     self.push_manifest("Add qibuild test project: %s" % src)
コード例 #10
0
ファイル: conftest.py プロジェクト: alkino/qibuild
 def add_qibuild_test_project(self, src):
     project_name = src + ".git"
     repo_src = self._create_repo(project_name , src=src, review=False)
     this_dir = os.path.dirname(__file__)
     src_path = os.path.join(this_dir, "..", "..", "qibuild", "test", "projects", src)
     qisys.sh.copy_git_src(src_path, repo_src)
     git = TestGit(repo_src)
     git.add(".")
     git.commit("--message", "Add sources from qibuild test project %s" % src)
     git.push("origin", "master:master")
     self.manifest.add_repo(project_name, src, ["origin"])
     repo = self.manifest.get_repo(project_name)
     self.push_manifest("Add qibuild test project: %s" % src)
コード例 #11
0
ファイル: sync.py プロジェクト: sbarthelemy/qibuild
 def manifest_repo(self):
     # the repo is always in manifests/default for backward-compatible reasons
     res = os.path.join(self.git_worktree.root, ".qi", "manifests", "default")
     if not os.path.exists(res):
         qisys.sh.mkdir(res, recursive=True)
         git = qisrc.git.Git(res)
         git.init()
         manifest_xml = os.path.join(res, "manifest.xml")
         with open(manifest_xml, "w") as fp:
             fp.write("<manifest />")
         git.add(".")
         git.commit("-m", "initial commit")
     return res
コード例 #12
0
ファイル: test_project.py プロジェクト: Grimy/qibuild
def test_gen_scm_info(build_worktree, tmpdir):
    build_worktree.add_test_project("world")
    hello_proj = build_worktree.add_test_project("hello")
    git = qisrc.git.Git(hello_proj.path)
    git.init()
    git.add(".")
    git.commit("--message", "initial commit")
    rc, sha1 = git.call("rev-parse", "HEAD", raises=False)
    package_xml = tmpdir.join("package.xml").strpath
    hello_proj.gen_package_xml(package_xml)
    tree = qisys.qixml.read(package_xml)
    scm_elem = tree.find("scm")
    git_elem = scm_elem.find("git")
    assert git_elem.get("revision") == sha1
コード例 #13
0
ファイル: test_project.py プロジェクト: pineal/qibuild
def test_gen_scm_info(build_worktree, tmpdir):
    build_worktree.add_test_project("world")
    hello_proj = build_worktree.add_test_project("hello")
    git = qisrc.git.Git(hello_proj.path)
    git.init()
    git.add(".")
    git.commit("--message", "initial commit")
    rc, sha1 = git.call("rev-parse", "HEAD", raises=False)
    package_xml = tmpdir.join("package.xml").strpath
    hello_proj.gen_package_xml(package_xml)
    tree = qisys.qixml.read(package_xml)
    scm_elem = tree.find("scm")
    git_elem = scm_elem.find("git")
    assert git_elem.get("revision") == sha1
コード例 #14
0
def push_file(tmp, git_path, filename, contents, branch="master"):
    """ Push a file to the given url. Assumes the repository
    has been created with :py:func:`create_git_repo` with the same
    path

    """
    tmp_src = os.path.join(tmp, "src", git_path)
    tmp_srv = os.path.join(tmp, "srv", git_path + ".git")
    git = qisrc.git.Git(tmp_src)
    if branch in git.get_local_branches():
        git.checkout("-f", branch)
    else:
        git.checkout("-b", branch)
    dirname = os.path.dirname(filename)
    qibuild.sh.mkdir(os.path.join(tmp_src, dirname), recursive=True)
    with open(os.path.join(tmp_src, filename), "w") as fp:
        fp.write(contents)
    git.add(filename)
    git.commit("-m", "added %s" % filename)
    git.push(tmp_srv, "%s:%s" % (branch, branch))