Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Git branches list order and truncate priority issue #1647

Merged
merged 3 commits into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions CodeEdit/Features/CodeEditUI/Views/ToolbarBranchPicker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,15 @@ struct ToolbarBranchPicker: View {
}
}

let branches = sourceControlManager.branches
.filter({ $0.isLocal && $0 != sourceControlManager.currentBranch })
let branches = sourceControlManager.orderedLocalBranches
.filter({ $0 != sourceControlManager.currentBranch })
let branchesGroups = branches.reduce(into: [String: GitBranchesGroup]()) { result, branch in
guard let branchPrefix = branch.name.components(separatedBy: "/").first else {
return
}

result[
branchPrefix,
branchPrefix.lowercased(),
default: GitBranchesGroup(name: branchPrefix, branches: [])
].branches.append(branch)
}
Expand Down
8 changes: 8 additions & 0 deletions CodeEdit/Features/Git/SourceControlManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ final class SourceControlManager: ObservableObject {

@Published var isGitRepository: Bool = false

var orderedLocalBranches: [GitBranch] {
var orderedBranches: [GitBranch] = [currentBranch].compactMap { $0 }
let otherBranches = branches.filter { $0.isLocal && $0 != currentBranch }
.sorted { $0.name.lowercased() < $1.name.lowercased() }
orderedBranches.append(contentsOf: otherBranches)
return orderedBranches
}

init(
workspaceURL: URL,
editorManager: EditorManager
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ struct SourceControlNavigatorRepositoryItem: View {
.lineLimit(1)
.foregroundStyle(.secondary)
.font(.system(size: 11))
.layoutPriority(-1)
}
Spacer()
HStack(spacing: 5) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ extension SourceControlNavigatorRepositoryView {
label: "Branches",
systemImage: "externaldrive.fill",
imageColor: Color(nsColor: .secondaryLabelColor),
children: sourceControlManager.branches.filter({ $0.isLocal }).map { branch in
children: sourceControlManager.orderedLocalBranches.map { branch in
.init(
id: "Branch\(branch.name)",
label: branch.name,
Expand Down
Loading