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

Extracted id is wrong in updated title #31

Open
watadarkstar opened this issue Nov 10, 2022 · 0 comments
Open

Extracted id is wrong in updated title #31

watadarkstar opened this issue Nov 10, 2022 · 0 comments

Comments

@watadarkstar
Copy link

watadarkstar commented Nov 10, 2022

Description

If no ticket/issue ID is in the title, it will extract the ID from the branch or body and update the title for you. It will fail the check if no ticket ID is found anywhere.

This doesn't work properly when you use a full URL link with a :repo or :owner that has a number in its name.

Here is an example repo that produces the issue:
watadarkstar/pull-request-ticket-222-check-bug#4

Notice how the repository name has a number in the name. That is key to get this bug to occur.

Seems like the issue is found on this line of code:

const result = value.match(/\d+/);

Steps to reproduce

Important: The repo or owner must have a number in the name for this bug to occur.

  1. Add the following to .github/workflows/pull-request-linting.yml and replace :repo and :owner with your actual repository that has a number in the name. i.e. :repo could be foo-22222-bar
name: Pull Request Lint

on:
  pull_request:
    types: ["opened", "edited", "reopened", "synchronize"]

jobs:
  title:
    name: ticket check
    runs-on: ubuntu-latest

    steps:
      - name: Check for ticket
        uses: neofinancial/ticket-check-action@v1
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          ticketPrefix: "#"
          bodyRegex: '#(?<ticketNumber>\d+)'
          bodyURLRegex: 'http(s?):\/\/(github.com)(\/:owner)(\/:repo)(\/issues)\/(?<ticketNumber>\d+)'
  1. Open a pull request and in the body put (replace :owner and :repo):
Some body text 

Closes https://github.com/:owner/:repo/issues/1
  1. Wait until the workflow finishes and the title will not have #1 in the title but instead will have the first number it finds in the repo name or the owners name i.e. if the repo is named foo-22222-bar it will always have #22222 in the title
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

No branches or pull requests

1 participant