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

[Backport release-v1.3] Exclude headref from selected branches #345

Merged
merged 4 commits into from
Jun 8, 2023

Conversation

github-actions[bot]
Copy link
Contributor

@github-actions github-actions bot commented Jun 8, 2023

Description

Backport of #344 to release-v1.3.

korthout added 4 commits June 8, 2023 13:32
This is helpful to users to better understand which target branches have
been determined to backport to.

(cherry picked from commit a01196f)
If we want to exclude the headref from the possible target branches, we
need to provide it as a parameter to the findTargetBranches function.

I'm not so happy that this affects all previously written unit tests for
this function, but it is acceptable because headref has now become
important for this function.

(cherry picked from commit e6e5284)
This case is relevant where the target_branches input is used to select
the target branches, and the original pull request's headref is part of
it.

For example, consider selecting all feature branches `feature/*` as
target_branches. Glob patterns are not supported yet, but users can find
these with an additional step in their workflow:

```
run: |
  branches=$(git branch --list --all | grep 'origin/feature/' | cut -c 18- )
  space_delimited=${branches//$'\n'/ }
  echo "BRANCHES=${space_delimited}" >> $GITHUB_OUTPUT
```

Note that such a step requires a deep checkout `depth=0`.

But when users do this, they might encounter the feature branch they
just merged, the merged branch that triggered the backport-action.

By excluding it now, we can better support this case. In addition, it
will help support glob patterns in the target_branches input in the
future.

(cherry picked from commit 151736d)
The headref is excluded automatically. Since this is an explicit
difference in behavior, it should be clearly documented to avoid
surprises for users.

As far as I know, there is no use case to backport a pull request to
its headref. The cherry-pick would be interrupted because there are no
changes which would result in empty commits. Typically, the git user
get's to decide to skip these commits, or to abort the cherry-pick. This
means that would not be any new commits, and we cannot open an empty
pull request. So all of this doesn't work. The only thing left to do, is
exclude the headref from the determined target branches.

(cherry picked from commit 2f0f6c9)
@korthout korthout merged commit 7ad0341 into release-v1.3 Jun 8, 2023
@korthout korthout deleted the backport-344-to-release-v1.3 branch June 8, 2023 13:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant