From ae829b3a48a9d18ae5faced176283c615df782b3 Mon Sep 17 00:00:00 2001 From: "Petr \"Stone\" Hracek" Date: Thu, 7 Nov 2024 12:25:54 +0100 Subject: [PATCH] Fix pulling bot-cfg from downstream. Signed-off-by: Petr "Stone" Hracek --- .github/workflows/build-and-push.yml | 2 +- Dockerfile | 2 +- betka/core.py | 15 ++++----------- betka/gitlab.py | 4 ++-- setup.py | 2 +- 5 files changed, 9 insertions(+), 16 deletions(-) diff --git a/.github/workflows/build-and-push.yml b/.github/workflows/build-and-push.yml index 20062ae..eebc49f 100644 --- a/.github/workflows/build-and-push.yml +++ b/.github/workflows/build-and-push.yml @@ -20,7 +20,7 @@ jobs: with: dockerfiles: ./Dockerfile image: betka - tags: latest 1 ${{ github.sha }} 0.9.4 + tags: latest 1 ${{ github.sha }} 0.9.5 - name: Push betka image to Quay.io id: push-to-quay diff --git a/Dockerfile b/Dockerfile index 0d48705..7b5de6a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ FROM quay.io/fedora/fedora:37 ENV NAME=betka-fedora \ - RELEASE=0.9.4 \ + RELEASE=0.9.5 \ ARCH=x86_64 \ SUMMARY="Syncs changes from upstream repository to downstream" \ DESCRIPTION="Syncs changes from upstream repository to downstream" \ diff --git a/betka/core.py b/betka/core.py index a81d2fe..4477cbe 100644 --- a/betka/core.py +++ b/betka/core.py @@ -340,14 +340,11 @@ def sync_to_downstream_branches(self, branch, origin_branch: str = ""): based on the configuration file. :param branch: downstream branch to check and to sync """ - if not self.config.get("master_checker"): - self.info("Syncing upstream repo to downstream repo is not allowed.") - return self.info(f"Syncing upstream {self.msg_upstream_url} to downstream {self.image}") description_msg = COMMIT_MASTER_MSG.format( hash=self.upstream_hash, repo=self.repo ) - mr = self.gitlab_api.check_gitlab_merge_requests(branch=branch) + mr = self.gitlab_api.check_gitlab_merge_requests(branch=branch, target_branch=origin_branch) if not mr and self.is_fork_enabled(): Git.get_changes_from_distgit(url=self.gitlab_api.get_forked_ssh_url_to_repo()) Git.push_changes_to_fork(branch=branch) @@ -660,19 +657,15 @@ def _sync_valid_branches(self, valid_branches): self.downstream_git_origin_branch = "" Git.call_git_cmd(f"checkout {branch}", msg="Change downstream branch") else: - self.downstream_git_branch = f"betka-{datetime.now().strftime('%Y%m%d%H%M%S')}{branch}" + self.downstream_git_branch = f"betka-{datetime.now().strftime('%Y%m%d%H%M%S')}-{branch}" self.downstream_git_origin_branch = branch Git.call_git_cmd( f"checkout -b {self.downstream_git_branch} {branch}", msg="Create a new downstream branch" ) - - # This loads downstream bot-cfg.yml file - # and update betka's dictionary (self.config). - # We need to have information up to date - - if not self._get_bot_cfg(branch=self.downstream_git_branch): + if not self._get_bot_cfg(branch=branch): continue + # Gets repo url without .git for cloning self.repo = Git.strip_dot_git(self.msg_upstream_url) self.info("SYNCING UPSTREAM TO DOWNSTREAM.") diff --git a/betka/gitlab.py b/betka/gitlab.py index 0eb0225..14d819e 100644 --- a/betka/gitlab.py +++ b/betka/gitlab.py @@ -398,7 +398,7 @@ def create_gitlab_merge_request( data["target_branch"] = origin_branch return self.create_project_mergerequest(data) - def check_gitlab_merge_requests(self, branch: str): + def check_gitlab_merge_requests(self, branch: str, target_branch: str): """ Checks if downstream already contains pull request. Check is based in the msg_to_check parameter. @@ -418,7 +418,7 @@ def check_gitlab_merge_requests(self, branch: str): ) logger.debug("Project_id different") continue - if mr.target_branch != branch: + if mr.target_branch != target_branch: logger.debug( "check_gitlab_merge_requests: Target branch does not equal." ) diff --git a/setup.py b/setup.py index 539baed..2cf0467 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ def get_requirements(): setup( name="betka", - version="0.9.4", + version="0.9.5", packages=find_packages(exclude=["examples", "tests"]), url="https://github.com/sclorg/betka", license="GPLv3+",