Skip to content

Commit

Permalink
Minor refactor
Browse files Browse the repository at this point in the history
Signed-off-by: Paolo Di Tommaso <[email protected]>
  • Loading branch information
pditommaso committed Oct 9, 2024
1 parent 4c61d71 commit 6795ca9
Showing 1 changed file with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -425,13 +425,15 @@ class AssetManager {

String getDefaultBranch() {
// if specified in manifest, that takes priority
String branch = getManifest().getDefaultBranch()
if( !branch ) {
// otherwise look for a symbolic ref (refs/remotes/origin/HEAD)
Ref remoteHead = git.getRepository().findRef(REMOTE_DEFAULT_HEAD)
branch = remoteHead?.getTarget()?.getName()?.substring(REMOTE_REFS_ROOT.length())
}
return branch ?: DEFAULT_BRANCH
// otherwise look for a symbolic ref (refs/remotes/origin/HEAD)
return getManifest().getDefaultBranch()
?: getRemoteBranch()
?: DEFAULT_BRANCH
}

protected String getRemoteBranch() {
Ref remoteHead = git.getRepository().findRef(REMOTE_DEFAULT_HEAD)
return remoteHead?.getTarget()?.getName()?.substring(REMOTE_REFS_ROOT.length())
}

@Memoized
Expand Down

0 comments on commit 6795ca9

Please sign in to comment.