Skip to content

Commit 6224857

Browse files
authored
Merge pull request #6 from 0xWDG/swiftlint-fixes
2 parents 00838c7 + 88bccdb commit 6224857

40 files changed

+739
-327
lines changed

.swiftlint.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ identifier_name:
1717
excluded:
1818
- id
1919
- vc
20+
- to
2021
# (short) File extensions:
2122
- c
2223
- m
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Scheme
3+
LastUpgradeVersion = "1500"
4+
version = "1.7">
5+
<BuildAction
6+
parallelizeBuildables = "YES"
7+
buildImplicitDependencies = "YES">
8+
<BuildActionEntries>
9+
<BuildActionEntry
10+
buildForTesting = "YES"
11+
buildForRunning = "YES"
12+
buildForProfiling = "YES"
13+
buildForArchiving = "YES"
14+
buildForAnalyzing = "YES">
15+
<BuildableReference
16+
BuildableIdentifier = "primary"
17+
BlueprintIdentifier = "Version-Control"
18+
BuildableName = "Version-Control"
19+
BlueprintName = "Version-Control"
20+
ReferencedContainer = "container:">
21+
</BuildableReference>
22+
</BuildActionEntry>
23+
</BuildActionEntries>
24+
</BuildAction>
25+
<TestAction
26+
buildConfiguration = "Debug"
27+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
28+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29+
shouldUseLaunchSchemeArgsEnv = "YES"
30+
shouldAutocreateTestPlan = "YES">
31+
</TestAction>
32+
<LaunchAction
33+
buildConfiguration = "Debug"
34+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
35+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
36+
launchStyle = "0"
37+
useCustomWorkingDirectory = "NO"
38+
ignoresPersistentStateOnLaunch = "NO"
39+
debugDocumentVersioning = "YES"
40+
debugServiceExtension = "internal"
41+
allowLocationSimulation = "YES">
42+
</LaunchAction>
43+
<ProfileAction
44+
buildConfiguration = "Release"
45+
shouldUseLaunchSchemeArgsEnv = "YES"
46+
savedToolIdentifier = ""
47+
useCustomWorkingDirectory = "NO"
48+
debugDocumentVersioning = "YES">
49+
<MacroExpansion>
50+
<BuildableReference
51+
BuildableIdentifier = "primary"
52+
BlueprintIdentifier = "Version-Control"
53+
BuildableName = "Version-Control"
54+
BlueprintName = "Version-Control"
55+
ReferencedContainer = "container:">
56+
</BuildableReference>
57+
</MacroExpansion>
58+
</ProfileAction>
59+
<AnalyzeAction
60+
buildConfiguration = "Debug">
61+
</AnalyzeAction>
62+
<ArchiveAction
63+
buildConfiguration = "Release"
64+
revealArchiveInOrganizer = "YES">
65+
</ArchiveAction>
66+
</Scheme>

Sources/Version-Control/Services/Models/Client/Add.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public struct Add {
1818
*/
1919
func addConflictedFile(directoryURL: URL,
2020
file: GitFileItem) async throws {
21-
21+
2222
try ShellClient().run("cd \(directoryURL.relativePath.escapedWhiteSpaces()); git add -- \(file.url)")
2323
}
2424
}

Sources/Version-Control/Services/Models/Client/Apply.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import Foundation
1111

1212
public struct Apply {
13-
13+
1414
/// Applies a Git patch to the Git index for a specified file in a specified directory.
1515
///
1616
/// - Parameters:
@@ -21,7 +21,9 @@ public struct Apply {
2121
/// - An error of type `Error` if any issues occur during the patch application process.
2222
///
2323
/// - Note:
24-
/// If the file was renamed (`file.gitStatus == .renamed`), this function recreates the rename operation by staging the removal of the old file and adding the old file's blob to the index under the new name.
24+
/// If the file was renamed (`file.gitStatus == .renamed`), \
25+
/// this function recreates the rename operation by staging the removal of the old file \
26+
/// and adding the old file's blob to the index under the new name.
2527
///
2628
/// - Example:
2729
/// ```swift

Sources/Version-Control/Services/Models/Client/Branch.swift

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
import Foundation
1111

1212
public struct Branch {
13-
13+
1414
public init() {}
15-
15+
1616
/// Retrieves the name of the current Git branch in a specified directory.
1717
///
1818
/// - Parameters:
@@ -47,7 +47,8 @@ public struct Branch {
4747
/// Retrieves a list of Git branches in a specified directory.
4848
///
4949
/// - Parameters:
50-
/// - allBranches: A Boolean flag indicating whether to list all branches, including remote branches (default is `false`).
50+
/// - allBranches: A Boolean flag indicating whether to list all branches, \
51+
/// including remote branches (default is `false`).
5152
/// - directoryURL: The URL of the directory containing the Git repository.
5253
///
5354
/// - Throws:
@@ -168,7 +169,8 @@ public struct Branch {
168169
/// - An error of type `Error` if any issues occur during the branch renaming process.
169170
///
170171
/// - Note:
171-
/// If the branch renaming is successful, the old branch name will no longer exist, and a new branch with the specified `newName` will be created.
172+
/// If the branch renaming is successful, the old branch name will no longer exist, \
173+
/// and a new branch with the specified `newName` will be created.
172174
///
173175
/// - Example:
174176
/// ```swift
@@ -203,7 +205,8 @@ public struct Branch {
203205
/// - An error of type `Error` if any issues occur during the branch deletion process.
204206
///
205207
/// - Returns:
206-
/// A `Bool` value indicating whether the branch was successfully deleted. Returns `true` if the branch was deleted successfully; otherwise, returns `false`.
208+
/// A `Bool` value indicating whether the branch was successfully deleted. \
209+
/// Returns `true` if the branch was deleted successfully; otherwise, returns `false`.
207210
///
208211
/// - Example:
209212
/// ```swift
@@ -229,12 +232,11 @@ public struct Branch {
229232
/// Prepare and execute the Git command to delete the local branch using a ShellClient.
230233
try ShellClient().run(
231234
"cd \(directoryURL.relativePath.escapedWhiteSpaces());git branch -D \(branchName)")
232-
235+
233236
// Return true to indicate that the branch deletion was attempted.
234237
return true
235238
}
236239

237-
238240
/// Deletes a remote Git branch in a specified directory.
239241
///
240242
/// - Parameters:
@@ -246,7 +248,9 @@ public struct Branch {
246248
/// - An error of type `Error` if any issues occur during the remote branch deletion process.
247249
///
248250
/// - Note:
249-
/// This function attempts to delete the remote branch on the specified remote repository. If the deletion fails due to the remote branch already being deleted or for any other reason, it may try to remove the corresponding local reference.
251+
/// This function attempts to delete the remote branch on the specified remote repository. \
252+
/// If the deletion fails due to the remote branch already being deleted or for any other reason, \
253+
/// it may try to remove the corresponding local reference.
250254
///
251255
/// - Example:
252256
/// ```swift
@@ -255,7 +259,11 @@ public struct Branch {
255259
/// let remoteBranchName = "feature/old-feature"
256260
///
257261
/// do {
258-
/// try deleteRemoteBranch(directoryURL: directoryURL, remoteName: remoteName, remoteBranchName: remoteBranchName)
262+
/// try deleteRemoteBranch(
263+
/// directoryURL: directoryURL,
264+
/// remoteName: remoteName,
265+
/// remoteBranchName: remoteBranchName
266+
/// )
259267
/// print("Remote branch '\(remoteBranchName)' was successfully deleted on '\(remoteName)'.")
260268
/// } catch {
261269
/// print("Error deleting remote branch: \(error.localizedDescription)")
@@ -330,17 +338,17 @@ public struct Branch {
330338
"--points-at=\(commitsh)",
331339
"--format=%(refname:short)"
332340
]
333-
341+
334342
let result = try ShellClient.live().run(
335343
"cd \(directoryURL.relativePath.escapedWhiteSpaces());git \(args)")
336-
344+
337345
let resultSplit = result.split(separator: "\n").map { String($0) }
338346
let resultRange = Array(resultSplit.reversed())
339347
return resultRange.isEmpty ? nil : resultRange
340348
}
341349

342-
343-
/// Retrieves a dictionary of branch names and their corresponding commit SHAs that are merged into the specified branch.
350+
/// Retrieves a dictionary of branch names and their corresponding commit SHAs \
351+
/// that are merged into the specified branch.
344352
///
345353
/// - Parameters:
346354
/// - directoryURL: The URL of the directory containing the Git repository.
@@ -350,7 +358,8 @@ public struct Branch {
350358
/// - An error of type `Error` if any issues occur during the branch retrieval process.
351359
///
352360
/// - Returns:
353-
/// A dictionary containing branch names as keys and their corresponding commit SHAs as values, representing branches that are merged into the specified branch.
361+
/// A dictionary containing branch names as keys and their corresponding commit SHAs as values, \
362+
/// representing branches that are merged into the specified branch.
354363
///
355364
/// - Example:
356365
/// ```swift
@@ -377,19 +386,19 @@ public struct Branch {
377386
func getMergedBranches(directoryURL: URL,
378387
branchName: String) throws -> [String: String] {
379388
let canonicalBranchRef = Refs().formatAsLocalRef(name: branchName)
380-
389+
381390
let args = ["branch", "--format=%(refname):%(objectname)", "--merged", branchName]
382-
391+
383392
do {
384393
let result = try ShellClient().run("cd \(directoryURL.relativePath.escapedWhiteSpaces());git \(args)")
385-
394+
386395
var mergedBranches = [String: String]()
387396
for line in result.split(separator: "\n") {
388397
let components = line.split(separator: ":", maxSplits: 1)
389398
if components.count == 2 {
390399
let ref = String(components[0])
391400
let sha = String(components[1])
392-
401+
393402
// Don't include the branch we're using to compare against
394403
// in the list of branches merged into that branch.
395404
if ref != canonicalBranchRef {
@@ -402,4 +411,4 @@ public struct Branch {
402411
throw error
403412
}
404413
}
405-
}
414+
} // swiftlint:disable:this file_length

Sources/Version-Control/Services/Models/Client/Check.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,18 @@
99
import Foundation
1010

1111
public struct Check {
12-
12+
1313
public init() {}
14-
14+
1515
/// Checks if a given workspace directory is a Git repository or a Git worktree.
1616
///
1717
/// - Parameter workspaceURL: The URL of the workspace directory to be checked.
1818
///
1919
/// - Returns: `true` if the workspace is a Git repository or worktree, `false` otherwise.
2020
///
21-
/// - Note: This function checks the type of the workspace using `getRepositoryType`, and if it's marked as unsafe by Git, it falls back to a naive approximation by looking for the `.git` directory.
21+
/// - Note: This function checks the type of the workspace using `getRepositoryType`, \
22+
/// and if it's marked as unsafe by Git, \
23+
/// it falls back to a naive approximation by looking for the `.git` directory.
2224
///
2325
/// - Example:
2426
/// ```swift

Sources/Version-Control/Services/Models/Client/Checkout.swift

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
import Foundation
1111

1212
public struct Checkout {
13-
13+
1414
public init() {}
15-
15+
1616
/// Checks out a Git branch in a specified directory.
1717
///
1818
/// - Parameters:
@@ -93,7 +93,11 @@ public struct Checkout {
9393
/// let resolutionStrategy = ManualConflictResolution.ours // Replace with the desired resolution strategy
9494
///
9595
/// do {
96-
/// try checkoutConflictedFile(directoryURL: directoryURL, file: conflictedFile, resolution: resolutionStrategy)
96+
/// try checkoutConflictedFile(
97+
/// directoryURL: directoryURL,
98+
/// file: conflictedFile,
99+
/// resolution: resolutionStrategy
100+
/// )
97101
/// print("File '\(conflictedFile.url.relativePath)' checked out with \(resolutionStrategy) resolution.")
98102
/// } catch {
99103
/// print("Error checking out conflicted file: \(error.localizedDescription)")
@@ -111,7 +115,7 @@ public struct Checkout {
111115
"--",
112116
file.url.relativePath
113117
]
114-
118+
115119
try ShellClient().run("cd \(directoryURL.relativePath.escapedWhiteSpaces());git \(args)")
116120
}
117121
}

Sources/Version-Control/Services/Models/Client/Cherry-Pick.swift

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
import Foundation
1111

1212
public struct CherryPick {
13-
13+
1414
public init() {}
15-
15+
1616
/// The app-specific results from attempting to cherry pick commits
1717
enum CherryPickResult: String {
1818
/// Git completed the cherry pick without reporting any errors, and the caller can
@@ -133,10 +133,13 @@ public struct CherryPick {
133133
public func isCherryPickHeadFound(directoryURL: URL) -> Bool {
134134
do {
135135
let cherryPickHeadPath = try String(contentsOf: directoryURL) + ".git/CHERRY_PICK_HEAD"
136-
136+
137137
return FileManager.default.fileExists(atPath: cherryPickHeadPath)
138138
} catch {
139-
print("[cherryPick] A problem was encountered reading .git/CHERRY_PICK_HEAD, so it is unsafe to continue cherry-picking.")
139+
print(
140+
"[cherryPick] A problem was encountered reading .git/CHERRY_PICK_HEAD," +
141+
" so it is unsafe to continue cherry-picking."
142+
)
140143
return false
141144
}
142145
}

Sources/Version-Control/Services/Models/Client/Clone.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import Foundation
1111

1212
public struct Clone {
13-
13+
1414
public init() {}
1515

1616
/// Clones a repository from a given url into to the specified path.

Sources/Version-Control/Services/Models/Client/Commit.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import Foundation
1111

1212
public struct Commit {
13-
13+
1414
public init() {}
1515

1616
/// Creates a Git commit in a specified Git repository directory.

0 commit comments

Comments
 (0)