mirror of
https://github.com/coollabsio/coolify.git
synced 2025-12-28 05:34:50 +00:00
feat: Prioritize main/master branches in branch selection dropdown
Add sortBranchesByPriority() helper to sort branches with priority: main first, master second, then alphabetically. This improves UX by pre-selecting the most commonly used default branches.
This commit is contained in:
parent
a528f4c3d1
commit
3c2f6a5fd6
@ -138,6 +138,7 @@ class GithubPrivateRepository extends Component
|
||||
$this->loadBranchByPage();
|
||||
}
|
||||
}
|
||||
$this->branches = sortBranchesByPriority($this->branches);
|
||||
$this->selected_branch_name = data_get($this->branches, '0.name', 'main');
|
||||
}
|
||||
|
||||
|
||||
@ -300,6 +300,24 @@ function generate_application_name(string $git_repository, string $git_branch, ?
|
||||
return Str::kebab("$git_repository:$git_branch-$cuid");
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort branches by priority: main first, master second, then alphabetically.
|
||||
*
|
||||
* @param Collection $branches Collection of branch objects with 'name' key
|
||||
*/
|
||||
function sortBranchesByPriority(Collection $branches): Collection
|
||||
{
|
||||
return $branches->sortBy(function ($branch) {
|
||||
$name = data_get($branch, 'name');
|
||||
|
||||
return match ($name) {
|
||||
'main' => '0_main',
|
||||
'master' => '1_master',
|
||||
default => '2_'.$name,
|
||||
};
|
||||
})->values();
|
||||
}
|
||||
|
||||
function base_ip(): string
|
||||
{
|
||||
if (isDev()) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user