Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Softer API version check #129

Merged
merged 1 commit into from
Jan 14, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions XcodeServerSDK/XcodeServer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ extension XcodeServer : NSURLSessionDelegate {

// MARK: Header constants
let Headers_APIVersion = "X-XCSAPIVersion"
let SupportedAPIVersions: Set<Int> = [6, 7] //will change with time, this codebase supports this version
let VerifiedAPIVersions: Set<Int> = [6, 7] //will change with time, this codebase supports these versions

// MARK: XcodeServer API methods
public extension XcodeServer {
Expand All @@ -88,17 +88,16 @@ public extension XcodeServer {
let apiVersion = Int(apiVersionString)

if let apiVersion = apiVersion where
apiVersion > 0 && !SupportedAPIVersions.contains(apiVersion) {
var common = "Version mismatch: response from API version \(apiVersion), but we support version \(SupportedAPIVersions). "
apiVersion > 0 && !VerifiedAPIVersions.contains(apiVersion) {
var common = "Version mismatch: response from API version \(apiVersion), but we only verified versions \(VerifiedAPIVersions). "

let maxVersion = SupportedAPIVersions.sort().last!
let maxVersion = VerifiedAPIVersions.sort().last!
if apiVersion > maxVersion {
common += "You're using a newer Xcode Server than we support. Please visit https://github.com/czechboy0/XcodeServerSDK to check whether there's a new version of the SDK for it."
Log.info("You're using a newer Xcode Server than we've verified (\(apiVersion), last verified is \(maxVersion)). Please visit https://github.com/czechboy0/XcodeServerSDK to check whether there's a new version of the SDK for it. If not, please file an issue in the XcodeServerSDK repository. The requests are still going through, however we haven't verified this API version, so here be dragons.")
} else {
common += "You're using an old Xcode Server which we don't support any more. Please look for an older version of the SDK at https://github.com/czechboy0/XcodeServerSDK or consider upgrading your Xcode Server to the current version."
return Error.withInfo(common)
}

return Error.withInfo(common)
}

//all good
Expand Down