Skip to content

Commit

Permalink
Merge pull request #214 from lbarcziova/validation-head-commit-refactor
Browse files Browse the repository at this point in the history
[validation] refactor getting of the head commit of a PR

Reviewed-by: Jiri Popelka <None>
  • Loading branch information
softwarefactory-project-zuul[bot] committed May 26, 2021
2 parents 0deb2cc + 30c7997 commit 70a9d7c
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions cron-jobs/validation/packit-service-validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
from os import getenv

from github import InputGitAuthor
from github.Commit import Commit

from ogr.services.github import GithubService
from ogr.abstract import PullRequest

Expand All @@ -31,6 +33,7 @@ def __init__(self, pr: PullRequest = None, trigger: Trigger = Trigger.pr_opened)
self.pr = pr
self.failure_msg = ""
self.trigger = trigger
self.head_commit = pr.head_commit
self._copr_project_name = None

@property
Expand Down Expand Up @@ -79,17 +82,16 @@ def push_to_pr(self):
)
# https://pygithub.readthedocs.io/en/latest/examples/Repository.html#update-a-file-in-the-repository
# allows empty commit (always the same content of file)
project.github_repo.update_file(
commit: Commit = project.github_repo.update_file(
path=contents.path,
message=f"Commit build trigger ({date.today().strftime('%d/%m/%y')})",
content="Testing the push trigger.",
sha=contents.sha,
branch=self.pr.source_branch,
committer=user,
author=user,
)
# udpate the PR object so that the head commit is up to date
self.pr = project.get_pr(self.pr.id)
)["commit"]
self.head_commit = commit.sha

def create_pr(self):
"""
Expand Down Expand Up @@ -360,7 +362,7 @@ def get_statuses(self):
Get commit statuses from the head commit of the PR.
:return: [CommitStatus]
"""
commit = project.github_repo.get_commit(self.pr.head_commit)
commit = project.github_repo.get_commit(self.head_commit)
return commit.get_combined_status().statuses


Expand Down

0 comments on commit 70a9d7c

Please sign in to comment.