Skip to content

Update branching instructions to be version-agnostic - #35066

Merged
PureWeen merged 3 commits into
mainfrom
fix/future-proof-branch-instructions
Apr 21, 2026
Merged

PureWeen merged 3 commits into
mainfrom
fix/future-proof-branch-instructions

Conversation

@PureWeen

Copy link
Copy Markdown
Member

Note

Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!

Description

The branching instructions in .github/copilot-instructions.md hardcoded net10.0 as the feature branch for new APIs. This becomes stale every time a new netN.0 branch is created (e.g., net11.0, net12.0).

This PR replaces the hardcoded version with a dynamic convention: the highest netN.0 branch is the current feature branch for new features and API changes. It also includes a discovery command so agents can programmatically find the right branch.

Changes

  • Removed hardcoded net10.0 branch line from Key Technologies section
  • Updated Feature branches description to explain the "highest netN.0" convention
  • Replaced hardcoded net10.0 in Branching section with version-agnostic pattern and discovery command

Why

This caused a real issue: during a multi-model code review of PR #34230, the reviewer incorrectly recommended targeting net10.0 instead of net11.0 because the instructions said net10.0. With this change, the instructions will remain correct as branches evolve.

Replace hardcoded 'net10.0' references with a dynamic pattern that
automatically applies as new netN.0 branches are created. The
instructions now describe the convention (highest netN.0 branch is
the feature branch) and include a command to discover it.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 21, 2026 20:16
@github-actions

github-actions Bot commented Apr 21, 2026 •

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 35066

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 35066"

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Updates .github/copilot-instructions.md branching guidance to avoid hardcoding a specific netN.0 feature branch, keeping the instructions accurate as new netN.0 branches are created.

Changes:

  • Removed the explicit net10.0 branch callout from the “Key Technologies” section.
  • Documented the convention that the highest netN.0 branch is the current feature/API-development branch.
  • Added a command intended to discover the current highest netN.0 branch from Git remotes.

Comment thread .github/copilot-instructions.md Outdated
### Branching
- `main` - For bug fixes without API changes
- `net10.0` - For new features and API changes
- The highest `netN.0` branch (e.g., `net11.0`, `net12.0`) - For new features and API changes. To find the current feature branch, run: `git branch -r | grep -oE 'origin/net[0-9]+\.0$' | sort -t. -k1 -V | tail -1`

Copilot AI Apr 21, 2026

Copy link

Choose a reason for hiding this comment

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

The discovery command relies on grep, sort, and tail, which won’t work in a default Windows PowerShell/Command Prompt environment (and may not be available in minimal shells). Since this doc targets cross-platform MAUI development, consider using a Git-only command (e.g., git for-each-ref with --sort=-version:refname and --count=1) to pick the highest netN.0 remote branch without external Unix tools.

Suggested change
- The highest `netN.0` branch (e.g., `net11.0`, `net12.0`) - For new features and API changes. To find the current feature branch, run: `git branch -r | grep -oE 'origin/net[0-9]+\.0$' | sort -t. -k1 -V | tail -1`
- The highest `netN.0` branch (e.g., `net11.0`, `net12.0`) - For new features and API changes. To find the current feature branch, run: `git for-each-ref --sort=-version:refname --count=1 --format='%(refname:short)' refs/remotes/origin/net*.0`

Copilot uses AI. Check for mistakes.
@PureWeen

PureWeen commented Apr 21, 2026 •

Copy link
Copy Markdown
Member Author

🔍 Multi-Model Code Review — PR #35066

PR: Update branching instructions to be version-agnostic
Author: @PureWeen | Base: main | Changed: .github/copilot-instructions.md (docs only)
Reviewers: 3 independent automated reviewers with adversarial consensus


CI Status: ✅ Passing (maui-pr skipping — expected for docs-only changes)


Prior Review Comments

No prior substantive review comments on this PR.


Findings

🟡 MODERATE — Discovery command output includes origin/ prefix

File: .github/copilot-instructions.md, line 142
Consensus: 3/3 reviewers agree (after adversarial round)

The command emits origin/net11.0, not net11.0. An agent interpolating the raw output into git checkout <branch> would detach HEAD instead of tracking the remote branch, and git push -u origin origin/net11.0 is malformed. Since this instruction exists specifically for agent consumption, the output should be directly usable.

Suggested fix: Change the grep to capture without the prefix:

git branch -r | grep -oE bnet[0-9]+.0 | sort -V | tail -1

Or append | sed 's|origin/||' to the existing pipeline.


🟡 MODERATE — Parenthetical examples (e.g., net11.0, net12.0) will go stale

File: .github/copilot-instructions.md, lines 21 and 142
Consensus: 3/3 reviewers agree

The examples appear twice and will become outdated when net13.0 is created — the exact class of staleness this PR is trying to eliminate. net12.0 doesn't even exist yet.

Suggested fix: Either remove the examples entirely (the discovery command is the source of truth) or use a truly generic pattern like (e.g., net{N}.0).


🟡 MODERATE — git branch -r requires prior fetch

File: .github/copilot-instructions.md, line 142
Consensus: 3/3 reviewers agree

In shallow clones or stale checkouts, git branch -r may return incomplete or outdated results. If the agent hasn't fetched, the command could return the wrong branch or nothing at all, with no indication of failure.

Suggested fix: Either prepend git fetch origin --quiet && to the command, or add a note: "Ensure remotes are fetched first (git fetch origin)."


🟡 MODERATE — "Highest netN.0" heuristic is an assumption, not an invariant

File: .github/copilot-instructions.md, lines 21 and 142
Consensus: 2/3 reviewers agree

If a higher-numbered branch is created ahead of time (e.g., net12.0 exists as a placeholder while net11.0 is still the active dev target), the heuristic returns the wrong branch. This is an edge case but worth acknowledging.

Suggested fix: Add a fallback note: "If unsure, check the github-merge-flow-net*.jsonc files for active merge targets."


🟢 MINOR — sort -t. -k1 -V flags are redundant

File: .github/copilot-instructions.md, line 142
Consensus: 2/3 reviewers agree (after adversarial round)

sort -V alone correctly handles version ordering on strings like origin/net10.0 vs origin/net11.0. The -t. -k1 flags restrict sorting to only the portion before the first dot, which is unnecessary and would actually break on hypothetical net10.0 vs net10.1 branches. Simplifying to sort -V is clearer.


🟢 MINOR — Inline command is complex for a markdown bullet point

File: .github/copilot-instructions.md, line 142
Consensus: 2/3 reviewers agree

A 4-stage bash pipeline in a bullet point is hard to read and maintain. A helper script in .github/scripts/ (e.g., Get-CurrentFeatureBranch.sh) would be more maintainable, or the command could be simplified as noted above.


🟢 MINOR — Removed concrete example reduces explanatory value

File: .github/copilot-instructions.md, line 21
Consensus: 3/3 reviewers agree

The deleted line **net10.0 branch**: .NET 10 SDK showed the concrete naming convention (netN.0 → .NET N SDK). New contributors lose this anchor. Consider adding a brief note like "Each netN.0 branch targets the .NET N SDK."


ℹ️ Informational — Out of scope but related

Finding Details
Other files hardcode net10.0 TFMs helix-device-tests.instructions.md (/p:_MauiDotNetTfm=net10.0), write-ui-tests/SKILL.md (net10.0-android), Run-DeviceTests.ps1 (net10.0-* literals). Same staleness class but TFMs, not branches — worth a follow-up PR.
sort -V portability Empirically verified working on macOS (BSD sort). Not an issue.

Test Coverage Assessment

N/A — documentation-only change, no code paths to test.


⚠️ Recommended Action: Request Changes

The direction is correct and the core problem (hardcoded net10.0) is solved. However, the discovery command has usability issues that should be fixed before merge:

  1. Strip origin/ prefix from command output (or adjust the grep) — agents will misuse the raw output
  2. Simplify sort to just sort -V
  3. Remove or genericize the (e.g., net11.0, net12.0) examples to avoid re-introducing staleness
  4. Add fetch prerequisite — note that git fetch origin is needed first

A revised command might look like:

git fetch origin --quiet && git branch -r | grep -oE \bnet[0-9]+\.0 | sort -V | tail -1

🔄 Re-Review — After Fixes (commit 52d0ccc)

Fixes addressed the Copilot inline suggestion and the majority of findings from the initial review. Re-reviewed with 3 independent reviewers.

Previous Findings Status

# Previous Finding Status Notes
1 origin/ prefix in command output ✅ FIXED %(refname:lstrip=3) correctly strips to net11.0
2 Stale (e.g., net11.0, net12.0) examples ✅ FIXED Replaced with generic netN.0 notation
3 Command requires prior git fetch ❌ STILL PRESENT git for-each-ref refs/remotes/… still reads local remote-tracking refs which can be stale. Easy fix: add "after running git fetch" to the sentence.
4 "Highest netN.0" heuristic is assumption ❌ STILL PRESENT Stated as fact ("is the current development branch") with no qualification. Minor wording change: "is typically" or "is (by convention)" would suffice.
5 Redundant sort -t. -k1 flags ➖ N/A Old command entirely replaced by git for-each-ref
6 Inline command is complex ❌ STILL PRESENT 🟢 The git for-each-ref command is cleaner than the old pipeline but still ~95 chars in a bullet point. Acceptable trade-off.
7 Lost concrete naming example ✅ FIXED "Each netN.0 branch targets the .NET N SDK" is self-documenting

New Issues

None found by any reviewer. Two single-reviewer findings were discarded after analysis:

  • net*.0 glob could match hypothetical net-preview.0 — no such branches exist or are expected
  • Hardcoded origin remote name — standard git convention, universal for this repo

✅ Recommended Action: Approve

4 of 7 original findings are fixed, 1 is N/A, and the 2 remaining items (#3 fetch prerequisite, #4 heuristic wording) are minor documentation nits that don't affect correctness for the primary use case. The PR achieves its goal: branching instructions that won't go stale when new netN.0 branches are created.

The remaining items can be addressed in a follow-up if desired:

  • Add "after running git fetch origin" caveat
  • Soften "is" → "is (by convention)" for the heuristic

…le examples

- Replace grep/sort/tail pipeline with git for-each-ref (works on all
  platforms without Unix tools)
- Strip origin/ prefix from output via refname:lstrip=3
- Remove version-specific examples (net11.0, net12.0) that would go stale
- Add concrete naming convention: each netN.0 branch targets .NET N SDK

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Redth
Redth previously approved these changes Apr 21, 2026
- Add 'git fetch origin' prerequisite before discovery command
- Soften 'is the current' to 'by convention' in both locations

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@PureWeen
PureWeen merged commit f49d3bd into main Apr 21, 2026
4 of 5 checks passed
@PureWeen
PureWeen deleted the fix/future-proof-branch-instructions branch April 21, 2026 21:07
@github-actions github-actions Bot added this to the .NET 10 SR7 milestone Apr 21, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators May 22, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants