Beispiel #1
0
    def sync_pr(self, pr_id, dist_git_branch: str, upstream_version: str = None):
        up = Upstream(config=self.config, package_config=self.package_config)

        dg = DistGit(config=self.config, package_config=self.package_config)

        up.checkout_pr(pr_id=pr_id)
        local_pr_branch = f"pull-request-{pr_id}-sync"
        # fetch and reset --hard upstream/$branch?
        dg.checkout_branch(dist_git_branch)
        dg.create_branch(local_pr_branch)
        dg.checkout_branch(local_pr_branch)

        dg.sync_files(up.local_project)

        patches = up.create_patches(
            upstream=upstream_version, destination=dg.local_project.working_dir
        )
        dg.add_patches_to_specfile(patches)

        description = (
            f"Upstream pr: {pr_id}\n"
            f"Upstream commit: {up.local_project.git_repo.head.commit}\n"
        )

        self.sync(
            distgit=dg,
            commit_msg=f"Sync upstream pr: {pr_id}",
            pr_title=f"Upstream pr: {pr_id}",
            pr_description=description,
            dist_git_branch="master",
            add_new_sources=False,
        )
Beispiel #2
0
    def sync_release(self, dist_git_branch: str, version: str = None):
        """
        Update given package in Fedora
        """
        up = Upstream(config=self.config, package_config=self.package_config)

        dg = DistGit(config=self.config, package_config=self.package_config)

        full_version = version or up.get_upstream_version()
        current_up_branch = up.active_branch
        try:
            # TODO: this is problematic, since we may overwrite stuff in the repo
            #       but the thing is that we need to do it
            #       I feel like the ideal thing to do would be to clone the repo and work in tmpdir
            # TODO: this is also naive, upstream may use different tagging scheme, e.g.
            #       release = 232, tag = v232
            up.checkout_release(full_version)

            local_pr_branch = f"{full_version}-{dist_git_branch}-update"
            # fetch and reset --hard upstream/$branch?
            logger.info(f'using "{dist_git_branch}" dist-git branch')
            dg.checkout_branch(dist_git_branch)
            dg.create_branch(local_pr_branch)
            dg.checkout_branch(local_pr_branch)

            description = (
                f"Upstream tag: {full_version}\n"
                f"Upstream commit: {up.local_project.git_repo.head.commit}\n"
            )

            dg.sync_files(up.local_project)

            self.sync(
                distgit=dg,
                commit_msg=f"{full_version} upstream release",
                pr_title=f"Update to upstream release {full_version}",
                pr_description=description,
                dist_git_branch=dist_git_branch,
                commit_msg_description=description,
                add_new_sources=True,
            )
        finally:
            current_up_branch.checkout()