Skip to content

feat: add automatic AB# tagging from branch name#152

Open
joshjohanning wants to merge 4 commits intomainfrom
add-work-item-linkage-from-branch-name
Open

feat: add automatic AB# tagging from branch name#152
joshjohanning wants to merge 4 commits intomainfrom
add-work-item-linkage-from-branch-name

Conversation

@joshjohanning
Copy link
Owner

@joshjohanning joshjohanning commented Mar 6, 2026

Add new add-work-item-from-branch input that extracts work item IDs from the head branch name and appends AB#xxx to the PR body if not already present. Supports common branch formats like task/12345/description, task-12345, 12345-description, and more.

Only matches 3+ digits to avoid versioning conflicts / false positive links

I've implemented this as a new add-work-item-from-branch input. When enabled, the action extracts work item IDs from the head branch name and automatically adds AB#<id> to the PR body if it's not already present.

Supported branch formats

All of your examples are supported -- the action looks for digit sequences preceded by the start of the branch name or a separator (/, -, _):

Branch name Extracted
task/12345/make-it-better AB#12345
task/12345-make-it-better AB#12345
task/12345 AB#12345
task-12345 AB#12345
12345-make-it-better AB#12345
12345make-it-better AB#12345
12345 AB#12345

It also handles multiple IDs in a single branch name (e.g. fix/12345/67890 adds both AB#12345 and AB#67890), and skips any IDs already referenced in the PR body.

Usage

- uses: joshjohanning/azdo_commit_message_validator@v2
  with:
    add-work-item-from-branch: true
    check-pull-request: true
    check-commits: true
    fail-if-missing-workitem-commit-link: true
    link-commits-to-pull-request: true
    azure-devops-organization: my-azdo-org
    azure-devops-token: ${{ secrets.AZURE_DEVOPS_PAT }}

The branch extraction runs before the commit/PR validation checks, so the newly added tags will satisfy subsequent check-pull-request validation.

This is off by default (false) so it's fully opt-in.

closes #151

Add new `add-ab-tag-from-branch` input that extracts work item IDs from
the head branch name and appends AB#xxx to the PR body if not already
present. Supports common branch formats like task/12345/description,
task-12345, 12345-description, and more.

closes #151
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements a new add-ab-tag-from-branch input that automatically extracts Azure DevOps work item IDs from the head branch name and appends the corresponding AB#xxx tags to the PR body if not already present. This addresses feature request #151 from users who want branch names like task/12345/fix-bug to automatically populate the PR body with AB#12345.

Changes:

  • New add-work-item-from-branch input and its extraction/update logic (extractWorkItemIdsFromBranch, addWorkItemsToPRBody functions)
  • Comprehensive test suite covering happy path, duplicate prevention, empty body, multiple IDs, and disabled scenarios
  • Documentation updates (README, action.yml) and version bump to 3.3.0

Reviewed changes

Copilot reviewed 5 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/index.js Core implementation: new regex pattern, extractWorkItemIdsFromBranch export, addWorkItemsToPRBody async function, and wiring into run()
__tests__/index.test.js Unit tests for extractWorkItemIdsFromBranch and integration tests for Add AB# tag from branch scenarios
action.yml New add-work-item-from-branch input declaration
README.md New feature listed in Key Features, new row in the Inputs table
package.json / package-lock.json Minor version bump to 3.3.0
badges/coverage.svg Updated coverage badge from 85.12% to 86.26%

You can also share your feedback on Copilot code review. Take the survey.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 7 changed files in this pull request and generated 3 comments.


You can also share your feedback on Copilot code review. Take the survey.

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.

Automatically add AB# tag from id in source branch

2 participants