Ado Pr Publish Flow
Overview
Publish the current branch to Azure DevOps with consistent naming, linking, and conflict handling rules.
Complete the flow in one pass: commit, push, check conflicts against origin/dev, resolve if needed, create PR, and return the PR URL.
Run git history-changing steps sequentially, never in parallel (especially commit and push).
Workflow
1) Collect context and normalize work item IDs
- Read current branch:
git rev-parse --abbrev-ref HEAD.
- Resolve Azure DevOps defaults if needed:
az devops configure --defaults organization=https://dev.azure.com/TCMD project=Andromeda
- Determine in-scope AB IDs from user input first.
- If IDs are not explicitly provided, infer from:
- Branch pattern
users/andreym/<id>-...
- Existing commit text containing
AB#<id>
- Fetch each ID with relations:
az boards work-item show --id <id> --expand relations -o json
- Build two ID sets:
- Commit link IDs: all in-scope IDs.
- PR link IDs: all provided/in-scope IDs, plus parent IDs for any provided child item.
2) Enforce branch naming convention
- Required pattern for features/bugs:
users/andreym/{ticketNumber}-some-short-explanation
- Example:
users/andreym/1111-localization
- If creating a new branch for a ticket, base it on latest
origin/dev:
git fetch origin dev
git switch -c users/andreym/<firstId>-<short-slug> origin/dev
- If the current branch does not match and you have at least one AB ID, create a compliant branch from the current
HEAD only when explicitly continuing pre-existing work.
- If the current branch already matches, keep using it.
3) Commit and push all current changes
- Stage all current changes:
- Generate a concise commit subject from the diff:
- Base on changed files and the dominant intent.
- Keep the subject short and specific.
- Ensure the commit message includes AB linking with
Fixes AB#....
- Use this format:
- Subject:
<TicketType> #<id>[ #<id>...]: <short change summary>
- Body/footer:
Fixes AB#<id> AB#<id> ...
- Normalize
<TicketType> for commit subjects to Infra/Feature/Bug (never Task) using the same mapping rules as PR titles.
- Push (sequentially after commit; do not run in parallel with commit):
git push -u origin <current-branch>
- Verify push propagated to remote before creating PR:
git fetch origin
git rev-parse HEAD
git rev-parse origin/<current-branch>
- If SHAs differ, push again and re-check.
4) Check conflict risk against latest origin/dev
- Fetch latest target branch:
- Detect conflict risk without modifying history:
BASE=$(git merge-base HEAD origin/dev)
git merge-tree "$BASE" HEAD origin/dev | rg '<<<<<<<|>>>>>>>'
- If no conflict markers are found, continue to PR creation.
- If conflict markers are found:
- Merge latest dev into current branch:
git merge origin/dev
- Resolve conflicts in files.
- Stage resolved files:
git add <resolved-files>
- Commit conflict resolution with AB linking:
- Subject:
Infra #<id>[ #<id>...]: Resolve merge conflicts with dev
- Body/footer:
Fixes AB#<id> AB#<id> ...
- Push updated branch again.
4.5) Validate PR branch contains only intended commits
- Inspect divergence from target:
git log --oneline --left-right origin/dev...HEAD
- Confirm commits on the
> side are in scope for the current ticket(s).
- If unrelated commits are present:
- Rebase/cherry-pick onto latest
origin/dev.
- Prefer
git rebase --onto origin/dev <old-base> <current-branch> when linear cleanup is straightforward.
- Otherwise create a clean branch from
origin/dev, cherry-pick intended commits, then force-push with lease:
git push --force-with-lease origin <current-branch>
5) Build PR title and description with naming/linking rules
- Use PR title format:
{ticket type} #{ticket number}: {name of story}
- Ticket type rules:
- PR titles may only use:
Infra, Feature, Bug (never Task).
- Use type from Azure Boards when available, then normalize to one of:
Infra, Feature, Bug.
- If Azure Boards returns
Task, resolve the parent work item type and use it when it maps to Infra/Feature/Bug.
- If parent type is missing or still not mappable, default PR title type to
Feature.
- Ticket number rules:
- Include all provided work item ticket numbers.
- Do not include parent-only ticket numbers in the PR title.
- Multiple numbers format example:
Bug #1234 #5678: Fix login crash
- Story name rule:
- Use the primary story/work item title or a short meaningful explanation.
- PR description must be Markdown and include:
- What changed
- Why it changed
- How it was validated
- Links section with
Fixes AB#...
- PR link policy:
- In commit(s): include
Fixes AB#... for all in-scope IDs.
- In PR: include all provided item IDs in
Fixes AB#....
- If a provided item has a parent, include that parent ID too.
- Parent IDs are linked as PR work items only and are not added to the PR title.
6) Create PR with Azure CLI
- Write PR description to a markdown file (for example
pr.md).
- Create the PR to
dev:
az repos pr create --repository Andromeda.iOS --source-branch <current-branch> --target-branch dev --title "<title>" --description @pr.md --work-items <pr-link-ids> --delete-source-branch true
- Return the PR URL from command output.
- Remove temporary
pr.md after PR creation.
Output requirements
- Report:
- Current branch used
- Commit(s) created
- Whether conflicts were detected/resolved
- Final PR title
- Final PR URL
- If required metadata is missing (for example no AB ID), fail fast and state what is missing.
- Never skip naming or linking conventions.
1---2name: ado-pr-publish-flow3description: End-to-end Azure DevOps PR publish workflow for Andromeda.iOS. Use when asked to commit and push all current changes, verify conflict risk against latest remote dev, resolve and re-commit if conflicts exist, and open a PR to dev with Azure CLI. Enforce branch naming `users/andreym/{ticketNumber}-some-short-explanation`, PR title naming `{ticket type}4---56# Ado Pr Publish Flow78## Overview910Publish the current branch to Azure DevOps with consistent naming, linking, and conflict handling rules.11Complete the flow in one pass: commit, push, check conflicts against `origin/dev`, resolve if needed, create PR, and return the PR URL.12Run git history-changing steps sequentially, never in parallel (especially `commit` and `push`).1314## Workflow1516### 1) Collect context and normalize work item IDs17181. Read current branch: `git rev-parse --abbrev-ref HEAD`.192. Resolve Azure DevOps defaults if needed:20 - `az devops configure --defaults organization=https://dev.azure.com/TCMD project=Andromeda`213. Determine in-scope AB IDs from user input first.224. If IDs are not explicitly provided, infer from:23 - Branch pattern `users/andreym/<id>-...`24 - Existing commit text containing `AB#<id>`255. Fetch each ID with relations:26 - `az boards work-item show --id <id> --expand relations -o json`276. Build two ID sets:28 - Commit link IDs: all in-scope IDs.29 - PR link IDs: all provided/in-scope IDs, plus parent IDs for any provided child item.3031### 2) Enforce branch naming convention32331. Required pattern for features/bugs:34 - `users/andreym/{ticketNumber}-some-short-explanation`35 - Example: `users/andreym/1111-localization`362. If creating a new branch for a ticket, base it on latest `origin/dev`:37 - `git fetch origin dev`38 - `git switch -c users/andreym/<firstId>-<short-slug> origin/dev`393. If the current branch does not match and you have at least one AB ID, create a compliant branch from the current `HEAD` only when explicitly continuing pre-existing work.404. If the current branch already matches, keep using it.4142### 3) Commit and push all current changes43441. Stage all current changes:45 - `git add -A`462. Generate a concise commit subject from the diff:47 - Base on changed files and the dominant intent.48 - Keep the subject short and specific.493. Ensure the commit message includes AB linking with `Fixes AB#...`.504. Use this format:51 - Subject: `<TicketType> #<id>[ #<id>...]: <short change summary>`52 - Body/footer: `Fixes AB#<id> AB#<id> ...`535. Normalize `<TicketType>` for commit subjects to `Infra`/`Feature`/`Bug` (never `Task`) using the same mapping rules as PR titles.546. Push (sequentially after commit; do not run in parallel with commit):55 - `git push -u origin <current-branch>`567. Verify push propagated to remote before creating PR:57 - `git fetch origin`58 - `git rev-parse HEAD`59 - `git rev-parse origin/<current-branch>`60 - If SHAs differ, push again and re-check.6162### 4) Check conflict risk against latest `origin/dev`63641. Fetch latest target branch:65 - `git fetch origin dev`662. Detect conflict risk without modifying history:67 - `BASE=$(git merge-base HEAD origin/dev)`68 - `git merge-tree "$BASE" HEAD origin/dev | rg '<<<<<<<|>>>>>>>'`693. If no conflict markers are found, continue to PR creation.704. If conflict markers are found:71 - Merge latest dev into current branch: `git merge origin/dev`72 - Resolve conflicts in files.73 - Stage resolved files: `git add <resolved-files>`74 - Commit conflict resolution with AB linking:75 - Subject: `Infra #<id>[ #<id>...]: Resolve merge conflicts with dev`76 - Body/footer: `Fixes AB#<id> AB#<id> ...`77 - Push updated branch again.7879### 4.5) Validate PR branch contains only intended commits80811. Inspect divergence from target:82 - `git log --oneline --left-right origin/dev...HEAD`832. Confirm commits on the `>` side are in scope for the current ticket(s).843. If unrelated commits are present:85 - Rebase/cherry-pick onto latest `origin/dev`.86 - Prefer `git rebase --onto origin/dev <old-base> <current-branch>` when linear cleanup is straightforward.87 - Otherwise create a clean branch from `origin/dev`, cherry-pick intended commits, then force-push with lease:88 - `git push --force-with-lease origin <current-branch>`8990### 5) Build PR title and description with naming/linking rules91921. Use PR title format:93 - `{ticket type} #{ticket number}: {name of story}`942. Ticket type rules:95 - PR titles may only use: `Infra`, `Feature`, `Bug` (never `Task`).96 - Use type from Azure Boards when available, then normalize to one of: `Infra`, `Feature`, `Bug`.97 - If Azure Boards returns `Task`, resolve the parent work item type and use it when it maps to `Infra`/`Feature`/`Bug`.98 - If parent type is missing or still not mappable, default PR title type to `Feature`.993. Ticket number rules:100 - Include all provided work item ticket numbers.101 - Do not include parent-only ticket numbers in the PR title.102 - Multiple numbers format example: `Bug #1234 #5678: Fix login crash`1034. Story name rule:104 - Use the primary story/work item title or a short meaningful explanation.1055. PR description must be Markdown and include:106 - What changed107 - Why it changed108 - How it was validated109 - Links section with `Fixes AB#...`1106. PR link policy:111 - In commit(s): include `Fixes AB#...` for all in-scope IDs.112 - In PR: include all provided item IDs in `Fixes AB#...`.113 - If a provided item has a parent, include that parent ID too.114 - Parent IDs are linked as PR work items only and are not added to the PR title.115116### 6) Create PR with Azure CLI1171181. Write PR description to a markdown file (for example `pr.md`).1192. Create the PR to `dev`:120 - `az repos pr create --repository Andromeda.iOS --source-branch <current-branch> --target-branch dev --title "<title>" --description @pr.md --work-items <pr-link-ids> --delete-source-branch true`1213. Return the PR URL from command output.1224. Remove temporary `pr.md` after PR creation.123124## Output requirements1251261. Report:127 - Current branch used128 - Commit(s) created129 - Whether conflicts were detected/resolved130 - Final PR title131 - Final PR URL1322. If required metadata is missing (for example no AB ID), fail fast and state what is missing.1333. Never skip naming or linking conventions.