Skip to content

Commit

Permalink
Factor out code change detection into helper function
Browse files Browse the repository at this point in the history
Summary: Set up for next diff where we add additional checks.

Reviewed By: danielocfb

Differential Revision: D63914822

fbshipit-source-id: a4e9d6bea3be657b5fb4538b6c021a50aec07dca
  • Loading branch information
Daniel Xu authored and facebook-github-bot committed Oct 4, 2024
1 parent 543eb6e commit 5a1be26
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions kernel_patches_daemon/branch_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,14 @@ async def _series_already_applied(repo: git.Repo, series: Series) -> bool:
return any(ps.lower() in summaries for ps in await series.patch_subjects())


def _is_branch_changed(repo: git.Repo, old_branch: str, new_branch: str) -> bool:
"""
Returns whether or not the new_branch (in local repo) is different from
the old_branch (remote repo).
"""
return repo.git.diff(new_branch, old_branch)


def _is_outdated_pr(pr: PullRequest) -> bool:
"""
Check if a pull request is outdated, i.e., whether it has not seen an update recently.
Expand Down Expand Up @@ -928,8 +936,8 @@ async def apply_push_comment(
# which could mean that we applied new set of patches or just rebased
if branch_name in self.branches and (
branch_name not in self.all_prs # NO PR yet
or self.repo_local.git.diff(
branch_name, f"remotes/origin/{branch_name}"
or _is_branch_changed(
self.repo_local, f"remotes/origin/{branch_name}", branch_name
) # have code changes
):
# we have branch, but either NO PR or there is code changes, we must try to
Expand Down

0 comments on commit 5a1be26

Please sign in to comment.