Skip to content

Commit

Permalink
Fix pulling bot-cfg from downstream.
Browse files Browse the repository at this point in the history
Signed-off-by: Petr "Stone" Hracek <[email protected]>
  • Loading branch information
phracek committed Nov 7, 2024
1 parent 04b7171 commit ae829b3
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-and-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -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" \
Expand Down
15 changes: 4 additions & 11 deletions betka/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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.")
Expand Down
4 changes: 2 additions & 2 deletions betka/gitlab.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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."
)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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+",
Expand Down

0 comments on commit ae829b3

Please sign in to comment.