Skip to content

Commit

Permalink
Fix get branches
Browse files Browse the repository at this point in the history
Signed-off-by: Petr "Stone" Hracek <[email protected]>
  • Loading branch information
phracek committed Sep 19, 2024
1 parent 4d2bb18 commit 084fb3a
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 10 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.8.0
tags: latest 1 ${{ github.sha }} 0.8.1

- 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.8.0 \
RELEASE=0.8.1 \
ARCH=x86_64 \
SUMMARY="Syncs changes from upstream repository to downstream" \
DESCRIPTION="Syncs changes from upstream repository to downstream" \
Expand Down
1 change: 1 addition & 0 deletions betka/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,7 @@ def _update_valid_remote_branches(self):
# Branches are taken from upstream repository like
# https://src.fedoraproject.org/container/nginx not from fork
all_branches = Git.get_valid_remote_branches()
self.debug(f"All remote branches {all_branches}.")
# Filter our branches before checking bot-cfg.yml files
branch_list_to_sync = Git.branches_to_synchronize(
self.betka_config, all_branches=all_branches
Expand Down
5 changes: 3 additions & 2 deletions betka/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,10 @@ def get_valid_remote_branches() -> List[str]:
remote_branches = []
all_branches = Git.get_all_branches()
default_string = "remotes/upstream/"
for branch in all_branches.strip("\n"):
for branch in all_branches.split("\n"):
branch = branch.strip()
if branch.startswith(default_string):
new_branch = branch.strip().replace(default_string, "")
new_branch = branch.replace(default_string, "")
remote_branches.append(new_branch)
return remote_branches

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.8.0",
version="0.8.1",
packages=find_packages(exclude=["examples", "tests"]),
url="https://github.com/sclorg/betka",
license="GPLv3+",
Expand Down
4 changes: 3 additions & 1 deletion tests/data/all_branches
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
* rhel-8.0.0
remotes/origin/HEAD -> origin/rhel-8.0.0
remotes/origin/rhel-8.0.0
remotes/origin/rhel-8.1.1
Expand All @@ -19,4 +20,5 @@
remotes/upstream/rhel-9.0.0-beta
remotes/upstream/rhel-9.3.0
remotes/upstream/rhel-9.3.0-backup-2024-02-16T14_10_07_500835
remotes/upstream/rhel-9.6.0
remotes/upstream/rhel-9.5.0
remotes/upstream/rhel-9.6.0
9 changes: 5 additions & 4 deletions tests/unit/test_git.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ def test_update_msg(self, upstream_msg, expected_msg):

def test_git_all_branches(self):
branches_all = get_all_branches()
flexmock(Git).should_receive("get_valid_remote_branches").and_return(branches_all)
assert "rhel-9.5.0" in branches_all
assert "rhel-8.10.0-rhel810-sync" in branches_all
assert "rhel-9.5.0.0" not in branches_all
flexmock(Git).should_receive("get_all_branches").and_return(branches_all)
result_list = Git.get_valid_remote_branches()
assert "rhel-9.5.0" in result_list
assert "rhel-8.10.0-rhel810-sync" not in result_list
assert "rhel-9.5.0.0" not in result_list

0 comments on commit 084fb3a

Please sign in to comment.