feat: add automatic AB# tagging from branch name#152
feat: add automatic AB# tagging from branch name#152joshjohanning wants to merge 8 commits intomainfrom
Conversation
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
There was a problem hiding this comment.
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-branchinput and its extraction/update logic (extractWorkItemIdsFromBranch,addWorkItemsToPRBodyfunctions) - 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.
…fy usage with check-pull-request
There was a problem hiding this comment.
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.
… digit IDs and update related documentation
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 5 changed files in this pull request and generated 2 comments.
You can also share your feedback on Copilot code review. Take the survey.
- add-work-item-from-branch now requires azure-devops-token and azure-devops-organization; extracted IDs are always validated against Azure DevOps before being added to the PR body - Remove 3-digit minimum from branch regex since validation catches false positives - Sanitize branch name in job summary to prevent markdown injection - Fix JSDoc param type for extractWorkItemIdsFromBranch - Clean up dangling append-work-item-title test references - Add tests for validation of branch-extracted IDs and missing token
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 5 changed files in this pull request and generated 3 comments.
You can also share your feedback on Copilot code review. Take the survey.
- Fix GHAS incomplete string escaping: escape backslashes in branchName - Allow add-work-item-from-branch as standalone (update guard condition) - Cap branch ID extraction at 5 to limit API calls - Fix misleading azure-devops-token/organization descriptions in README - Add test for standalone branch extraction usage
|
Moving this back to draft while I work through the false positive problem with branch name extraction. The core issue: extracting bare numbers from branch names (e.g. The 3-digit minimum helps with very short numbers ( Still thinking through the best approach here. Some options under consideration:
Will update once I have a cleaner solution. cc @davetevans |
|
I would vote for the prefix pattern matching |
Summary
Add new
add-work-item-from-branchinput that extracts work item IDs from the head branch name and addsAB#xxxto the PR body if not already present. Each extracted ID is validated against Azure DevOps before being added, preventing false positives from version numbers or other numeric patterns in branch names.Resolves #151
Changes
add-work-item-from-branchinput -- extracts digit sequences from branch names preceded by a separator (/,-,_) or start of stringazure-devops-tokenandazure-devops-organization; each ID is checked against Azure DevOps and only valid work items are added to the PR body. Invalid IDs are skipped with a warning.main-- includes the breakingnode20tonode24runtime upgrade, and theadd-work-item-tablefeature (which replaced the oldappend-work-item-titleinput)append-work-item-titlereferences from test mocksSupported branch formats
task/12345/make-it-betterAB#12345task/12345-make-it-betterAB#12345task/12345AB#12345task-12345AB#1234512345-make-it-betterAB#1234512345make-it-betterAB#1234512345AB#12345Multiple IDs in a single branch name are also supported (e.g.
fix/12345/67890adds bothAB#12345andAB#67890), and IDs already referenced in the PR body are skipped.Design decisions
2024fromhotfix-2024-somethingare safely filtered out by the Azure DevOps validation.validate-work-item-existsis independent --add-work-item-from-branchhas validation built in (it must confirm numbers are real work items).validate-work-item-existsseparately controls whether human-writtenAB#references in commits/PR body are validated. These are separate concerns; a user can enable branch extraction while trusting manually-written references.AB#tags satisfy subsequentcheck-pull-requestvalidation.Usage
Test coverage
extractWorkItemIdsFromBranch(various branch formats, duplicates, empty input, short numbers)