Skip to content

Commit b31e07d

Browse files
committed
Writing relative url to gitconfig upon adding first pattern
1 parent eab7301 commit b31e07d

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

CodeEdit/Features/Settings/Pages/SourceControlSettings/Models/IgnorePatternModel.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,12 @@ class IgnorePatternModel: ObservableObject {
182182

183183
private func writeAllPatterns() {
184184
let content = patterns.map(\.value).joined(separator: "\n")
185+
Task {
186+
let excludesfile: String? = try await gitConfig.get(key: "core.excludesfile")
187+
if excludesfile == "" {
188+
await gitConfig.set(key: "core.excludesfile", value: "~/\(fileURL.lastPathComponent)")
189+
}
190+
}
185191
try? content.write(to: fileURL, atomically: true, encoding: .utf8)
186192
}
187193

@@ -271,6 +277,6 @@ class IgnorePatternModel: ObservableObject {
271277
func setupGlobalIgnoreFile() async {
272278
guard !FileManager.default.fileExists(atPath: fileURL.path) else { return }
273279
FileManager.default.createFile(atPath: fileURL.path, contents: nil)
274-
await gitConfig.set(key: "core.excludesfile", value: fileURL.path, global: true)
280+
await gitConfig.set(key: "core.excludesfile", value: "~/\(fileURL.lastPathComponent)")
275281
}
276282
}

CodeEdit/Features/Settings/Pages/SourceControlSettings/SourceControlGitView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ private extension SourceControlGitView {
157157
// Fallback to `.gitignore_global` in the home directory
158158
fileURL = FileManager.default.homeDirectoryForCurrentUser.appendingPathComponent(".gitignore_global")
159159
// Set the default path in Git config if not set
160-
await gitConfig.set(key: "core.excludesfile", value: fileURL.path, global: true)
160+
await gitConfig.set(key: "core.excludesfile", value: "~/\(fileURL.lastPathComponent)")
161161
}
162162

163163
// Ensure the file exists

0 commit comments

Comments
 (0)