Miapp: derive base branch from origin/HEAD instead of $env:RepoBranchName#9713
Open
mazhelez wants to merge 1 commit into
Open
Miapp: derive base branch from origin/HEAD instead of $env:RepoBranchName#9713mazhelez wants to merge 1 commit into
mazhelez wants to merge 1 commit into
Conversation
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>
spetersenms
approved these changes
Jul 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Miapp(the MicroApp Integrate tooling underbuild/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 setsRepoBranchName=masterfor its own repo, but BCApps' default branch ismain. Miapp then constructed refs likeorigin/master, which do not exist in BCApps, and failed:Change
Initialize-MiappRepoBranchName(env-based) withGet-MiappBaseBranch, which resolves the base branch from the repository's ownorigin/HEADviagit symbolic-ref --short refs/remotes/origin/HEAD, withgit remote show originas a fallback. The result is cached in a module-scoped variable.origin/$env:RepoBranchNameusages acrossMicroApp.psm1,MicroAppGitHelper.psm1,MicroAppIntegrate.psm1, andMicroSnapApp.psm1, plus the README.Testing
Get-MiappBaseBranchreturnsmainin BCApps even when$env:RepoBranchName=master.git log HEAD..origin/<base>andgit log origin/<base>..HEAD) now resolveorigin/mainand exit 0.AB#643986