forked from Carthage/Carthage
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRemoteVersion.swift
More file actions
19 lines (18 loc) · 806 Bytes
/
RemoteVersion.swift
File metadata and controls
19 lines (18 loc) · 806 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import Foundation
import ReactiveSwift
import ReactiveTask
import Result
import Tentacle
/// Synchronously returns the semantic version of the newest release,
/// if the given producer emits it within a reasonable timeframe.
///
public func remoteVersion(_ remoteVersionProducer: SignalProducer<Release, CarthageError>) -> SemanticVersion? {
let latestRemoteVersion = remoteVersionProducer
.attemptMap { release -> Result<SemanticVersion, CarthageError> in
return SemanticVersion.from(Scanner(string: release.tag)).mapError(CarthageError.init(scannableError:))
}
// Add timeout on different queue so that `first()` doesn't block timeout scheduling
.timeout(after: 0.5, raising: CarthageError.gitHubAPITimeout, on: QueueScheduler(qos: .default))
.first()
return latestRemoteVersion?.value
}