File tree Expand file tree Collapse file tree 3 files changed +30
-9
lines changed
Settings/Pages/SourceControlSettings Expand file tree Collapse file tree 3 files changed +30
-9
lines changed Original file line number Diff line number Diff line change @@ -71,8 +71,6 @@ extension SettingsData {
7171 var revisionComparisonLayout : RevisionComparisonLayout = . localLeft
7272 /// The selected value of the control navigator
7373 var controlNavigatorOrder : ControlNavigatorOrder = . sortByName
74- /// The name of the default branch
75- var defaultBranchName : String = " main "
7674 /// Default initializer
7775 init ( ) { }
7876 /// Explicit decoder init for setting default values when key is not present in `JSON`
@@ -109,7 +107,6 @@ extension SettingsData {
109107 ControlNavigatorOrder . self,
110108 forKey: . controlNavigatorOrder
111109 ) ?? . sortByName
112- self . defaultBranchName = try container. decodeIfPresent ( String . self, forKey: . defaultBranchName) ?? " main "
113110 }
114111 }
115112
Original file line number Diff line number Diff line change @@ -11,7 +11,10 @@ struct SourceControlGeneralView: View {
1111 @AppSettings ( \. sourceControl. general)
1212 var settings
1313
14- @State private var text : String = " main "
14+ let gitConfig = GitConfigClient ( shellClient: currentWorld. shellClient)
15+
16+ @State private var defaultBranch : String = " "
17+ @State private var hasAppeared = false
1518
1619 var body : some View {
1720 SettingsForm {
@@ -32,6 +35,14 @@ struct SourceControlGeneralView: View {
3235 defaultBranchName
3336 }
3437 }
38+ . onAppear {
39+ Task {
40+ defaultBranch = try await gitConfig. get ( key: " init.defaultBranch " , global: true ) ?? " "
41+ Task {
42+ hasAppeared = true
43+ }
44+ }
45+ }
3546 }
3647}
3748
@@ -116,9 +127,18 @@ private extension SourceControlGeneralView {
116127 }
117128
118129 private var defaultBranchName : some View {
119- TextField ( text: $text ) {
130+ TextField ( text: $defaultBranch ) {
120131 Text ( " Default branch name " )
121132 Text ( " Cannot contain spaces, backslashes, or other symbols " )
122133 }
134+ . onChange ( of: defaultBranch) { newValue in
135+ if hasAppeared {
136+ Limiter . debounce ( id: " defaultBranchDebouncer " , duration: 0.5 ) {
137+ Task {
138+ await gitConfig. set ( key: " init.defaultBranch " , value: newValue, global: true )
139+ }
140+ }
141+ }
142+ }
123143 }
124144}
Original file line number Diff line number Diff line change @@ -13,10 +13,11 @@ struct SourceControlPullView: View {
1313
1414 @EnvironmentObject var sourceControlManager : SourceControlManager
1515
16+ let gitConfig = GitConfigClient ( shellClient: currentWorld. shellClient)
17+
1618 @State var loading : Bool = false
1719
18- @AppSettings ( \. sourceControl. git. preferRebaseWhenPulling)
19- var preferRebaseWhenPulling
20+ @State var preferRebaseWhenPulling : Bool = false
2021
2122 var body : some View {
2223 VStack ( spacing: 0 ) {
@@ -39,8 +40,11 @@ struct SourceControlPullView: View {
3940 . scrollDisabled ( true )
4041 . scrollContentBackground ( . hidden)
4142 . onAppear {
42- if preferRebaseWhenPulling {
43- sourceControlManager. operationRebase = true
43+ Task {
44+ preferRebaseWhenPulling = try await gitConfig. get ( key: " pull.rebase " , global: true ) ?? false
45+ if preferRebaseWhenPulling {
46+ sourceControlManager. operationRebase = true
47+ }
4448 }
4549 }
4650 HStack {
You can’t perform that action at this time.
0 commit comments