File tree Expand file tree Collapse file tree 3 files changed +30
-16
lines changed
utils/swift_snapshot_tool/Sources/swift_snapshot_tool Expand file tree Collapse file tree 3 files changed +30
-16
lines changed Original file line number Diff line number Diff line change @@ -128,7 +128,7 @@ func downloadToolchainAndRunTest(
128
128
let fileType = platform. fileType
129
129
let toolchainType = platform. toolchainType
130
130
131
- let realBranch = branch != . development ? " swift- \( branch ) -branch " : branch . rawValue
131
+ let realBranch = branch. urlBranchName
132
132
let toolchainDir = " \( workspace) / \( tag. name) - \( platform) "
133
133
let downloadPath = URL ( fileURLWithPath: " \( workspace) / \( tag. name) - \( platform) . \( fileType) " )
134
134
if !fileExists( toolchainDir) {
Original file line number Diff line number Diff line change @@ -27,18 +27,23 @@ struct Tag: Decodable {
27
27
ref. dropFirst ( 10 )
28
28
}
29
29
30
- func dateString( _ branch: Branch ) -> Substring {
31
- // FIXME: If we ever actually use interesting a-b builds, we should capture this information
32
- // would be better to do it sooner than later.
33
- return name. dropFirst ( " swift- " . count + branch. rawValue. count + " -SNAPSHOT- " . count) . dropLast ( 2 )
34
- }
35
-
36
30
func date( branch: Branch ) -> Date {
37
- // TODO: I think that d might be a class... if so, we really want to memoize
38
- // this.
39
31
let d = DateFormatter ( )
40
32
d. dateFormat = " yyyy-MM-dd "
41
- return d. date ( from: String ( dateString ( branch) ) ) !
33
+ // TODO: Change top use swift regexp
34
+ let pattern = " swift-.*DEVELOPMENT-SNAPSHOT-( \\ d+- \\ d+- \\ d+) "
35
+ do {
36
+ let regex = try NSRegularExpression ( pattern: pattern, options: . caseInsensitive)
37
+ guard let match = regex. firstMatch ( in: String ( name) ,
38
+ options: [ ] ,
39
+ range: NSRange ( location: 0 , length: name. utf16. count) ) else {
40
+ fatalError ( " Failed to find match! " )
41
+ }
42
+ let str = String ( ( name as NSString ) . substring ( with: match. range ( at: 1 ) ) )
43
+ return d. date ( from: str) !
44
+ } catch let error as NSError {
45
+ fatalError ( " Error creating NSRegularExpression: \( error) " )
46
+ }
42
47
}
43
48
}
44
49
Original file line number Diff line number Diff line change @@ -23,8 +23,8 @@ enum Platform: String, EnumerableFlag {
23
23
case . osx:
24
24
return " pkg "
25
25
case . ubuntu1404,
26
- . ubuntu1604,
27
- . ubuntu1804:
26
+ . ubuntu1604,
27
+ . ubuntu1804:
28
28
return " tar.gz "
29
29
}
30
30
}
@@ -34,8 +34,8 @@ enum Platform: String, EnumerableFlag {
34
34
case . osx:
35
35
return " xcode "
36
36
case . ubuntu1404,
37
- . ubuntu1604,
38
- . ubuntu1804:
37
+ . ubuntu1604,
38
+ . ubuntu1804:
39
39
return self . rawValue
40
40
}
41
41
}
@@ -50,9 +50,18 @@ enum Branch: String, EnumerableFlag {
50
50
var tagPrefix : String {
51
51
switch self {
52
52
case . development:
53
- " swift- \( rawValue. uppercased ( ) ) "
53
+ " swift- \( rawValue. uppercased ( ) ) "
54
54
default :
55
- " swift- \( rawValue. uppercased ( ) ) -DEVELOPMENT "
55
+ " swift- \( rawValue. uppercased ( ) ) -DEVELOPMENT "
56
+ }
57
+ }
58
+
59
+ var urlBranchName : String {
60
+ switch self {
61
+ case . development:
62
+ return self . rawValue
63
+ default :
64
+ return " swift- \( self . rawValue) -branch "
56
65
}
57
66
}
58
67
}
You can’t perform that action at this time.
0 commit comments