Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Push to proper branch #135

Merged
merged 2 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.8
tags: latest 1 ${{ github.sha }} 0.10.0

- name: Push betka image to Quay.io
id: push-to-quay
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/python-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
strategy:
fail-fast: false
matrix:
tox_env: [py36, py38, py39, py310, py311, py312]
tox_env: [py311, py312]
# Use GitHub's Linux Docker host
runs-on: ubuntu-latest
steps:
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.8 \
RELEASE=0.10.0 \
ARCH=x86_64 \
SUMMARY="Syncs changes from upstream repository to downstream" \
DESCRIPTION="Syncs changes from upstream repository to downstream" \
Expand Down
32 changes: 26 additions & 6 deletions betka/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,10 +356,28 @@ def sync_to_downstream_branches(self, branch, origin_branch: str = ""):
git_status = Git.git_add_all(
upstream_msg=self.upstream_message,
related_msg=Git.get_msg_from_jira_ticket(self.config),

)
if not git_status:
self.info(
"There were no changes in repository. Do not file a pull request."
f"There were no changes in repository. Do not file a pull request."
)
BetkaEmails.send_email(
text=f"There were no changes in repository {self.image} to {branch}. Fork status {self.is_fork_enabled()}.",
receivers=["[email protected]"],
subject="[betka-diff] No git changes",
)
return

git_push_status = Git.git_push(fork_enabled=self.is_fork_enabled(), source_branch=branch)
if not git_push_status:
self.info(
f"Pushing to dist-git was not successful {branch}. Original_branch {origin_branch}."
)
BetkaEmails.send_email(
text=f"Pushing to {branch}. See logs from the bot.",
receivers=["[email protected]"],
subject="[betka-push] Pushing was not successful.",
)
return
# Prepare betka_schema used for sending mail and Pagure Pull Request
Expand Down Expand Up @@ -421,10 +439,12 @@ def get_master_fedmsg_info(self, message):
# https://apps.fedoraproject.org/datagrepper/id?id=2018-ab4ad1f9-36a0-483a-9401-6b5c2a314383&is_raw=true&size=extra-large
self.message = message
if "head_commit" not in self.message or self.message["head_commit"] == "":
self.info(
"Fedora Messaging does not contain head_commit or is head_commit is empty %r",
self.message,
)
if self.message.get("body"):
body = self.message.get("body")
self.info(
f"Fedora Messaging does not contain head_commit or is "
f"head_commit is empty {body['ref']}",
)
return False
href = self.message.get("ref")
head_commit = self.message.get("head_commit")
Expand Down Expand Up @@ -660,7 +680,7 @@ def _sync_valid_branches(self, valid_branches):
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}",
f"checkout -b {self.downstream_git_branch} --track origin/{branch}",
msg="Create a new downstream branch"
)
if not self._get_bot_cfg(branch=branch):
Expand Down
28 changes: 20 additions & 8 deletions betka/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,13 @@ def git_add_all(upstream_msg: str, related_msg: str) -> bool:
Add and push all files into the fork.
:param upstream_msg:
:param related_msg:
:param fork_enabled:
:param source_branch:
"""
#git_show_status = Git.call_git_cmd(
# "diff HEAD", ignore_error=True, msg="Check git status"
#)
#logger.debug(f"Show git diff {git_show_status}")
git_show_status = Git.call_git_cmd(
"diff HEAD", ignore_error=True, msg="Check git status"
)
logger.debug(f"Show git diff {git_show_status}")
Git.call_git_cmd("add -A", msg="Add all")

upstream_msg += f"\n{related_msg}\n"
Expand All @@ -88,11 +90,21 @@ def git_add_all(upstream_msg: str, related_msg: str) -> bool:
return False
except CalledProcessError:
pass
return True

try:
Git.call_git_cmd("push -u origin", msg="Push changes into git")
except CalledProcessError:
pass
@staticmethod
def git_push(fork_enabled: bool = False, source_branch: str = "") -> bool:

if fork_enabled:
try:
Git.call_git_cmd("push", msg="Push changes into git")
except CalledProcessError:
return False
else:
try:
Git.call_git_cmd(f"push -u origin {source_branch}", msg="Push changes into git")
except CalledProcessError:
return False
return True

@staticmethod
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.8",
version="0.10.0",
packages=find_packages(exclude=["examples", "tests"]),
url="https://github.com/sclorg/betka",
license="GPLv3+",
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tox]
skipsdist = True
envlist = py36,py38,py39,py310,py311,py312
envlist = py311,py312
DEPLOYMENT=test
[testenv]
commands = python3 -m pytest --color=yes -v --showlocals tests/
Expand Down
Loading