Skip to content

Miapp: derive base branch from origin/HEAD instead of $env:RepoBranchName - #9713

Merged
mazhelez merged 1 commit into
mainfrom
mazhelez/miapp-base-branch-from-origin-head
Jul 27, 2026
Merged

Miapp: derive base branch from origin/HEAD instead of $env:RepoBranchName#9713
mazhelez merged 1 commit into
mainfrom
mazhelez/miapp-base-branch-from-origin-head

Conversation

@mazhelez

@mazhelez mazhelez commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Summary

Miapp (the MicroApp Integrate tooling under build/scripts/Miapp/) derived its base branch from $env:RepoBranchName. When Miapp runs inside a repository whose default branch differs from an outer/consuming repository, that ambient variable points at the wrong branch. In practice, a monorepo that vendors BCApps as a submodule sets RepoBranchName=master for its own repo, but BCApps' default branch is main. Miapp then constructed refs like origin/master, which do not exist in BCApps, and failed:

fatal: ambiguous argument 'HEAD..origin/master': unknown revision or path not in the working tree.

Change

  • Replace Initialize-MiappRepoBranchName (env-based) with Get-MiappBaseBranch, which resolves the base branch from the repository's own origin/HEAD via git symbolic-ref --short refs/remotes/origin/HEAD, with git remote show origin as a fallback. The result is cached in a module-scoped variable.
  • No environment variable is read or written, so Miapp always targets the default branch of the repository it operates on.
  • Update all origin/$env:RepoBranchName usages across MicroApp.psm1, MicroAppGitHelper.psm1, MicroAppIntegrate.psm1, and MicroSnapApp.psm1, plus the README.

Testing

  • All modules parse cleanly.
  • Get-MiappBaseBranch returns main in BCApps even when $env:RepoBranchName=master.
  • The two previously failing commands (git log HEAD..origin/<base> and git log origin/<base>..HEAD) now resolve origin/main and exit 0.

AB#643986

Miapp read the base branch from $env:RepoBranchName. When run against a
submodule whose default branch differs from the outer repository (BCApps
uses 'main', while the consuming monorepo sets RepoBranchName='master'),
this built refs like 'origin/master' that do not exist in BCApps and failed
with: fatal: ambiguous argument 'HEAD..origin/master': unknown revision.

Replace Initialize-MiappRepoBranchName with Get-MiappBaseBranch, which
resolves the base branch from the repository's own origin/HEAD (git
symbolic-ref, with 'git remote show origin' as a fallback) and caches the
result in a module-scoped variable. No environment variable is read or
written, so Miapp always targets the default branch of the repository it
operates on.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@mazhelez
mazhelez requested review from a team July 24, 2026 11:34
@github-actions github-actions Bot added Build: scripts & configs Build scripts and configuration files Other GitHub request for other area than SCM, Finance or Integration Ownership: Needs Review Ownership is Other, low confidence, or needs manual correction labels Jul 24, 2026
@github-actions github-actions Bot added this to the Version 29.0 milestone Jul 24, 2026
@mazhelez
mazhelez added this pull request to the merge queue Jul 27, 2026
Merged via the queue into main with commit e654d6e Jul 27, 2026
335 of 338 checks passed
@mazhelez
mazhelez deleted the mazhelez/miapp-base-branch-from-origin-head branch July 27, 2026 08:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Build: scripts & configs Build scripts and configuration files Other GitHub request for other area than SCM, Finance or Integration Ownership: Needs Review Ownership is Other, low confidence, or needs manual correction

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants