Skip to content

Commit 172603d

Browse files
authored
Merge branch 'master' into drop-swift-5.7
2 parents 8260ca0 + d99c795 commit 172603d

File tree

5 files changed

+30
-20
lines changed

5 files changed

+30
-20
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
- Drop Swift 5.7 [@417-72KI][] - [#620](https://github.com/danger/swift/pull/620)
1717
- Fix pattern for detecting SwiftLint in package [@417-72KI][] - [#616](https://github.com/danger/swift/pull/616)
18+
- Allow optional GitLab MR description [@kvvzr][] - [#609](https://github.com/danger/swift/pull/609)
1819

1920
## 3.18.1
2021

Sources/Danger/GitLabDSL.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ public extension GitLab {
216216
public let changesCount: String
217217
public let closedAt: Date?
218218
public let closedBy: User?
219-
public let description: String
219+
public let description: String?
220220
public let diffRefs: DiffRefs
221221
public let downvotes: Int
222222
public let firstDeployedToProductionAt: Date?
@@ -273,6 +273,7 @@ public extension GitLab {
273273
case active
274274
case blocked
275275
case deactivated
276+
case ldapBlocked = "ldap_blocked"
276277
}
277278

278279
public let avatarUrl: String?

Sources/DangerDependenciesResolver/InlineDependenciesFinder.swift

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
import Foundation
2+
import Version
23

34
struct InlineDependenciesFinder {
45
let fileReader: FileReading
56
let config: ScriptManager.Config
67

78
init(fileReader: FileReading = FileReader(),
8-
config: ScriptManager.Config) {
9+
config: ScriptManager.Config)
10+
{
911
self.fileReader = fileReader
1012
self.config = config
1113
}
1214

1315
func resolveInlineDependencies(fromPath path: String,
14-
dangerSwiftVersion: String) throws -> [InlineDependency] {
16+
dangerSwiftVersion: Version) throws -> [InlineDependency]
17+
{
1518
let lines = try fileReader.readText(atPath: path).components(separatedBy: .newlines)
1619

1720
var result: [InlineDependency] = [.dangerSwift(version: dangerSwiftVersion)]
@@ -45,7 +48,8 @@ struct InlineDependenciesFinder {
4548

4649
result.append(InlineDependency(url: url, major: majorVersion))
4750
} else if let firstCharacter = line.unicodeScalars.first,
48-
!CharacterSet.alphanumerics.contains(firstCharacter) {
51+
!CharacterSet.alphanumerics.contains(firstCharacter)
52+
{
4953
break
5054
}
5155
}
@@ -70,15 +74,11 @@ extension InlineDependenciesFinder {
7074
}
7175

7276
extension InlineDependenciesFinder.InlineDependency {
73-
static func dangerSwift(version: String) -> Self {
74-
let components = version.split(separator: ".")
75-
.compactMap { Int($0) }
76-
precondition(components.count == 3)
77-
78-
return .init(url: dangerSwiftRepoURL,
79-
major: components[0],
80-
minor: components[1],
81-
patch: components[2])
77+
static func dangerSwift(version: Version) -> Self {
78+
.init(url: dangerSwiftRepoURL,
79+
major: version.major,
80+
minor: version.minor,
81+
patch: version.patch)
8282
}
8383
}
8484

Sources/DangerDependenciesResolver/Script.swift

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import DangerShellExecutor
22
import Foundation
33
import Logger
4+
import Version
45

56
public struct ScriptManager {
67
public struct Config {
@@ -10,7 +11,8 @@ public struct ScriptManager {
1011

1112
public init(prefix: String = "package: ",
1213
file: String = "Dangerplugins",
13-
major: String = "~> ") {
14+
major: String = "~> ")
15+
{
1416
dependencyPrefix = prefix
1517
dependencyFile = file
1618
majorVersionPrefix = major
@@ -22,6 +24,7 @@ public struct ScriptManager {
2224
case invalidInlineDependencyURL(String)
2325
case failedToAddDependencyScript(String)
2426
case scriptNotFound(String)
27+
case invalidDangerSwiftVersion
2528
}
2629

2730
private let config = Config()
@@ -36,7 +39,8 @@ public struct ScriptManager {
3639
public init(folder: String,
3740
dangerSwiftVersion: String,
3841
packageManager: PackageManager,
39-
logger: Logger) throws {
42+
logger: Logger) throws
43+
{
4044
self.dangerSwiftVersion = dangerSwiftVersion
4145
self.folder = folder
4246
self.logger = logger
@@ -56,6 +60,10 @@ public struct ScriptManager {
5660
}
5761

5862
private func script(fromPath path: String) throws -> Script {
63+
guard let dangerSwiftVersion = Version(dangerSwiftVersion) else {
64+
throw Errors.invalidDangerSwiftVersion
65+
}
66+
5967
let identifier = scriptIdentifier(fromPath: path)
6068
let folder = try createFolderIfNeededForScript(withIdentifier: identifier, filePath: path)
6169
let script = Script(name: path.nameExcludingExtension, folder: folder, logger: logger)
@@ -95,9 +103,9 @@ public struct ScriptManager {
95103

96104
let moduleFolder = try sourcesFolder.createSubfolder(withName: filePath.nameExcludingExtension)
97105

98-
FileManager.default.createFile(atPath: moduleFolder.appendingPath("main.swift"),
99-
contents: Data(try String(contentsOfFile: filePath).utf8),
100-
attributes: [:])
106+
try FileManager.default.createFile(atPath: moduleFolder.appendingPath("main.swift"),
107+
contents: Data(String(contentsOfFile: filePath).utf8),
108+
attributes: [:])
101109

102110
return scriptFolder
103111
}
@@ -215,7 +223,8 @@ public final class Script {
215223
func executeSwiftCommand(_ command: String,
216224
onFolder folder: String? = nil,
217225
arguments: [String] = [],
218-
executor: ShellExecutor) throws -> String {
226+
executor: ShellExecutor) throws -> String
227+
{
219228
func resolveSwiftPath() -> String {
220229
#if os(Linux)
221230
return "swift"

Sources/Runner/Commands/Edit.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ func editDanger(version dangerSwiftVersion: String, logger: Logger) throws {
3232
separator: "\n")
3333
exit(1)
3434
}
35-
3635
absoluteLibPath = libPath.fullPath
3736
libsImport = ["-l Danger"]
3837
}

0 commit comments

Comments
 (0)