Skip to content

Commit

Permalink
Add a warning annotation to GitHub Actions logs
Browse files Browse the repository at this point in the history
Check if a Pull Request exists in a repository that already has a Lineage
branch on the remote. If a PR does not exist emit a warning as this is
undesirable behavior. This may indicate an undeleted head branch from a
previously merged Lineage PR.
  • Loading branch information
mcdonnnj committed Oct 29, 2021
1 parent d8a4f17 commit d78f7e7
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/lineage/entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,16 @@ def get_code_owners(repo: Repository.Repository) -> Generator[str, None, None]:
break


def has_existing_pr(repo: Repository.Repository, branch_name: str) -> bool:
"""Check if an open PR already exists for the lineage branch."""
# By default only open Pull Requests are returned
pull_requests = repo.get_pulls()
for pr in pull_requests:
if pr.head.ref == branch_name:
return True
return False


def main() -> None:
"""Parse environment and perform requested actions."""
# Set up logging. Force logging output to stdout to allow for GitHub Actions
Expand Down Expand Up @@ -412,6 +422,12 @@ def main() -> None:
repo, lineage_id, local_branch
)
logging.info("Pull request branch is new: %s", branch_is_new)
# Check if a PR exists if the branch already exists
if not branch_is_new and not has_existing_pr(repo, pr_branch_name):
core.warning(
"There is no Pull Request for the existing Lineage branch.",
title=repo.full_name,
)
fetch(repo, remote_url, remote_branch)
changed: bool
conflict_file_list: List[str]
Expand Down

0 comments on commit d78f7e7

Please sign in to comment.