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

Referred issues placeholder #77

Merged
merged 4 commits into from
Jun 27, 2021
Merged

Referred issues placeholder #77

merged 4 commits into from
Jun 27, 2021

Conversation

korthout
Copy link
Owner

Adds a new placeholder ${issue_refs} to be used in custom pull descriptions introduced in #64.

This placeholder will be replaced with all issues mentioned in the original pull request's description (aka body). Issue mentions can be GitHub issue references (e.g. #123 or zeebe-io/backport-action#123) or urls to GitHub issues.

This supports reference to issues in external repositories. For GitHub references, the full reference is kept in-tact as is, but urls are always transformed into the full reference (i.e. including the org and repo) even for local repo references.

closes #3

Tested successfully in https://github.com/zeebe-io/automation-lab/pull/67

This method was hard to build due to the complications of working with
regex. However, because the entire method can work on a string and does
not require any other dependencies, it made sense to expose it as a
single exported function in a utils file. This made testing a lot
easier, because it does not require us to do any additional setup.

The tests are structured in a way to test the most common cases and the
helper method is created to allow the test code to focus on test cases.

In ES2020, string.matchAll is added which allows capturing groups of all
matches. Using this we would not have to execute the url pattern on each
individual matched url again to find the capture groups (which we use to
construct the issue reference). Sadly, ES2020 is not available in nodejs
12 which is used by default for github actions.
The placeholder ${issue_refs} is replaced with all issues mentioned in
the original pull request's body. Urls are tranformed into actual GitHub
refs (like org/repo#number). External repo issue reference still refer
to the external repo. Finally, all indidividual references are seperated
by a space when used to replace the placeholder.
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.

Link backport PR to original issue
1 participant