Return header if no branches match current ref (or null if empty repo)

This commit is contained in:
Abdelilah El Aissaoui 2022-02-17 23:03:19 +01:00
parent 32ef5d50cd
commit 9dc5296a61

View file

@ -21,7 +21,17 @@ class BranchesManager @Inject constructor() {
.repository
.fullBranch
return branchList.firstOrNull { it.name == branchName }
var branchFound = branchList.firstOrNull {
it.name == branchName
}
if(branchFound == null) {
branchFound = branchList.firstOrNull {
it.objectId.name == branchName // Try to get the HEAD
}
}
return branchFound
}
suspend fun getBranches(git: Git) = withContext(Dispatchers.IO) {