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(
128128 let fileType = platform. fileType
129129 let toolchainType = platform. toolchainType
130130
131- let realBranch = branch != . development ? " swift- \( branch ) -branch " : branch . rawValue
131+ let realBranch = branch. urlBranchName
132132 let toolchainDir = " \( workspace) / \( tag. name) - \( platform) "
133133 let downloadPath = URL ( fileURLWithPath: " \( workspace) / \( tag. name) - \( platform) . \( fileType) " )
134134 if !fileExists( toolchainDir) {
Original file line number Diff line number Diff line change @@ -27,18 +27,23 @@ struct Tag: Decodable {
2727 ref. dropFirst ( 10 )
2828 }
2929
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-
3630 func date( branch: Branch ) -> Date {
37- // TODO: I think that d might be a class... if so, we really want to memoize
38- // this.
3931 let d = DateFormatter ( )
4032 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+ }
4247 }
4348}
4449
Original file line number Diff line number Diff line change @@ -23,8 +23,8 @@ enum Platform: String, EnumerableFlag {
2323 case . osx:
2424 return " pkg "
2525 case . ubuntu1404,
26- . ubuntu1604,
27- . ubuntu1804:
26+ . ubuntu1604,
27+ . ubuntu1804:
2828 return " tar.gz "
2929 }
3030 }
@@ -34,8 +34,8 @@ enum Platform: String, EnumerableFlag {
3434 case . osx:
3535 return " xcode "
3636 case . ubuntu1404,
37- . ubuntu1604,
38- . ubuntu1804:
37+ . ubuntu1604,
38+ . ubuntu1804:
3939 return self . rawValue
4040 }
4141 }
@@ -50,9 +50,18 @@ enum Branch: String, EnumerableFlag {
5050 var tagPrefix : String {
5151 switch self {
5252 case . development:
53- " swift- \( rawValue. uppercased ( ) ) "
53+ " swift- \( rawValue. uppercased ( ) ) "
5454 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 "
5665 }
5766 }
5867}
You can’t perform that action at this time.
0 commit comments