Skip to content

Commit b200777

Browse files
committed
format fixes
1 parent d8d170f commit b200777

File tree

8 files changed

+96
-77
lines changed

8 files changed

+96
-77
lines changed

CodeApp/Containers/MainScene.swift

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -268,16 +268,20 @@ private struct MainView: View {
268268

269269
changeLogLastReadVersion = appVersion
270270
}
271-
272-
.alert(alertManager.title, isPresented: $alertManager.isShowingAlert, actions: {
273-
alertManager.alertContent
274-
}, message: {
275-
if let message = alertManager.message {
276-
Text(message)
277-
}else {
278-
EmptyView()
271+
272+
.alert(
273+
alertManager.title, isPresented: $alertManager.isShowingAlert,
274+
actions: {
275+
alertManager.alertContent
276+
},
277+
message: {
278+
if let message = alertManager.message {
279+
Text(message)
280+
} else {
281+
EmptyView()
282+
}
279283
}
280-
})
284+
)
281285
.fullScreenCover(isPresented: $safariManager.showsSafari) {
282286
if let url = safariManager.urlToVisit {
283287
SafariView(url: url)

CodeApp/Containers/SourceControlContainer.swift

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ struct SourceControlContainer: View {
2626
App.notificationManager.showInformationMessage(
2727
"source_control.repository_initialized")
2828
App.git_status()
29-
}catch {
29+
} catch {
3030
App.notificationManager.showErrorMessage(
3131
error.localizedDescription
3232
)
@@ -70,10 +70,11 @@ struct SourceControlContainer: View {
7070

7171
App.notificationManager.postProgressNotification(
7272
title: "source_control.pushing_to_remote", progress: progress)
73-
73+
7474
do {
7575
let currentBranch = try await serviceProvider.currentBranch()
76-
try await serviceProvider.push(branch: currentBranch, remote: remote, progress: progress)
76+
try await serviceProvider.push(
77+
branch: currentBranch, remote: remote, progress: progress)
7778
App.notificationManager.showInformationMessage(
7879
"source_control.push_succeeded")
7980
App.git_status()
@@ -84,7 +85,8 @@ struct SourceControlContainer: View {
8485
title:
8586
"errors.source_control.authentication_failed",
8687
level: .error,
87-
primary: { showsPrompt = true }, primaryTitle: "common.configure", source: "source_control.title")
88+
primary: { showsPrompt = true }, primaryTitle: "common.configure",
89+
source: "source_control.title")
8890
} else {
8991
App.notificationManager.showErrorMessage(
9092
error.localizedDescription)
@@ -173,7 +175,7 @@ struct SourceControlContainer: View {
173175
primary: {
174176
App.loadFolder(url: dirURL)
175177
}, primaryTitle: "common.open_folder", source: repo)
176-
}catch {
178+
} catch {
177179
let error = error as NSError
178180
if error.code == LibGit2ErrorClass._GIT_ERROR_HTTP {
179181
App.notificationManager.postActionNotification(
@@ -205,7 +207,7 @@ struct SourceControlContainer: View {
205207
throw error
206208
}
207209
}
208-
210+
209211
}
210212

211213
func onRevert(urlString: String, confirm: Bool = false) async throws {
@@ -246,13 +248,13 @@ struct SourceControlContainer: View {
246248
}
247249
return
248250
}
249-
251+
250252
do {
251253
let previousContent = try await serviceProvider.previous(path: fileURL.absoluteString)
252254
try previousContent.write(to: fileURL, atomically: true, encoding: .utf8)
253255
App.git_status()
254256
App.notificationManager.showInformationMessage("source_control.revert_succeeded")
255-
}catch {
257+
} catch {
256258
App.notificationManager.showErrorMessage(error.localizedDescription)
257259
throw error
258260
}

CodeApp/Managers/BottomBar.swift

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
// Created by Ken Chung on 1/7/2021.
66
//
77

8-
import SwiftUI
98
import SwiftGit2
9+
import SwiftUI
1010

1111
struct BottomBar: View {
1212

@@ -30,21 +30,21 @@ struct BottomBar: View {
3030
do {
3131
try await gitServiceProvider.checkout(oid: destination.reference.oid)
3232
App.notificationManager.showInformationMessage("Checkout succeeded")
33-
}catch {
33+
} catch {
3434
App.notificationManager.showErrorMessage(error.localizedDescription)
3535
throw error
3636
}
3737
}
38-
38+
3939
func iconNameForReferenceType(_ reference: ReferenceType) -> String {
4040
if reference is TagReference {
4141
return "tag"
42-
}else if let reference = reference as? Branch {
42+
} else if let reference = reference as? Branch {
4343
return (reference.isRemote ? "cloud" : "arrow.triangle.branch")
4444
}
4545
return "circle"
4646
}
47-
47+
4848
var body: some View {
4949
ZStack(alignment: .center) {
5050
Color.init(id: "statusBar.background").frame(maxHeight: 20)
@@ -69,13 +69,14 @@ struct BottomBar: View {
6969
},
7070
onSelect: { destination in
7171
if !App.gitTracks.isEmpty {
72-
72+
7373
App.alertManager.showAlert(
7474
title: "Git checkout: Uncommitted Changes",
75-
message: "Uncommited changes will be lost. Do you wish to proceed?",
76-
content: AnyView (
75+
message:
76+
"Uncommited changes will be lost. Do you wish to proceed?",
77+
content: AnyView(
7778
Group {
78-
Button("Checkout", role: .destructive){
79+
Button("Checkout", role: .destructive) {
7980
Task {
8081
try await checkout(destination: destination)
8182
}
@@ -89,7 +90,9 @@ struct BottomBar: View {
8990
try await checkout(destination: destination)
9091
}
9192
}
92-
}, title: App.branch, iconName: "arrow.triangle.branch", menuTitle: "source_control.checkout.select_branch_or_tag")
93+
}, title: App.branch, iconName: "arrow.triangle.branch",
94+
menuTitle: "source_control.checkout.select_branch_or_tag"
95+
)
9396
.fixedSize(horizontal: true, vertical: false)
9497
.frame(height: 20)
9598

CodeApp/Managers/FileSystem/Local/LocalGitServiceProvider.swift

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -179,15 +179,17 @@ class LocalGitServiceProvider: GitServiceProvider {
179179
let repository = try self.checkedRepository()
180180
let ref = try repository.HEAD().get()
181181
guard let branch = ref as? Branch,
182-
let branchName = branch.shortName
182+
let branchName = branch.shortName
183183
else {
184184
throw NSError(descriptionKey: "Git is in detached mode")
185185
}
186-
let remoteBranch = try repository.remoteBranch(named: "\(remote?.name ?? "origin")/\(branchName)").get()
186+
let remoteBranch = try repository.remoteBranch(
187+
named: "\(remote?.name ?? "origin")/\(branchName)"
188+
).get()
187189
return try repository.aheadBehind(local: ref.oid, upstream: remoteBranch.oid).get()
188190
}
189191
}
190-
192+
191193
func status() async throws -> [StatusEntry] {
192194
return try await WorkerQueueTask {
193195
let repository = try self.checkedRepository()
@@ -196,7 +198,7 @@ class LocalGitServiceProvider: GitServiceProvider {
196198
]).get()
197199
}
198200
}
199-
201+
200202
func createRepository() async throws {
201203
try await WorkerQueueTask {
202204
guard !self.hasRepository else {
@@ -233,7 +235,7 @@ class LocalGitServiceProvider: GitServiceProvider {
233235
fetchProgress: fetchProgressBlock
234236
).get()
235237
} else {
236-
_ = try Repository.clone(
238+
_ = try Repository.clone(
237239
from: from,
238240
to: to,
239241
checkoutProgress: checkoutProgressBlock,
@@ -264,7 +266,7 @@ class LocalGitServiceProvider: GitServiceProvider {
264266
self.contentCache.removeAllObjects()
265267
}
266268
}
267-
269+
268270
func unstage(paths: [String]) async throws {
269271
try await WorkerQueueTask {
270272
let repository = try self.checkedRepository()
@@ -298,21 +300,21 @@ class LocalGitServiceProvider: GitServiceProvider {
298300
}
299301
}
300302
}
301-
303+
302304
func remotes() async throws -> [Remote] {
303305
return try await WorkerQueueTask {
304306
let repository = try self.checkedRepository()
305307
return try repository.allRemotes().get()
306308
}
307309
}
308-
310+
309311
func currentBranch() async throws -> Branch {
310312
try await WorkerQueueTask {
311313
let repository = try self.checkedRepository()
312314
let head = try repository.HEAD().get()
313315
if let branch = head as? Branch {
314316
return branch
315-
}else {
317+
} else {
316318
throw NSError(descriptionKey: "Repository is in detached mode")
317319
}
318320
}
@@ -322,7 +324,9 @@ class LocalGitServiceProvider: GitServiceProvider {
322324
try await WorkerQueueTask {
323325
let repository = try self.checkedRepository()
324326
let credentials = try self.checkedCredentials()
325-
try repository.push(credentials: credentials, branch: branch.longName, remoteName: to.name){ current, total in
327+
try repository.push(
328+
credentials: credentials, branch: branch.longName, remoteName: to.name
329+
) { current, total in
326330
DispatchQueue.main.async {
327331
progress?.totalUnitCount = Int64(current)
328332
progress?.completedUnitCount = Int64(total)
@@ -338,46 +342,47 @@ class LocalGitServiceProvider: GitServiceProvider {
338342
self.contentCache.removeAllObjects()
339343
}
340344
}
341-
345+
342346
func localBranches() async throws -> [Branch] {
343-
return try await WorkerQueueTask{
347+
return try await WorkerQueueTask {
344348
let repository = try self.checkedRepository()
345349
return try repository.localBranches().get()
346350
}
347351
}
348352

349353
func remoteBranches() async throws -> [Branch] {
350-
return try await WorkerQueueTask{
354+
return try await WorkerQueueTask {
351355
let repository = try self.checkedRepository()
352356
return try repository.remoteBranches().get()
353357
}
354358
}
355359

356360
func tags() async throws -> [TagReference] {
357-
return try await WorkerQueueTask{
361+
return try await WorkerQueueTask {
358362
let repository = try self.checkedRepository()
359363
return try repository.allTags().get()
360364
}
361365
}
362-
366+
363367
/// Returns the OID of the path at the current HEAD
364368
private func fileOidAtPathForLastCommit(path: String) throws -> OID {
365369
let repository = try self.checkedRepository()
366370
let entries = try repository.status(options: [.includeUnmodified]).get()
367371
for entry in entries {
368372
if let oldFilePath = entry.headToIndex?.oldFile?.path,
369-
path == oldFilePath,
370-
let oid = entry.headToIndex?.oldFile?.oid {
373+
path == oldFilePath,
374+
let oid = entry.headToIndex?.oldFile?.oid
375+
{
371376
return oid
372377
}
373378
}
374379
throw NSError(descriptionKey: "Unable to locate OID for \(path)")
375380
}
376-
381+
377382
func previous(path: String) async throws -> String {
378383
return try await WorkerQueueTask {
379384
let repository = try self.checkedRepository()
380-
385+
381386
if let cached = self.contentCache.object(forKey: path as NSString) {
382387
return (cached as String)
383388
}
@@ -386,7 +391,7 @@ class LocalGitServiceProvider: GitServiceProvider {
386391

387392
let oid = try self.fileOidAtPathForLastCommit(path: path)
388393
let blob = try repository.blob(oid).get()
389-
394+
390395
guard let content = String(data: blob.data, encoding: .utf8) else {
391396
throw NSError(descriptionKey: "Unable to decode data")
392397
}

0 commit comments

Comments
 (0)