-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #129 from interstateone/xcode-releases
Add support for and default to Xcode Releases data source
- Loading branch information
Showing
16 changed files
with
365 additions
and
151 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import Foundation | ||
|
||
public enum DataSource: String, CaseIterable { | ||
case apple | ||
case xcodeReleases | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import Version | ||
import struct XCModel.Xcode | ||
|
||
extension Version { | ||
/// Initialize a Version from an XcodeReleases' XCModel.Xcode | ||
/// | ||
/// This is kinda quick-and-dirty, and it would probably be better for us to adopt something closer to XCModel.Xcode under the hood and map the scraped data to it instead. | ||
init?(xcReleasesXcode: XCModel.Xcode) { | ||
var versionString = xcReleasesXcode.version.number ?? "" | ||
|
||
// Append trailing ".0" in order to get a fully-specified version string | ||
let components = versionString.components(separatedBy: ".") | ||
versionString += Array(repeating: ".0", count: 3 - components.count).joined() | ||
|
||
// Append prerelease identifier | ||
switch xcReleasesXcode.version.release { | ||
case let .beta(beta): | ||
versionString += "-Beta" | ||
if beta > 1 { | ||
versionString += ".\(beta)" | ||
} | ||
case let .dp(dp): | ||
versionString += "-DP" | ||
if dp > 1 { | ||
versionString += ".\(dp)" | ||
} | ||
case .gm: | ||
versionString += "-GM" | ||
case let .gmSeed(gmSeed): | ||
versionString += "-GM.Seed" | ||
if gmSeed > 1 { | ||
versionString += ".\(gmSeed)" | ||
} | ||
case let .rc(rc): | ||
versionString += "-Release.Candidate" | ||
if rc > 1 { | ||
versionString += ".\(rc)" | ||
} | ||
case .release: | ||
break | ||
} | ||
|
||
// Append build identifier | ||
if let buildNumber = xcReleasesXcode.version.build { | ||
versionString += "+\(buildNumber)" | ||
} | ||
|
||
self.init(versionString) | ||
} | ||
|
||
var buildMetadataIdentifiersDisplay: String { | ||
return !buildMetadataIdentifiers.isEmpty ? "(\(buildMetadataIdentifiers.joined(separator: " ")))" : "" | ||
} | ||
} |
Oops, something went wrong.