Skip to content

Commit

Permalink
Merge pull request #12 from g-Off/fix-version-parsing
Browse files Browse the repository at this point in the history
adds Version library to fix parsing of `-alpha.1` type versions
  • Loading branch information
g-Off authored Oct 29, 2019
2 parents 3185d17 + 1906885 commit 841fad7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 30 deletions.
5 changes: 3 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ let package = Package(
targets: ["XcodeProject"]),
],
dependencies: [
.package(url: "https://github.com/g-Off/ObjectCoder.git", .exact("0.1.0"))
.package(url: "https://github.com/g-Off/ObjectCoder.git", .exact("0.1.0")),
.package(url: "https://github.com/mxcl/Version.git", from: "1.0.0")
],
targets: [
.target(
name: "XcodeProject",
dependencies: ["ObjectCoder"]),
dependencies: ["ObjectCoder", "Version"]),
.testTarget(
name: "XcodeProjectTests",
dependencies: ["XcodeProject"]),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ public extension PBXReference {
return nil
}

enum SortOption: String {
enum SortOption: String, CustomStringConvertible, CaseIterable {
public var description: String {
return rawValue
}

case name
case type

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//

import Foundation
import Version

public final class XCRemoteSwiftPackageReference: XCSwiftPackageReference {
public enum Requirement: Encodable {
Expand All @@ -17,33 +18,6 @@ public final class XCRemoteSwiftPackageReference: XCSwiftPackageReference {
case branch
case revision
}

public struct Version: CustomStringConvertible, Encodable {
let major: Int
let minor: Int
let patch: Int

public init(major: Int, minor: Int, patch: Int) {
self.major = major
self.minor = minor
self.patch = patch
}

init?(_ value: String) {
var integerValues = value.components(separatedBy: ".").compactMap { Int($0) }
guard integerValues.count == 3 else { return nil }
self.init(major: integerValues.removeFirst(), minor: integerValues.removeFirst(), patch: integerValues.removeFirst())
}

public var description: String {
return "\(major).\(minor).\(patch)"
}

public func encode(to encoder: Encoder) throws {
var container = encoder.singleValueContainer()
try container.encode(description)
}
}

public struct GitHash: Encodable, CustomStringConvertible {
private var value: String
Expand Down

0 comments on commit 841fad7

Please sign in to comment.