Skip to content

Commit 791ddd6

Browse files
committed
Update uploadAssets.yml
Fix formatting.
1 parent e7c03e8 commit 791ddd6

File tree

7 files changed

+111
-89
lines changed

7 files changed

+111
-89
lines changed

.github/workflows/uploadAssets.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ jobs:
8484
apt install -yq swiftlang
8585
swift build -c release --enable-test-discovery --static-swift-stdlib -Xswiftc -static-executable
8686
cp .build/release/LFSPointers .
87+
./LFSPointers --generate-completion-script zsh > _LFSPointers
88+
./LFSPointers --generate-completion-script bash > LFSPointers.bash
8789
mkdir LFSPointers-$TAG-linux-arm64
8890
cp .build/release/LFSPointers LFSPointers-$TAG-linux-arm64
8991
tar -czf LFSPointers-${{ github.event.release.tag_name }}-linux-arm64.tar.gz LFSPointers-$TAG-linux-arm64
@@ -161,6 +163,8 @@ jobs:
161163
run: |
162164
swift build -c release --enable-test-discovery --static-swift-stdlib -Xswiftc -static-executable
163165
cp .build/release/LFSPointers .
166+
./LFSPointers --generate-completion-script zsh > _LFSPointers
167+
./LFSPointers --generate-completion-script bash > LFSPointers.bash
164168
mkdir LFSPointers-$TAG-linux-amd64
165169
cp .build/release/LFSPointers LFSPointers-$TAG-linux-amd64
166170
tar -czf LFSPointers-$TAG-linux-amd64.tar.gz LFSPointers-$TAG-linux-amd64

.swiftformat

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111
"lineBreakBeforeControlFlowKeywords" : false,
1212
"lineBreakBeforeEachArgument" : false,
1313
"lineBreakBeforeEachGenericRequirement" : false,
14-
"lineLength" : 100,
14+
"lineLength" : 120,
1515
"maximumBlankLines" : 2,
1616
"prioritizeKeepingFunctionOutputTogether" : false,
1717
"respectsExistingLineBreaks" : true,
1818
"rules" : {
19-
"AllPublicDeclarationsHaveDocumentation" : truee,
19+
"AllPublicDeclarationsHaveDocumentation" : true,
2020
"AlwaysUseLowerCamelCase" : true,
2121
"AmbiguousTrailingClosureOverload" : true,
2222
"BeginDocumentationCommentWithOneLineSummary" : true,
@@ -30,7 +30,7 @@
3030
"NeverUseForceTry" : false,
3131
"NeverUseImplicitlyUnwrappedOptionals" : false,
3232
"NoAccessLevelOnExtensionDeclaration" : true,
33-
"NoBlockComments" : true,
33+
"NoBlockComments" : false,
3434
"NoCasesWithOnlyFallthrough" : true,
3535
"NoEmptyTrailingClosureParentheses" : true,
3636
"NoLabelsInCasePatterns" : true,

Sources/LFSPointersExecutable/main.swift

Lines changed: 42 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
1-
import Foundation
1+
//
2+
// main.swift
3+
//
4+
//
5+
// Created by Jeff Lebrun on 0/00/20.
6+
//
7+
28
import ArgumentParser
3-
import Rainbow
49
import Files
10+
import Foundation
511
import LFSPointersKit
12+
import Rainbow
613

714
let jsonStructure = """
815
[
@@ -34,16 +41,16 @@ struct LFSPointersCommand: ParsableCommand {
3441
discussion: "JSON STRUCTURE:\n\(jsonStructure)",
3542
version: "3.0.0"
3643
)
37-
44+
3845
@Flag(name: .shortAndLong, help: "Whether to display verbose output.")
3946
var verbose: Bool = false
40-
47+
4148
@Flag(name: .customLong("silent"), help: "Don't print to standard output or standard error.")
4249
var s: Bool = false
43-
50+
4451
@Flag(name: .shortAndLong, help: "Repeat this process in all directories.")
4552
var recursive: Bool = false
46-
53+
4754
@Flag(name: .shortAndLong, help: "Convert all files to pointers (USE WITH CAUTION!).")
4855
var all: Bool = false
4956

@@ -69,20 +76,20 @@ struct LFSPointersCommand: ParsableCommand {
6976
transform: URL.init(fileURLWithPath:)
7077
)
7178
var backupDirectory: URL? = nil
72-
79+
7380
@Argument(
7481
help: "The directory which contains the files you want to convert to LFS pointers.",
7582
completion: .directory,
7683
transform: URL.init(fileURLWithPath:)
7784
)
7885
var directory: URL
79-
86+
8087
@Argument(
8188
help: "A list of paths to files, relative to the current directory, that represent files to be converted. You can use your shell's regular expression support to pass in a list of files.",
8289
completion: .file()
8390
)
8491
var files: [String] = []
85-
92+
8693
mutating func validate() throws {
8794
// Verify the directory actually exists.
8895
guard FileManager().fileExists(atPath: directory.path) else {
@@ -97,22 +104,22 @@ struct LFSPointersCommand: ParsableCommand {
97104
}
98105
}
99106
}
100-
107+
101108
func run() throws {
102109
var silent = false
103-
110+
104111
if s {
105112
silent = true
106113
}
107-
114+
108115
if json {
109116
silent = true
110117
}
111-
118+
112119
if !color {
113120
Rainbow.enabled = false
114121
}
115-
122+
116123
let printClosure: (URL, Status) -> Void = { url, status in
117124
switch status {
118125
case let .appending(pointer):
@@ -122,17 +129,17 @@ struct LFSPointersCommand: ParsableCommand {
122129
} else if !silent {
123130
print("Appending pointer to file \"\(file.name)\"...")
124131
}
125-
132+
126133
case let .error(error):
127134
let file = try! File(path: url.path)
128-
135+
129136
if self.verbose && !silent {
130137
if self.color {
131138
fputs("Could not convert \"\(file.name)\" to a pointer.\n Git LFS error: \(error)\n".red, stderr)
132139
} else {
133140
fputs("Could not convert \"\(file.name)\" to a pointer.\n Git LFS error: \(error)\n", stderr)
134141
}
135-
142+
136143
} else if !silent {
137144
if self.color {
138145
fputs("Could not convert \"\(file.name)\" to a pointer.".red, stderr)
@@ -141,22 +148,22 @@ struct LFSPointersCommand: ParsableCommand {
141148
}
142149
}
143150
break
144-
151+
145152
case .generating:
146153
let file = try! File(path: url.path)
147-
154+
148155
if !silent && self.verbose {
149156
print("Converting \"\(file.name)\" to pointer...\n")
150157
} else if !silent {
151158
print("Converting \"\(file.name)\" to pointer...\n")
152159
}
153160
case let .regexDoesntMatch(regex):
154161
let file = try! File(path: url.path)
155-
162+
156163
if !silent && self.verbose {
157164
print("File name \"\(file.name)\" does not match regular expression \"\(regex.pattern)\", continuing...")
158165
}
159-
166+
160167
case let .writing(pointer):
161168
let file = try! File(path: url.path)
162169
if self.verbose && !silent {
@@ -166,7 +173,7 @@ struct LFSPointersCommand: ParsableCommand {
166173
}
167174
}
168175
}
169-
176+
170177
do {
171178

172179
if all {
@@ -180,13 +187,13 @@ struct LFSPointersCommand: ParsableCommand {
180187
Foundation.exit(0)
181188
}
182189
}
183-
190+
184191
if let bd = backupDirectory {
185192
do {
186193
if !silent {
187194
print("Copying files to backup directory...")
188195
}
189-
196+
190197
// Copy the specified directory into the backup directory.
191198
try Folder(path: directory.path).copy(to: Folder(path: bd.path))
192199
} catch {
@@ -204,22 +211,22 @@ struct LFSPointersCommand: ParsableCommand {
204211
)
205212
}
206213
}
207-
214+
208215
Foundation.exit(4)
209216
}
210217
}
211-
218+
212219
if all {
213220
let pointers = try LFSPointer.pointers(
214221
forDirectory: directory,
215222
searchType: .all,
216223
recursive: recursive,
217224
statusClosure: printClosure
218225
)
219-
226+
220227
if !json {
221228
pointers.forEach({ p in
222-
229+
223230
do {
224231
try p.write(
225232
toFile: URL(fileURLWithPath: p.filePath),
@@ -240,7 +247,7 @@ struct LFSPointersCommand: ParsableCommand {
240247
fputs("Unable to overwrite file \"\(p.filename)\". Error: \(error)", stderr)
241248
}
242249
}
243-
250+
244251
})
245252
} else {
246253
do {
@@ -261,10 +268,10 @@ struct LFSPointersCommand: ParsableCommand {
261268
recursive: recursive,
262269
statusClosure: printClosure
263270
)
264-
271+
265272
if !json {
266273
pointers.forEach({ p in
267-
274+
268275
do {
269276
try p.write(
270277
toFile: URL(fileURLWithPath: p.filePath),
@@ -286,7 +293,7 @@ struct LFSPointersCommand: ParsableCommand {
286293
fputs("Unable to overwrite file \"\(p.filename)\". Error: \(error)", stderr)
287294
}
288295
}
289-
296+
290297
})
291298
} else {
292299
do {
@@ -299,7 +306,7 @@ struct LFSPointersCommand: ParsableCommand {
299306
}
300307

301308
}
302-
309+
303310
} catch let error {
304311
if !silent {
305312

@@ -310,10 +317,10 @@ struct LFSPointersCommand: ParsableCommand {
310317
}
311318

312319
}
313-
320+
314321
Foundation.exit(2)
315322
}
316-
323+
317324
if !silent {
318325

319326
if self.color {

Sources/LFSPointersKit/Enums.swift

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//
22
// Enums.swift
3-
//
3+
//
44
//
55
// Created by Jeff Lebrun on 4/16/20.
66
//
@@ -9,18 +9,17 @@ import Foundation
99

1010
/// The search types to use when filtering files.
1111
public enum SearchTypes {
12-
12+
1313
/// Searches for all files that match any of the filenames in the array.
1414
case fileNames([URL])
15-
15+
1616
/// Searches for all files whose name matches the regular expression.
1717
case regex(NSRegularExpression)
18-
18+
1919
/// Searches for all files.
2020
case all
2121
}
2222

23-
2423
public enum Status {
2524
case writing(LFSPointer),
2625
appending(LFSPointer),

Sources/LFSPointersKit/Extensions.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//
22
// Extensions.swift
3-
//
3+
//
44
//
55
// Created by Jeff Lebrun on 4/14/20.
66
//
@@ -9,6 +9,7 @@ import Foundation
99

1010
public extension NSRegularExpression {
1111
/// Checks if this regular expression matches the supplied `String`.
12+
///
1213
/// - Returns: `true` if the `String` matches, otherwise, `false`.
1314
func matches(_ string: String) -> Bool {
1415
firstMatch(in: string, options: [], range: NSRange(location: 0, length: string.utf16.count)) != nil

0 commit comments

Comments
 (0)