From 5a60fd9659499e9dfdd20921ce8ac8dc2d4d2cf7 Mon Sep 17 00:00:00 2001 From: Ben Chatelain Date: Wed, 18 Nov 2015 07:27:42 -0700 Subject: [PATCH 001/302] Remove header comments --- OctoKit/Time.swift | 8 -------- OctoKitTests/TimeTests.swift | 8 -------- 2 files changed, 16 deletions(-) diff --git a/OctoKit/Time.swift b/OctoKit/Time.swift index 44bc6bbd..42af97e3 100644 --- a/OctoKit/Time.swift +++ b/OctoKit/Time.swift @@ -1,11 +1,3 @@ -// -// Time.swift -// OctoKit -// -// Created by Ben Chatelain on 11/18/15. -// Copyright © 2015 nerdish by nature. All rights reserved. -// - import Foundation struct Time { diff --git a/OctoKitTests/TimeTests.swift b/OctoKitTests/TimeTests.swift index f1105a90..08a4cae4 100644 --- a/OctoKitTests/TimeTests.swift +++ b/OctoKitTests/TimeTests.swift @@ -1,11 +1,3 @@ -// -// TimeTests.swift -// OctoKit -// -// Created by Ben Chatelain on 11/18/15. -// Copyright © 2015 nerdish by nature. All rights reserved. -// - import XCTest @testable import OctoKit From 4982d8aac8cfcc369a981138a654235ec1ebc133 Mon Sep 17 00:00:00 2001 From: Piet Brauer Date: Wed, 18 Nov 2015 21:38:15 +0700 Subject: [PATCH 002/302] Add .travis.yml --- .travis.yml | 6 ++++++ Makefile | 3 ++- circle.yml | 9 --------- 3 files changed, 8 insertions(+), 10 deletions(-) create mode 100644 .travis.yml delete mode 100644 circle.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..ba2eec64 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,6 @@ +osx_image: xcode7.1 +language: objective-c +before_install: + - make install +script: + - make test diff --git a/Makefile b/Makefile index 24abd97b..793180bf 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,7 @@ install: + brew update brew install carthage carthage bootstrap test: - set -o pipefail && xcodebuild clean test -scheme OctoKit -sdk iphonesimulator | xcpretty -c -r junit --output $(CIRCLE_TEST_REPORTS)/xcode/results.xml + set -o pipefail && xcodebuild clean test -scheme OctoKit -sdk iphonesimulator | xcpretty -c diff --git a/circle.yml b/circle.yml deleted file mode 100644 index 8ead812c..00000000 --- a/circle.yml +++ /dev/null @@ -1,9 +0,0 @@ -machine: - xcode: - version: "7.0" -dependencies: - override: - - make install -test: - override: - - make test From 3c697338e30f2fda467b45b34323e1abf1f596c7 Mon Sep 17 00:00:00 2001 From: Piet Brauer Date: Wed, 18 Nov 2015 21:39:42 +0700 Subject: [PATCH 003/302] Add travis badge --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 775ffbd1..46058fc3 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # Octokit.swift +[![Build Status](https://travis-ci.org/nerdishbynature/octokit.swift.svg?branch=travis.yml)](https://travis-ci.org/nerdishbynature/octokit.swift) + ## Authentication Octokit supports both, Github and Github Enterprise. From a2f3e681e9bfbdc2ca5e1e96edc45310776f5bc4 Mon Sep 17 00:00:00 2001 From: Piet Brauer Date: Wed, 18 Nov 2015 22:30:17 +0700 Subject: [PATCH 004/302] Use master branch for badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 46058fc3..b470502f 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Octokit.swift -[![Build Status](https://travis-ci.org/nerdishbynature/octokit.swift.svg?branch=travis.yml)](https://travis-ci.org/nerdishbynature/octokit.swift) +[![Build Status](https://travis-ci.org/nerdishbynature/octokit.swift.svg?branch=master)](https://travis-ci.org/nerdishbynature/octokit.swift) ## Authentication From a03de96c2f8e386e3fab18819232c41b765b6eae Mon Sep 17 00:00:00 2001 From: Piet Brauer Date: Tue, 24 Nov 2015 10:13:34 +0700 Subject: [PATCH 005/302] Post code coverage using slather and codecov --- .travis.yml | 2 ++ Gemfile | 3 +++ Gemfile.lock | 44 ++++++++++++++++++++++++++++++++++++++++++++ Makefile | 8 +++++++- README.md | 1 + 5 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 Gemfile create mode 100644 Gemfile.lock diff --git a/.travis.yml b/.travis.yml index ba2eec64..751d2610 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,3 +4,5 @@ before_install: - make install script: - make test +after_success: + - make post_coverage diff --git a/Gemfile b/Gemfile new file mode 100644 index 00000000..665536c2 --- /dev/null +++ b/Gemfile @@ -0,0 +1,3 @@ +source "https://rubygems.org" + +gem "slather", git: "https://github.com/nerdishbynature/slather.git", branch: "feature-profdata" diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 00000000..ca2dea41 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,44 @@ +GIT + remote: https://github.com/nerdishbynature/slather.git + revision: fd90e5e76e2a6422a9c4a4d43d0104529659f3b3 + branch: feature-profdata + specs: + slather (1.8.1) + clamp (~> 0.6) + nokogiri (~> 1.6.3) + xcodeproj (~> 0.26.2) + +GEM + remote: https://rubygems.org/ + specs: + activesupport (4.2.5) + i18n (~> 0.7) + json (~> 1.7, >= 1.7.7) + minitest (~> 5.1) + thread_safe (~> 0.3, >= 0.3.4) + tzinfo (~> 1.1) + claide (0.9.1) + clamp (0.6.5) + colored (1.2) + i18n (0.7.0) + json (1.8.3) + mini_portile (0.6.2) + minitest (5.8.3) + nokogiri (1.6.6.4) + mini_portile (~> 0.6.0) + thread_safe (0.3.5) + tzinfo (1.2.2) + thread_safe (~> 0.1) + xcodeproj (0.26.3) + activesupport (>= 3) + claide (~> 0.9.1) + colored (~> 1.2) + +PLATFORMS + ruby + +DEPENDENCIES + slather! + +BUNDLED WITH + 1.10.6 diff --git a/Makefile b/Makefile index 793180bf..20124968 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,13 @@ install: brew update brew install carthage + brew install python + pip install codecov carthage bootstrap test: - set -o pipefail && xcodebuild clean test -scheme OctoKit -sdk iphonesimulator | xcpretty -c + set -o pipefail && xcodebuild clean test -scheme OctoKit -sdk iphonesimulator ONLY_ACTIVE_ARCH=YES -enableCodeCoverage YES | xcpretty -c + +post_coverage: + bundle exec slather coverage --input-format profdata -x --ignore "../**/*/Xcode*" --ignore "Carthage/**" --output-directory slather-report --scheme OctoKit Octokit.xcodeproj + codecov -f slather-report/cobertura.xml diff --git a/README.md b/README.md index b470502f..d532ee64 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # Octokit.swift [![Build Status](https://travis-ci.org/nerdishbynature/octokit.swift.svg?branch=master)](https://travis-ci.org/nerdishbynature/octokit.swift) +[![codecov.io](https://codecov.io/github/nerdishbynature/octokit.swift/coverage.svg?branch=master)](https://codecov.io/github/nerdishbynature/octokit.swift?branch=master) ## Authentication From ebb05b180fb5349fb40b2a8f3b51c9780a68a573 Mon Sep 17 00:00:00 2001 From: Nate West Date: Tue, 24 Nov 2015 09:42:38 -0500 Subject: [PATCH 006/302] Add podspec for CocoaPods users --- Makefile | 1 + OctoKit.swift.podspec | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 OctoKit.swift.podspec diff --git a/Makefile b/Makefile index 20124968..a70185f3 100644 --- a/Makefile +++ b/Makefile @@ -6,6 +6,7 @@ install: carthage bootstrap test: + pod lib lint --quick set -o pipefail && xcodebuild clean test -scheme OctoKit -sdk iphonesimulator ONLY_ACTIVE_ARCH=YES -enableCodeCoverage YES | xcpretty -c post_coverage: diff --git a/OctoKit.swift.podspec b/OctoKit.swift.podspec new file mode 100644 index 00000000..fb359bfc --- /dev/null +++ b/OctoKit.swift.podspec @@ -0,0 +1,20 @@ +Pod::Spec.new do |s| + s.name = "OctoKit.swift" + s.version = "0.1.0" + s.summary = "Swift version of the Octokit family" + s.description = <<-DESC + You are looking at the Swift port of the + Octokit family. This is very unofficial and not maintained + by Github. + DESC + s.homepage = "https://github.com/nerdishbynature/octokit.swift" + s.license = "MIT" + s.author = { "Piet Brauer" => "piet@nerdishbynature.com" } + s.source = { :git => "https://github.com/nerdishbynature/octokit.swift.git", :tag => s.version.to_s } + s.social_media_url = "https://twitter.com/pietbrauer" + s.module_name = "Octokit" + s.dependency "NBNRequestKit", "~> 0.1.0" + s.platform = :ios, "8.0" + s.requires_arc = true + s.source_files = "OctoKit/*.swift" +end From e1ab504b397fd472ec032c05c5a297b755746b3b Mon Sep 17 00:00:00 2001 From: Nate West Date: Tue, 24 Nov 2015 09:48:06 -0500 Subject: [PATCH 007/302] Fix LICENSE podspec link --- OctoKit.swift.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OctoKit.swift.podspec b/OctoKit.swift.podspec index fb359bfc..80685218 100644 --- a/OctoKit.swift.podspec +++ b/OctoKit.swift.podspec @@ -8,7 +8,7 @@ Pod::Spec.new do |s| by Github. DESC s.homepage = "https://github.com/nerdishbynature/octokit.swift" - s.license = "MIT" + s.license = { :type => "MIT", :file => "LICENSE" } s.author = { "Piet Brauer" => "piet@nerdishbynature.com" } s.source = { :git => "https://github.com/nerdishbynature/octokit.swift.git", :tag => s.version.to_s } s.social_media_url = "https://twitter.com/pietbrauer" From 0efebc16f1cbec0c54d5292104cf5e1b5b6822a4 Mon Sep 17 00:00:00 2001 From: Nate West Date: Tue, 24 Nov 2015 09:53:06 -0500 Subject: [PATCH 008/302] Travis hotfix https://github.com/Homebrew/homebrew/issues/45616#issuecomment-153104335 --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index a70185f3..77d382c0 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ install: - brew update + brew update || brew update brew install carthage brew install python pip install codecov From 9f8d554e8aed66837754ac331f0b603408095680 Mon Sep 17 00:00:00 2001 From: Nate West Date: Tue, 24 Nov 2015 11:29:12 -0500 Subject: [PATCH 009/302] Fix Version number --- OctoKit.swift.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OctoKit.swift.podspec b/OctoKit.swift.podspec index 80685218..9d757ac5 100644 --- a/OctoKit.swift.podspec +++ b/OctoKit.swift.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "OctoKit.swift" - s.version = "0.1.0" + s.version = "0.4.0" s.summary = "Swift version of the Octokit family" s.description = <<-DESC You are looking at the Swift port of the From 4908294060625ccd98b2b22ec1aaa2224bfd0a12 Mon Sep 17 00:00:00 2001 From: Nate West Date: Tue, 24 Nov 2015 11:38:35 -0500 Subject: [PATCH 010/302] Add documentation for the Repository calls --- OctoKit/Repositories.swift | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/OctoKit/Repositories.swift b/OctoKit/Repositories.swift index b71187bf..06dfbcd3 100644 --- a/OctoKit/Repositories.swift +++ b/OctoKit/Repositories.swift @@ -44,6 +44,14 @@ import RequestKit // MARK: request public extension Octokit { + +/** + Fetches all the Repositories for a user or organization + - parameter owner: The user or organization that owns the repositories. If `nil`, fetches repositories for the authenticated user. + - parameter page: Current page for repository pagination. `1` by default. + - parameter perPage: Number of repositories per page. `100` by default. + - parameter completion: Callback for the outcome of the fetch. +*/ public func repositories(owner: String? = nil, page: String = "1", perPage: String = "100", completion: (response: Response<[Repository]>) -> Void) { let router = (owner != nil) ? RepositoryRouter.ReadRepositories(configuration, owner!, page, perPage) @@ -60,6 +68,12 @@ public extension Octokit { } } +/** + Fetches a repository for a user or organization + - parameter owner: The user or organization that owns the repositories. + - parameter name: The name of the repository to fetch. + - parameter completion: Callback for the outcome of the fetch. +*/ public func repository(owner: String, name: String, completion: (response: Response) -> Void) { let router = RepositoryRouter.ReadRepository(configuration, owner, name) router.loadJSON([String: AnyObject].self) { json, error in From e1cd3b4c146297f6f439bd5d02db6f5ac122ca2b Mon Sep 17 00:00:00 2001 From: Nate West Date: Tue, 24 Nov 2015 11:44:49 -0500 Subject: [PATCH 011/302] Add documentation for the User calls --- OctoKit/User.swift | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/OctoKit/User.swift b/OctoKit/User.swift index 0d77b65b..622d1123 100644 --- a/OctoKit/User.swift +++ b/OctoKit/User.swift @@ -42,6 +42,12 @@ import RequestKit // MARK: request public extension Octokit { + +/** + Fetches a user or organization + - parameter name: The name of the user or organization. + - parameter completion: Callback for the outcome of the fetch. +*/ public func user(name: String, completion: (response: Response) -> Void) { let router = UserRouter.ReadUser(name, self.configuration) router.loadJSON([String: AnyObject].self) { json, error in @@ -56,6 +62,10 @@ public extension Octokit { } } +/** + Fetches the authenticated user + - parameter completion: Callback for the outcome of the fetch. +*/ public func me(completion: (response: Response) -> Void) { let router = UserRouter.ReadAuthenticatedUser(self.configuration) router.loadJSON([String: AnyObject].self) { json, error in From 76cc60f1860f429447cbf1d946f5adbe2745a3da Mon Sep 17 00:00:00 2001 From: Nate West Date: Tue, 24 Nov 2015 11:48:51 -0500 Subject: [PATCH 012/302] Add documentation for the Stars calls --- OctoKit/Stars.swift | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/OctoKit/Stars.swift b/OctoKit/Stars.swift index 206b3f53..e651bfa4 100644 --- a/OctoKit/Stars.swift +++ b/OctoKit/Stars.swift @@ -2,6 +2,12 @@ import Foundation import RequestKit public extension Octokit { + +/** + Fetches all the starred repositories for a user + - parameter name: The user who starred repositories. + - parameter completion: Callback for the outcome of the fetch. +*/ public func stars(name: String, completion: (response: Response<[Repository]>) -> Void) { let router = StarsRouter.ReadStars(name, configuration) router.loadJSON([[String: AnyObject]].self) { json, error in @@ -16,6 +22,10 @@ public extension Octokit { } } +/** + Fetches all the starred repositories for the authenticated user + - parameter completion: Callback for the outcome of the fetch. +*/ public func myStars(completion: (response: Response<[Repository]>) -> Void) { let router = StarsRouter.ReadAuthenticatedStars(configuration) router.loadJSON([[String: AnyObject]].self) { json, error in From dfd2c2461c8bf29d89714a80618b929ff57975c6 Mon Sep 17 00:00:00 2001 From: Nate West Date: Tue, 24 Nov 2015 11:49:18 -0500 Subject: [PATCH 013/302] Fix Repository documentation --- OctoKit/Repositories.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OctoKit/Repositories.swift b/OctoKit/Repositories.swift index 06dfbcd3..b5525614 100644 --- a/OctoKit/Repositories.swift +++ b/OctoKit/Repositories.swift @@ -46,7 +46,7 @@ import RequestKit public extension Octokit { /** - Fetches all the Repositories for a user or organization + Fetches the Repositories for a user or organization - parameter owner: The user or organization that owns the repositories. If `nil`, fetches repositories for the authenticated user. - parameter page: Current page for repository pagination. `1` by default. - parameter perPage: Number of repositories per page. `100` by default. From 84f8ca2d65164f23aaaed338003a175173fc750d Mon Sep 17 00:00:00 2001 From: Nate West Date: Tue, 24 Nov 2015 11:56:26 -0500 Subject: [PATCH 014/302] Add documentation for time utils --- OctoKit/Time.swift | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/OctoKit/Time.swift b/OctoKit/Time.swift index 42af97e3..c32da4a1 100644 --- a/OctoKit/Time.swift +++ b/OctoKit/Time.swift @@ -2,11 +2,12 @@ import Foundation struct Time { - /// A date formatter for RFC 3339 style timestamps. Uses POSIX locale and GMT timezone so that date - /// values are parsed as absolutes. - /// - https://tools.ietf.org/html/rfc3339 - /// - https://developer.apple.com/library/mac/qa/qa1480/_index.html - /// - https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/DataFormatting/Articles/dfDateFormatting10_4.html +/** + A date formatter for RFC 3339 style timestamps. Uses POSIX locale and GMT timezone so that date values are parsed as absolutes. + - [https://tools.ietf.org/html/rfc3339](https://tools.ietf.org/html/rfc3339) + - [https://developer.apple.com/library/mac/qa/qa1480/_index.html](https://developer.apple.com/library/mac/qa/qa1480/_index.html) + - [https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/DataFormatting/Articles/dfDateFormatting10_4.html](https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/DataFormatting/Articles/dfDateFormatting10_4.html) +*/ private static var rfc3339DateFormatter: NSDateFormatter = { let formatter = NSDateFormatter() formatter.dateFormat = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'" @@ -15,9 +16,13 @@ struct Time { return formatter }() +/** + Parses RFC 3339 date strings into NSDate + - parameter string: The string representation of the date + - returns: An `NSDate` with a successful parse, otherwise `nil` +*/ static func rfc3339Date(string: String?) -> NSDate? { guard let string = string else { return nil } return Time.rfc3339DateFormatter.dateFromString(string) } - } From 6691abe2a5005db136072b9d0d7e5c623ab89ba3 Mon Sep 17 00:00:00 2001 From: Nate West Date: Tue, 24 Nov 2015 12:01:44 -0500 Subject: [PATCH 015/302] Add documentation for the follow system calls --- OctoKit/Follow.swift | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/OctoKit/Follow.swift b/OctoKit/Follow.swift index cf549ff2..4aa64cbd 100644 --- a/OctoKit/Follow.swift +++ b/OctoKit/Follow.swift @@ -2,6 +2,11 @@ import Foundation import RequestKit public extension Octokit { + +/** + Fetches the followers of the authenticated user + - parameter completion: Callback for the outcome of the fetch. +*/ public func myFollowers(completion: (response: Response<[User]>) -> Void) { let router = FollowRouter.ReadAuthenticatedFollowers(configuration) router.loadJSON([[String: AnyObject]].self) { json, error in @@ -16,6 +21,11 @@ public extension Octokit { } } +/** + Fetches the followers of a user + - parameter name: Name of the user + - parameter completion: Callback for the outcome of the fetch. +*/ public func followers(name: String, completion: (response: Response<[User]>) -> Void) { let router = FollowRouter.ReadFollowers(name, configuration) router.loadJSON([[String: AnyObject]].self) { json, error in @@ -30,6 +40,10 @@ public extension Octokit { } } +/** + Fetches the users following the authenticated user + - parameter completion: Callback for the outcome of the fetch. +*/ public func myFollowing(completion: (response: Response<[User]>) -> Void) { let router = FollowRouter.ReadAuthenticatedFollowing(configuration) router.loadJSON([[String: AnyObject]].self) { json, error in @@ -44,6 +58,11 @@ public extension Octokit { } } +/** + Fetches the users following a user + - parameter name: The name of the user + - parameter completion: Callback for the outcome of the fetch. +*/ public func following(name: String, completion: (response: Response<[User]>) -> Void) { let router = FollowRouter.ReadFollowing(name, configuration) router.loadJSON([[String: AnyObject]].self) { json, error in From 95eaef02ce4ed468855cc12798b46014302028c8 Mon Sep 17 00:00:00 2001 From: Nate West Date: Tue, 24 Nov 2015 12:14:29 -0500 Subject: [PATCH 016/302] Privatize RepositoryRouter --- OctoKit/Repositories.swift | 14 +++++++------- OctoKitTests/RepositoryTests.swift | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/OctoKit/Repositories.swift b/OctoKit/Repositories.swift index b71187bf..13db1579 100644 --- a/OctoKit/Repositories.swift +++ b/OctoKit/Repositories.swift @@ -77,12 +77,12 @@ public extension Octokit { // MARK: Router -public enum RepositoryRouter: Router { +enum RepositoryRouter: Router { case ReadRepositories(Configuration, String, String, String) case ReadAuthenticatedRepositories(Configuration, String, String) case ReadRepository(Configuration, String, String) - public var configuration: Configuration { + var configuration: Configuration { switch self { case .ReadRepositories(let config, _, _, _): return config case .ReadAuthenticatedRepositories(let config, _, _): return config @@ -90,15 +90,15 @@ public enum RepositoryRouter: Router { } } - public var method: HTTPMethod { + var method: HTTPMethod { return .GET } - public var encoding: HTTPEncoding { + var encoding: HTTPEncoding { return .URL } - public var params: [String: String] { + var params: [String: String] { switch self { case .ReadRepositories(_, _, let page, let perPage): return ["per_page": perPage, "page": page] @@ -109,7 +109,7 @@ public enum RepositoryRouter: Router { } } - public var path: String { + var path: String { switch self { case ReadRepositories(_, let owner, _, _): return "/users/\(owner)/repos" @@ -120,7 +120,7 @@ public enum RepositoryRouter: Router { } } - public var URLRequest: NSURLRequest? { + var URLRequest: NSURLRequest? { switch self { case .ReadRepositories(_, _, _, _): return request() diff --git a/OctoKitTests/RepositoryTests.swift b/OctoKitTests/RepositoryTests.swift index 7bfb7847..fb40f752 100644 --- a/OctoKitTests/RepositoryTests.swift +++ b/OctoKitTests/RepositoryTests.swift @@ -1,5 +1,5 @@ import XCTest -import OctoKit +@testable import OctoKit import Nocilla class RepositoryTests: XCTestCase { From 7960a200a8a05c1d2e2a533c446dd92d0d82583f Mon Sep 17 00:00:00 2001 From: Nate West Date: Tue, 24 Nov 2015 12:16:57 -0500 Subject: [PATCH 017/302] Privatize oAuthRouter --- OctoKit/Configuration.swift | 14 +++++++------- OctoKitTests/ConfigurationTests.swift | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/OctoKit/Configuration.swift b/OctoKit/Configuration.swift index e4602caf..3044557f 100644 --- a/OctoKit/Configuration.swift +++ b/OctoKit/Configuration.swift @@ -74,18 +74,18 @@ public struct OAuthConfiguration: Configuration { } } -public enum OAuthRouter: Router { +enum OAuthRouter: Router { case Authorize(OAuthConfiguration) case AccessToken(OAuthConfiguration, String) - public var configuration: Configuration { + var configuration: Configuration { switch self { case .Authorize(let config): return config case .AccessToken(let config, _): return config } } - public var method: HTTPMethod { + var method: HTTPMethod { switch self { case .Authorize: return .GET @@ -94,7 +94,7 @@ public enum OAuthRouter: Router { } } - public var encoding: HTTPEncoding { + var encoding: HTTPEncoding { switch self { case .Authorize: return .URL @@ -103,7 +103,7 @@ public enum OAuthRouter: Router { } } - public var path: String { + var path: String { switch self { case .Authorize: return "login/oauth/authorize" @@ -112,7 +112,7 @@ public enum OAuthRouter: Router { } } - public var params: [String: String] { + var params: [String: String] { switch self { case .Authorize(let config): let scope = (config.scopes as NSArray).componentsJoinedByString(",") @@ -122,7 +122,7 @@ public enum OAuthRouter: Router { } } - public var URLRequest: NSURLRequest? { + var URLRequest: NSURLRequest? { switch self { case .Authorize(let config): let URLString = config.webEndpoint.stringByAppendingURLPath(path) diff --git a/OctoKitTests/ConfigurationTests.swift b/OctoKitTests/ConfigurationTests.swift index 19c9a82a..a9612572 100644 --- a/OctoKitTests/ConfigurationTests.swift +++ b/OctoKitTests/ConfigurationTests.swift @@ -1,6 +1,6 @@ import XCTest import Foundation -import OctoKit +@testable import OctoKit import Nocilla class ConfigurationTests: XCTestCase { From 4183a80e292e86efdca2c2fc7c513ae8dc45e354 Mon Sep 17 00:00:00 2001 From: Nate West Date: Tue, 24 Nov 2015 12:18:37 -0500 Subject: [PATCH 018/302] Privatize FollowRouter --- OctoKit/Follow.swift | 14 +++++++------- OctoKitTests/FollowTests.swift | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/OctoKit/Follow.swift b/OctoKit/Follow.swift index cf549ff2..d3f88242 100644 --- a/OctoKit/Follow.swift +++ b/OctoKit/Follow.swift @@ -59,21 +59,21 @@ public extension Octokit { } } -public enum FollowRouter: Router { +enum FollowRouter: Router { case ReadAuthenticatedFollowers(Configuration) case ReadFollowers(String, Configuration) case ReadAuthenticatedFollowing(Configuration) case ReadFollowing(String, Configuration) - public var method: HTTPMethod { + var method: HTTPMethod { return .GET } - public var encoding: HTTPEncoding { + var encoding: HTTPEncoding { return .URL } - public var configuration: Configuration { + var configuration: Configuration { switch self { case .ReadAuthenticatedFollowers(let config): return config case .ReadFollowers(_, let config): return config @@ -82,7 +82,7 @@ public enum FollowRouter: Router { } } - public var path: String { + var path: String { switch self { case .ReadAuthenticatedFollowers: return "user/followers" @@ -95,11 +95,11 @@ public enum FollowRouter: Router { } } - public var params: [String: String] { + var params: [String: String] { return [:] } - public var URLRequest: NSURLRequest? { + var URLRequest: NSURLRequest? { return request() } } diff --git a/OctoKitTests/FollowTests.swift b/OctoKitTests/FollowTests.swift index 79fb9c5f..75394c73 100644 --- a/OctoKitTests/FollowTests.swift +++ b/OctoKitTests/FollowTests.swift @@ -1,5 +1,5 @@ import XCTest -import OctoKit +@testable import OctoKit import Nocilla class FollowTests: XCTestCase { From 35848200c4cea8f66f852a3cc3bdaad7459f8d56 Mon Sep 17 00:00:00 2001 From: Nate West Date: Tue, 24 Nov 2015 12:19:34 -0500 Subject: [PATCH 019/302] Privatize PublicKeyRouter --- OctoKit/PublicKey.swift | 14 +++++++------- OctoKitTests/PublicKeyTests.swift | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/OctoKit/PublicKey.swift b/OctoKit/PublicKey.swift index 975d2b95..1b496be2 100644 --- a/OctoKit/PublicKey.swift +++ b/OctoKit/PublicKey.swift @@ -18,44 +18,44 @@ public extension Octokit { } } -public enum PublicKeyRouter: JSONPostRouter { +enum PublicKeyRouter: JSONPostRouter { case PostPublicKey(String, String, Configuration) - public var configuration: Configuration { + var configuration: Configuration { switch self { case .PostPublicKey(_, _, let config): return config } } - public var method: HTTPMethod { + var method: HTTPMethod { switch self { case .PostPublicKey: return .POST } } - public var encoding: HTTPEncoding { + var encoding: HTTPEncoding { switch self { case .PostPublicKey: return .JSON } } - public var path: String { + var path: String { switch self { case .PostPublicKey: return "user/keys" } } - public var params: [String: String] { + var params: [String: String] { switch self { case .PostPublicKey(let publicKey, let title, _): return ["title": title, "key": publicKey] } } - public var URLRequest: NSURLRequest? { + var URLRequest: NSURLRequest? { switch self { case .PostPublicKey(_, _, _): return request() diff --git a/OctoKitTests/PublicKeyTests.swift b/OctoKitTests/PublicKeyTests.swift index fd50be34..07711124 100644 --- a/OctoKitTests/PublicKeyTests.swift +++ b/OctoKitTests/PublicKeyTests.swift @@ -1,5 +1,5 @@ import XCTest -import OctoKit +@testable import OctoKit import Nocilla class PublicKeyTests: XCTestCase { From 9c25dc9dc3e47be8c4e27b40b337da7633c7c435 Mon Sep 17 00:00:00 2001 From: Nate West Date: Tue, 24 Nov 2015 12:20:44 -0500 Subject: [PATCH 020/302] Privatize UserRouter --- OctoKit/User.swift | 14 +++++++------- OctoKitTests/UserTests.swift | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/OctoKit/User.swift b/OctoKit/User.swift index 0d77b65b..661fdcf4 100644 --- a/OctoKit/User.swift +++ b/OctoKit/User.swift @@ -73,26 +73,26 @@ public extension Octokit { // MARK: Router -public enum UserRouter: Router { +enum UserRouter: Router { case ReadAuthenticatedUser(Configuration) case ReadUser(String, Configuration) - public var configuration: Configuration { + var configuration: Configuration { switch self { case .ReadAuthenticatedUser(let config): return config case .ReadUser(_, let config): return config } } - public var method: HTTPMethod { + var method: HTTPMethod { return .GET } - public var encoding: HTTPEncoding { + var encoding: HTTPEncoding { return .URL } - public var path: String { + var path: String { switch self { case .ReadAuthenticatedUser: return "user" @@ -101,11 +101,11 @@ public enum UserRouter: Router { } } - public var params: [String: String] { + var params: [String: String] { return [:] } - public var URLRequest: NSURLRequest? { + var URLRequest: NSURLRequest? { switch self { case .ReadAuthenticatedUser(_): return request() diff --git a/OctoKitTests/UserTests.swift b/OctoKitTests/UserTests.swift index 1cb0b74e..c44565f4 100644 --- a/OctoKitTests/UserTests.swift +++ b/OctoKitTests/UserTests.swift @@ -1,5 +1,5 @@ import XCTest -import OctoKit +@testable import OctoKit import Nocilla class UserTests: XCTestCase { From b570aa31c74f79ab575399c3203628269b044e4b Mon Sep 17 00:00:00 2001 From: Nate West Date: Tue, 24 Nov 2015 12:21:19 -0500 Subject: [PATCH 021/302] Privatize StarsRouter --- OctoKit/Stars.swift | 14 +++++++------- OctoKitTests/StarsTests.swift | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/OctoKit/Stars.swift b/OctoKit/Stars.swift index 206b3f53..20ca2969 100644 --- a/OctoKit/Stars.swift +++ b/OctoKit/Stars.swift @@ -31,25 +31,25 @@ public extension Octokit { } } -public enum StarsRouter: Router { +enum StarsRouter: Router { case ReadAuthenticatedStars(Configuration) case ReadStars(String, Configuration) - public var method: HTTPMethod { + var method: HTTPMethod { return .GET } - public var configuration: Configuration { + var configuration: Configuration { switch self { case .ReadAuthenticatedStars(let config): return config case .ReadStars(_, let config): return config } } - public var encoding: HTTPEncoding { + var encoding: HTTPEncoding { return .URL } - public var path: String { + var path: String { switch self { case .ReadAuthenticatedStars: return "user/starred" @@ -58,11 +58,11 @@ public enum StarsRouter: Router { } } - public var params: [String: String] { + var params: [String: String] { return [:] } - public var URLRequest: NSURLRequest? { + var URLRequest: NSURLRequest? { return request() } } diff --git a/OctoKitTests/StarsTests.swift b/OctoKitTests/StarsTests.swift index 898fc0ab..db85b839 100644 --- a/OctoKitTests/StarsTests.swift +++ b/OctoKitTests/StarsTests.swift @@ -1,5 +1,5 @@ import XCTest -import OctoKit +@testable import OctoKit import Nocilla class StarsTests: XCTestCase { From 35a15397e7a833e501940598a455c4865c37084e Mon Sep 17 00:00:00 2001 From: Piet Brauer Date: Wed, 25 Nov 2015 09:33:28 +0700 Subject: [PATCH 022/302] Add some copy changes --- OctoKit.swift.podspec | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/OctoKit.swift.podspec b/OctoKit.swift.podspec index 9d757ac5..4a35b3ca 100644 --- a/OctoKit.swift.podspec +++ b/OctoKit.swift.podspec @@ -1,12 +1,11 @@ Pod::Spec.new do |s| s.name = "OctoKit.swift" s.version = "0.4.0" - s.summary = "Swift version of the Octokit family" + s.summary = "A Swift API Client for GitHub and GitHub Enterprise" s.description = <<-DESC - You are looking at the Swift port of the - Octokit family. This is very unofficial and not maintained - by Github. - DESC + You are looking at the A Swift API Client for GitHub and GitHub Enterprise. + This is very unofficial and not maintained by Github. + DESC s.homepage = "https://github.com/nerdishbynature/octokit.swift" s.license = { :type => "MIT", :file => "LICENSE" } s.author = { "Piet Brauer" => "piet@nerdishbynature.com" } From f966f67ff080b9276655830fa0de80e389876a0b Mon Sep 17 00:00:00 2001 From: Nate West Date: Wed, 25 Nov 2015 08:03:04 -0500 Subject: [PATCH 023/302] Adjust indentation --- OctoKit/Follow.swift | 36 ++++++++++++++++++------------------ OctoKit/Repositories.swift | 26 +++++++++++++------------- OctoKit/Stars.swift | 18 +++++++++--------- OctoKit/Time.swift | 22 +++++++++++----------- OctoKit/User.swift | 18 +++++++++--------- 5 files changed, 60 insertions(+), 60 deletions(-) diff --git a/OctoKit/Follow.swift b/OctoKit/Follow.swift index 0bd6e10b..9bb58fa9 100644 --- a/OctoKit/Follow.swift +++ b/OctoKit/Follow.swift @@ -3,10 +3,10 @@ import RequestKit public extension Octokit { -/** - Fetches the followers of the authenticated user - - parameter completion: Callback for the outcome of the fetch. -*/ + /** + Fetches the followers of the authenticated user + - parameter completion: Callback for the outcome of the fetch. + */ public func myFollowers(completion: (response: Response<[User]>) -> Void) { let router = FollowRouter.ReadAuthenticatedFollowers(configuration) router.loadJSON([[String: AnyObject]].self) { json, error in @@ -21,11 +21,11 @@ public extension Octokit { } } -/** - Fetches the followers of a user - - parameter name: Name of the user - - parameter completion: Callback for the outcome of the fetch. -*/ + /** + Fetches the followers of a user + - parameter name: Name of the user + - parameter completion: Callback for the outcome of the fetch. + */ public func followers(name: String, completion: (response: Response<[User]>) -> Void) { let router = FollowRouter.ReadFollowers(name, configuration) router.loadJSON([[String: AnyObject]].self) { json, error in @@ -40,10 +40,10 @@ public extension Octokit { } } -/** - Fetches the users following the authenticated user - - parameter completion: Callback for the outcome of the fetch. -*/ + /** + Fetches the users following the authenticated user + - parameter completion: Callback for the outcome of the fetch. + */ public func myFollowing(completion: (response: Response<[User]>) -> Void) { let router = FollowRouter.ReadAuthenticatedFollowing(configuration) router.loadJSON([[String: AnyObject]].self) { json, error in @@ -58,11 +58,11 @@ public extension Octokit { } } -/** - Fetches the users following a user - - parameter name: The name of the user - - parameter completion: Callback for the outcome of the fetch. -*/ + /** + Fetches the users following a user + - parameter name: The name of the user + - parameter completion: Callback for the outcome of the fetch. + */ public func following(name: String, completion: (response: Response<[User]>) -> Void) { let router = FollowRouter.ReadFollowing(name, configuration) router.loadJSON([[String: AnyObject]].self) { json, error in diff --git a/OctoKit/Repositories.swift b/OctoKit/Repositories.swift index bdcdce61..b9f041b8 100644 --- a/OctoKit/Repositories.swift +++ b/OctoKit/Repositories.swift @@ -45,13 +45,13 @@ import RequestKit public extension Octokit { -/** - Fetches the Repositories for a user or organization - - parameter owner: The user or organization that owns the repositories. If `nil`, fetches repositories for the authenticated user. - - parameter page: Current page for repository pagination. `1` by default. - - parameter perPage: Number of repositories per page. `100` by default. - - parameter completion: Callback for the outcome of the fetch. -*/ + /** + Fetches the Repositories for a user or organization + - parameter owner: The user or organization that owns the repositories. If `nil`, fetches repositories for the authenticated user. + - parameter page: Current page for repository pagination. `1` by default. + - parameter perPage: Number of repositories per page. `100` by default. + - parameter completion: Callback for the outcome of the fetch. + */ public func repositories(owner: String? = nil, page: String = "1", perPage: String = "100", completion: (response: Response<[Repository]>) -> Void) { let router = (owner != nil) ? RepositoryRouter.ReadRepositories(configuration, owner!, page, perPage) @@ -68,12 +68,12 @@ public extension Octokit { } } -/** - Fetches a repository for a user or organization - - parameter owner: The user or organization that owns the repositories. - - parameter name: The name of the repository to fetch. - - parameter completion: Callback for the outcome of the fetch. -*/ + /** + Fetches a repository for a user or organization + - parameter owner: The user or organization that owns the repositories. + - parameter name: The name of the repository to fetch. + - parameter completion: Callback for the outcome of the fetch. + */ public func repository(owner: String, name: String, completion: (response: Response) -> Void) { let router = RepositoryRouter.ReadRepository(configuration, owner, name) router.loadJSON([String: AnyObject].self) { json, error in diff --git a/OctoKit/Stars.swift b/OctoKit/Stars.swift index 3e67effa..e53bc357 100644 --- a/OctoKit/Stars.swift +++ b/OctoKit/Stars.swift @@ -3,11 +3,11 @@ import RequestKit public extension Octokit { -/** - Fetches all the starred repositories for a user - - parameter name: The user who starred repositories. - - parameter completion: Callback for the outcome of the fetch. -*/ + /** + Fetches all the starred repositories for a user + - parameter name: The user who starred repositories. + - parameter completion: Callback for the outcome of the fetch. + */ public func stars(name: String, completion: (response: Response<[Repository]>) -> Void) { let router = StarsRouter.ReadStars(name, configuration) router.loadJSON([[String: AnyObject]].self) { json, error in @@ -22,10 +22,10 @@ public extension Octokit { } } -/** - Fetches all the starred repositories for the authenticated user - - parameter completion: Callback for the outcome of the fetch. -*/ + /** + Fetches all the starred repositories for the authenticated user + - parameter completion: Callback for the outcome of the fetch. + */ public func myStars(completion: (response: Response<[Repository]>) -> Void) { let router = StarsRouter.ReadAuthenticatedStars(configuration) router.loadJSON([[String: AnyObject]].self) { json, error in diff --git a/OctoKit/Time.swift b/OctoKit/Time.swift index c32da4a1..6220f7e7 100644 --- a/OctoKit/Time.swift +++ b/OctoKit/Time.swift @@ -2,12 +2,12 @@ import Foundation struct Time { -/** - A date formatter for RFC 3339 style timestamps. Uses POSIX locale and GMT timezone so that date values are parsed as absolutes. - - [https://tools.ietf.org/html/rfc3339](https://tools.ietf.org/html/rfc3339) - - [https://developer.apple.com/library/mac/qa/qa1480/_index.html](https://developer.apple.com/library/mac/qa/qa1480/_index.html) - - [https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/DataFormatting/Articles/dfDateFormatting10_4.html](https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/DataFormatting/Articles/dfDateFormatting10_4.html) -*/ + /** + A date formatter for RFC 3339 style timestamps. Uses POSIX locale and GMT timezone so that date values are parsed as absolutes. + - [https://tools.ietf.org/html/rfc3339](https://tools.ietf.org/html/rfc3339) + - [https://developer.apple.com/library/mac/qa/qa1480/_index.html](https://developer.apple.com/library/mac/qa/qa1480/_index.html) + - [https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/DataFormatting/Articles/dfDateFormatting10_4.html](https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/DataFormatting/Articles/dfDateFormatting10_4.html) + */ private static var rfc3339DateFormatter: NSDateFormatter = { let formatter = NSDateFormatter() formatter.dateFormat = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'" @@ -16,11 +16,11 @@ struct Time { return formatter }() -/** - Parses RFC 3339 date strings into NSDate - - parameter string: The string representation of the date - - returns: An `NSDate` with a successful parse, otherwise `nil` -*/ + /** + Parses RFC 3339 date strings into NSDate + - parameter string: The string representation of the date + - returns: An `NSDate` with a successful parse, otherwise `nil` + */ static func rfc3339Date(string: String?) -> NSDate? { guard let string = string else { return nil } return Time.rfc3339DateFormatter.dateFromString(string) diff --git a/OctoKit/User.swift b/OctoKit/User.swift index 33ef8a90..a38043df 100644 --- a/OctoKit/User.swift +++ b/OctoKit/User.swift @@ -43,11 +43,11 @@ import RequestKit public extension Octokit { -/** - Fetches a user or organization - - parameter name: The name of the user or organization. - - parameter completion: Callback for the outcome of the fetch. -*/ + /** + Fetches a user or organization + - parameter name: The name of the user or organization. + - parameter completion: Callback for the outcome of the fetch. + */ public func user(name: String, completion: (response: Response) -> Void) { let router = UserRouter.ReadUser(name, self.configuration) router.loadJSON([String: AnyObject].self) { json, error in @@ -62,10 +62,10 @@ public extension Octokit { } } -/** - Fetches the authenticated user - - parameter completion: Callback for the outcome of the fetch. -*/ + /** + Fetches the authenticated user + - parameter completion: Callback for the outcome of the fetch. + */ public func me(completion: (response: Response) -> Void) { let router = UserRouter.ReadAuthenticatedUser(self.configuration) router.loadJSON([String: AnyObject].self) { json, error in From 0780fbd0987f7b4a5b485b2e18b6b02ff8fee886 Mon Sep 17 00:00:00 2001 From: Piet Brauer Date: Thu, 26 Nov 2015 09:18:18 +0700 Subject: [PATCH 024/302] Bump version to 0.5.0 --- OctoKit.swift.podspec | 2 +- OctoKit/Info.plist | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/OctoKit.swift.podspec b/OctoKit.swift.podspec index 4a35b3ca..e22808e9 100644 --- a/OctoKit.swift.podspec +++ b/OctoKit.swift.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "OctoKit.swift" - s.version = "0.4.0" + s.version = "0.5.0" s.summary = "A Swift API Client for GitHub and GitHub Enterprise" s.description = <<-DESC You are looking at the A Swift API Client for GitHub and GitHub Enterprise. diff --git a/OctoKit/Info.plist b/OctoKit/Info.plist index d3de8eef..288c341b 100644 --- a/OctoKit/Info.plist +++ b/OctoKit/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 1.0 + 0.5.0 CFBundleSignature ???? CFBundleVersion From 98d9a9bc78c18d796b7725080743aeeff7ae8bc0 Mon Sep 17 00:00:00 2001 From: Piet Brauer Date: Fri, 11 Dec 2015 10:20:51 +0700 Subject: [PATCH 025/302] Update RequestKit --- Cartfile.resolved | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cartfile.resolved b/Cartfile.resolved index 9f794129..19917c7e 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1,2 +1,2 @@ github "nerdishbynature/Nocilla" "0.10.0" -github "nerdishbynature/RequestKit" "0.1.0" +github "nerdishbynature/RequestKit" "0.1.1" From 83bdb06c5dbcd4fd01299c9bc7ddebf554952e0b Mon Sep 17 00:00:00 2001 From: Nate West Date: Fri, 11 Dec 2015 09:22:55 -0500 Subject: [PATCH 026/302] Update RequestKit version --- OctoKit.swift.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OctoKit.swift.podspec b/OctoKit.swift.podspec index e22808e9..295663f2 100644 --- a/OctoKit.swift.podspec +++ b/OctoKit.swift.podspec @@ -12,7 +12,7 @@ Pod::Spec.new do |s| s.source = { :git => "https://github.com/nerdishbynature/octokit.swift.git", :tag => s.version.to_s } s.social_media_url = "https://twitter.com/pietbrauer" s.module_name = "Octokit" - s.dependency "NBNRequestKit", "~> 0.1.0" + s.dependency "NBNRequestKit", "~> 0.1.1" s.platform = :ios, "8.0" s.requires_arc = true s.source_files = "OctoKit/*.swift" From 46936fbdf605e4497d316f69f16d400204608df0 Mon Sep 17 00:00:00 2001 From: Piet Brauer Date: Sat, 12 Dec 2015 16:33:34 +0700 Subject: [PATCH 027/302] Update RequestKit --- Cartfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cartfile b/Cartfile index 39ba9603..33db47c0 100644 --- a/Cartfile +++ b/Cartfile @@ -1 +1 @@ -github "nerdishbynature/RequestKit" +github "nerdishbynature/RequestKit" "dammit" From 17cef5bb49bf3e69009c5488fb5d231414f74d8a Mon Sep 17 00:00:00 2001 From: Piet Brauer Date: Sat, 12 Dec 2015 16:44:21 +0700 Subject: [PATCH 028/302] Update 4 realz --- Cartfile.resolved | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cartfile.resolved b/Cartfile.resolved index 19917c7e..1ac77486 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1,2 +1,2 @@ github "nerdishbynature/Nocilla" "0.10.0" -github "nerdishbynature/RequestKit" "0.1.1" +github "nerdishbynature/RequestKit" "9f5c1b38e7f7ae086779d7b1353c473d7a9f4fe6" From 2e82893d0df30db325e6dbbfb72738b815b7b118 Mon Sep 17 00:00:00 2001 From: Piet Brauer Date: Sat, 12 Dec 2015 16:54:15 +0700 Subject: [PATCH 029/302] Fix tests --- OctoKitTests/ConfigurationTests.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OctoKitTests/ConfigurationTests.swift b/OctoKitTests/ConfigurationTests.swift index a9612572..2aafcf1e 100644 --- a/OctoKitTests/ConfigurationTests.swift +++ b/OctoKitTests/ConfigurationTests.swift @@ -44,7 +44,7 @@ class ConfigurationTests: XCTestCase { func testAuthorizeURLRequest() { let config = OAuthConfiguration(token: "12345", secret: "6789", scopes: ["repo", "read:org"]) let request = OAuthRouter.Authorize(config).URLRequest - let expected = NSURL(string: "https://github.com/login/oauth/authorize?client_id=12345&scope=repo,read%3Aorg")! + let expected = NSURL(string: "https://github.com/login/oauth/authorize?client_id=12345&scope=repo%2Cread%3Aorg")! XCTAssertEqual(request!.URL!, expected) } From 56552ae5558340350de3273abe7ecb89311145a1 Mon Sep 17 00:00:00 2001 From: Piet Brauer Date: Sun, 13 Dec 2015 10:57:13 +0700 Subject: [PATCH 030/302] Use RequestKit 0.2.1 --- Cartfile | 2 +- Cartfile.resolved | 2 +- OctoKit.swift.podspec | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cartfile b/Cartfile index 33db47c0..f80aaa58 100644 --- a/Cartfile +++ b/Cartfile @@ -1 +1 @@ -github "nerdishbynature/RequestKit" "dammit" +github "nerdishbynature/RequestKit" == 0.2.1 diff --git a/Cartfile.resolved b/Cartfile.resolved index 1ac77486..c9bfbb7b 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1,2 +1,2 @@ github "nerdishbynature/Nocilla" "0.10.0" -github "nerdishbynature/RequestKit" "9f5c1b38e7f7ae086779d7b1353c473d7a9f4fe6" +github "nerdishbynature/RequestKit" "0.2.1" diff --git a/OctoKit.swift.podspec b/OctoKit.swift.podspec index e22808e9..fa7a8443 100644 --- a/OctoKit.swift.podspec +++ b/OctoKit.swift.podspec @@ -12,7 +12,7 @@ Pod::Spec.new do |s| s.source = { :git => "https://github.com/nerdishbynature/octokit.swift.git", :tag => s.version.to_s } s.social_media_url = "https://twitter.com/pietbrauer" s.module_name = "Octokit" - s.dependency "NBNRequestKit", "~> 0.1.0" + s.dependency "NBNRequestKit", "~> 0.2.1" s.platform = :ios, "8.0" s.requires_arc = true s.source_files = "OctoKit/*.swift" From 37df4a2c4255a298e31193f731665537b2acd012 Mon Sep 17 00:00:00 2001 From: Piet Brauer Date: Sun, 13 Dec 2015 12:53:33 +0700 Subject: [PATCH 031/302] Bump version --- OctoKit.swift.podspec | 2 +- OctoKit/Info.plist | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/OctoKit.swift.podspec b/OctoKit.swift.podspec index fa7a8443..f3c95500 100644 --- a/OctoKit.swift.podspec +++ b/OctoKit.swift.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "OctoKit.swift" - s.version = "0.5.0" + s.version = "0.5.1" s.summary = "A Swift API Client for GitHub and GitHub Enterprise" s.description = <<-DESC You are looking at the A Swift API Client for GitHub and GitHub Enterprise. diff --git a/OctoKit/Info.plist b/OctoKit/Info.plist index 288c341b..504fc36a 100644 --- a/OctoKit/Info.plist +++ b/OctoKit/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 0.5.0 + 0.5.1 CFBundleSignature ???? CFBundleVersion From 9458fedd305cb323b450a52c95680943703d7556 Mon Sep 17 00:00:00 2001 From: Piet Brauer Date: Mon, 22 Feb 2016 11:19:56 +0800 Subject: [PATCH 032/302] Add fastlane setup --- .travis.yml | 30 +- Gemfile | 4 +- Gemfile.lock | 281 ++++++++++- Makefile | 12 +- fastlane/.env | 4 + fastlane/.env.default | 15 + fastlane/.env.deploy | 14 + fastlane/.env.ios92 | 2 + fastlane/.env.ios93_xcode73 | 3 + fastlane/.env.osx | 6 + fastlane/.env.tvos91 | 6 + fastlane/Fastfile | 4 + fastlane/README.md | 196 ++++++++ fastlane/report.xml | 21 + fastlane/test-output/report.html | 779 ++++++++++++++++++++++++++++++ fastlane/test-output/report.junit | 69 +++ 16 files changed, 1417 insertions(+), 29 deletions(-) create mode 100644 fastlane/.env create mode 100644 fastlane/.env.default create mode 100644 fastlane/.env.deploy create mode 100644 fastlane/.env.ios92 create mode 100644 fastlane/.env.ios93_xcode73 create mode 100644 fastlane/.env.osx create mode 100644 fastlane/.env.tvos91 create mode 100644 fastlane/Fastfile create mode 100644 fastlane/README.md create mode 100644 fastlane/report.xml create mode 100644 fastlane/test-output/report.html create mode 100644 fastlane/test-output/report.junit diff --git a/.travis.yml b/.travis.yml index 751d2610..17a4dbbf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,30 @@ -osx_image: xcode7.1 language: objective-c +osx_image: xcode7.1 +sudo: false +env: + global: + - LC_CTYPE=en_US.UTF-8 + - LANG=en_US.UTF-8 + - FASTLANE_LANE=ci_commit +matrix: + include: + - osx_image: xcode7.2 + env: FASTLANE_LANE=code_coverage FASTLANE_ENV=default + - osx_image: xcode7.2 + env: FASTLANE_ENV=ios92 + - osx_image: xcode7.2 + env: FASTLANE_ENV=tvos91 + - osx_image: xcode7.2 + env: FASTLANE_ENV=osx + - osx_image: xcode7.3 + env: FASTLANE_ENV=ios93_xcode73 before_install: - - make install + - make install script: - - make test + - set -o pipefail + - bundle exec fastlane $FASTLANE_LANE configuration:Debug --env $FASTLANE_ENV + - bundle exec fastlane $FASTLANE_LANE configuration:Release --env $FASTLANE_ENV after_success: - - make post_coverage + - if [ "$FASTLANE_LANE" == "code_coverage" ]; then + make post_coverage; + fi diff --git a/Gemfile b/Gemfile index 665536c2..ef43960b 100644 --- a/Gemfile +++ b/Gemfile @@ -1,3 +1,5 @@ source "https://rubygems.org" -gem "slather", git: "https://github.com/nerdishbynature/slather.git", branch: "feature-profdata" +gem "slather", "~> 2.0" +gem "fastlane" +gem "cocoapods" diff --git a/Gemfile.lock b/Gemfile.lock index ca2dea41..4bf68f56 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,44 +1,289 @@ -GIT - remote: https://github.com/nerdishbynature/slather.git - revision: fd90e5e76e2a6422a9c4a4d43d0104529659f3b3 - branch: feature-profdata - specs: - slather (1.8.1) - clamp (~> 0.6) - nokogiri (~> 1.6.3) - xcodeproj (~> 0.26.2) - GEM remote: https://rubygems.org/ specs: - activesupport (4.2.5) + activesupport (4.2.5.1) i18n (~> 0.7) json (~> 1.7, >= 1.7.7) minitest (~> 5.1) thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) + addressable (2.3.8) + babosa (1.0.2) + cert (1.3.0) + fastlane_core (>= 0.29.1, < 1.0.0) + spaceship (>= 0.16.0, < 1.0.0) claide (0.9.1) clamp (0.6.5) + cocoapods (0.39.0) + activesupport (>= 4.0.2) + claide (~> 0.9.1) + cocoapods-core (= 0.39.0) + cocoapods-downloader (~> 0.9.3) + cocoapods-plugins (~> 0.4.2) + cocoapods-search (~> 0.1.0) + cocoapods-stats (~> 0.6.2) + cocoapods-trunk (~> 0.6.4) + cocoapods-try (~> 0.5.1) + colored (~> 1.2) + escape (~> 0.0.4) + molinillo (~> 0.4.0) + nap (~> 1.0) + xcodeproj (~> 0.28.2) + cocoapods-core (0.39.0) + activesupport (>= 4.0.2) + fuzzy_match (~> 2.0.4) + nap (~> 1.0) + cocoapods-downloader (0.9.3) + cocoapods-plugins (0.4.2) + nap + cocoapods-search (0.1.0) + cocoapods-stats (0.6.2) + cocoapods-trunk (0.6.4) + nap (>= 0.8, < 2.0) + netrc (= 0.7.8) + cocoapods-try (0.5.1) + coderay (1.1.1) colored (1.2) + commander (4.3.5) + highline (~> 1.7.2) + credentials_manager (0.15.0) + colored + commander (>= 4.3.5) + highline (>= 1.7.1) + security + deliver (1.10.3) + credentials_manager (>= 0.12.0, < 1.0.0) + fastimage (~> 1.6) + fastlane_core (>= 0.36.4, < 1.0.0) + plist (~> 3.1.0) + spaceship (>= 0.19.0, <= 1.0.0) + domain_name (0.5.20160128) + unf (>= 0.0.5, < 1.0.0) + dotenv (2.1.0) + escape (0.0.4) + excon (0.45.4) + faraday (0.9.2) + multipart-post (>= 1.2, < 3) + faraday-cookie_jar (0.0.6) + faraday (>= 0.7.4) + http-cookie (~> 1.0.0) + faraday_middleware (0.10.0) + faraday (>= 0.7.4, < 0.10) + fastimage (1.6.8) + addressable (~> 2.3, >= 2.3.5) + fastlane (1.61.0) + addressable (~> 2.3.8) + cert (>= 1.3.0, < 2.0.0) + credentials_manager (>= 0.15.0, < 1.0.0) + deliver (>= 1.10.1, < 2.0.0) + fastlane_core (>= 0.36.5, < 1.0.0) + frameit (>= 2.4.1, < 3.0.0) + gym (>= 1.6.1, < 2.0.0) + krausefx-shenzhen (>= 0.14.7) + match (>= 0.3.0, < 1.0.0) + pem (>= 1.2.0, < 2.0.0) + pilot (>= 1.3.0, < 2.0.0) + plist (~> 3.1.0) + produce (>= 1.1.0, < 2.0.0) + scan (>= 0.5.0, < 1.0.0) + screengrab (>= 0.2.0, < 1.0.0) + sigh (>= 1.3.1, < 2.0.0) + slack-notifier (~> 1.3) + snapshot (>= 1.7.0, < 2.0.0) + spaceship (>= 0.19.4, < 1.0.0) + supply (>= 0.4.0, < 1.0.0) + terminal-notifier (~> 1.6.2) + terminal-table (~> 1.4.5) + xcodeproj (>= 0.20, < 1.0.0) + xcpretty (>= 0.2.1) + fastlane_core (0.36.6) + babosa + colored + commander (= 4.3.5) + credentials_manager (>= 0.11.0, < 1.0.0) + excon (~> 0.45.0) + highline (>= 1.7.2) + json + multi_json + plist (~> 3.1) + rubyzip (~> 1.1.6) + sentry-raven (~> 0.15) + terminal-table (~> 1.4.5) + frameit (2.4.1) + deliver (> 0.3) + fastimage (~> 1.6.3) + fastlane_core (>= 0.16.0, < 1.0.0) + mini_magick (~> 4.0.2) + fuzzy_match (2.0.4) + google-api-client (0.9.2) + activesupport (>= 3.2) + addressable (~> 2.3) + googleauth (~> 0.5) + httpclient (~> 2.7) + hurley (~> 0.1) + memoist (~> 0.11) + mime-types (>= 1.6) + multi_json (~> 1.11) + representable (~> 2.3.0) + retriable (~> 2.0) + thor (~> 0.19) + googleauth (0.5.1) + faraday (~> 0.9) + jwt (~> 1.4) + logging (~> 2.0) + memoist (~> 0.12) + multi_json (~> 1.11) + os (~> 0.9) + signet (~> 0.7) + gym (1.6.1) + fastlane_core (>= 0.36.1, < 1.0.0) + plist + rubyzip (>= 1.1.7) + terminal-table + xcpretty (>= 0.2.1) + highline (1.7.8) + http-cookie (1.0.2) + domain_name (~> 0.5) + httpclient (2.7.1) + hurley (0.2) i18n (0.7.0) json (1.8.3) - mini_portile (0.6.2) - minitest (5.8.3) - nokogiri (1.6.6.4) - mini_portile (~> 0.6.0) + jwt (1.5.2) + krausefx-shenzhen (0.14.7) + commander (~> 4.3) + dotenv (>= 0.7) + faraday (~> 0.9) + faraday_middleware (~> 0.9) + highline (>= 1.7.2) + json (~> 1.8) + net-sftp (~> 2.1.2) + plist (~> 3.1.0) + rubyzip (~> 1.1) + security (~> 0.1.3) + terminal-table (~> 1.4.5) + little-plugger (1.1.4) + logging (2.0.0) + little-plugger (~> 1.1) + multi_json (~> 1.10) + match (0.3.0) + cert (>= 1.2.8, < 2.0.0) + credentials_manager (>= 0.13.0, < 1.0.0) + fastlane_core (>= 0.36.1, < 1.0.0) + security + sigh (>= 1.2.2, < 2.0.0) + spaceship (>= 0.18.1, < 1.0.0) + memoist (0.14.0) + method_source (0.8.2) + mime-types (3.0) + mime-types-data (~> 3.2015) + mime-types-data (3.2015.1120) + mini_magick (4.0.4) + mini_portile2 (2.0.0) + minitest (5.8.4) + molinillo (0.4.3) + multi_json (1.11.2) + multi_xml (0.5.5) + multipart-post (2.0.0) + nap (1.1.0) + net-sftp (2.1.2) + net-ssh (>= 2.6.5) + net-ssh (3.0.2) + netrc (0.7.8) + nokogiri (1.6.7.2) + mini_portile2 (~> 2.0.0.rc2) + os (0.9.6) + pem (1.2.0) + fastlane_core (>= 0.36.1, < 1.0.0) + spaceship (>= 0.19.3, < 1.0.0) + pilot (1.4.1) + credentials_manager (>= 0.3.0) + fastlane_core (>= 0.36.5, < 1.0.0) + spaceship (>= 0.20.0, < 1.0.0) + terminal-table (~> 1.4.5) + plist (3.1.0) + produce (1.1.1) + fastlane_core (>= 0.30.0, < 1.0.0) + spaceship (>= 0.16.0) + pry (0.10.3) + coderay (~> 1.1.0) + method_source (~> 0.8.1) + slop (~> 3.4) + representable (2.3.0) + uber (~> 0.0.7) + retriable (2.1.0) + rouge (1.10.1) + rubyzip (1.1.7) + scan (0.5.0) + fastlane_core (>= 0.36.1, < 1.0.0) + slack-notifier (~> 1.3) + terminal-table + xcpretty (>= 0.2.1) + xcpretty-travis-formatter (>= 0.0.3) + screengrab (0.2.0) + fastlane_core (>= 0.36.1, < 1.0.0) + security (0.1.3) + sentry-raven (0.15.5) + faraday (>= 0.7.6) + sigh (1.3.1) + fastlane_core (>= 0.36.1, < 1.0.0) + plist (~> 3.1) + spaceship (>= 0.12.3) + signet (0.7.2) + addressable (~> 2.3) + faraday (~> 0.9) + jwt (~> 1.5) + multi_json (~> 1.10) + slack-notifier (1.5.1) + slather (2.0.0) + clamp (~> 0.6) + nokogiri (~> 1.6.3) + xcodeproj (>= 0.28.2, < 1.1.0) + slop (3.6.0) + snapshot (1.8.0) + fastimage (~> 1.6.3) + fastlane_core (>= 0.36.1, < 1.0.0) + plist (~> 3.1.0) + xcpretty (>= 0.2.1) + spaceship (0.21.0) + colored + credentials_manager (>= 0.9.0) + faraday (~> 0.9) + faraday-cookie_jar (~> 0.0.6) + faraday_middleware (~> 0.9) + fastimage (~> 1.6) + multi_xml (~> 0.5) + plist (~> 3.1) + pry + supply (0.4.0) + credentials_manager (>= 0.15.0) + fastlane_core (>= 0.35.0) + google-api-client (~> 0.9.1) + terminal-notifier (1.6.3) + terminal-table (1.4.5) + thor (0.19.1) thread_safe (0.3.5) tzinfo (1.2.2) thread_safe (~> 0.1) - xcodeproj (0.26.3) + uber (0.0.15) + unf (0.1.4) + unf_ext + unf_ext (0.0.7.2) + xcodeproj (0.28.2) activesupport (>= 3) claide (~> 0.9.1) colored (~> 1.2) + xcpretty (0.2.2) + rouge (~> 1.8) + xcpretty-travis-formatter (0.0.4) + xcpretty (~> 0.2, >= 0.0.7) PLATFORMS ruby DEPENDENCIES - slather! + cocoapods + fastlane + slather (~> 2.0) BUNDLED WITH - 1.10.6 + 1.11.2 diff --git a/Makefile b/Makefile index 77d382c0..85fad3f7 100644 --- a/Makefile +++ b/Makefile @@ -1,14 +1,14 @@ +SHA=$(shell git rev-parse HEAD) +BRANCH=$(shell git name-rev --name-only HEAD) + install: - brew update || brew update brew install carthage - brew install python - pip install codecov carthage bootstrap test: - pod lib lint --quick - set -o pipefail && xcodebuild clean test -scheme OctoKit -sdk iphonesimulator ONLY_ACTIVE_ARCH=YES -enableCodeCoverage YES | xcpretty -c + bundle exec fastlane code_coverage configuration:Debug --env default post_coverage: bundle exec slather coverage --input-format profdata -x --ignore "../**/*/Xcode*" --ignore "Carthage/**" --output-directory slather-report --scheme OctoKit Octokit.xcodeproj - codecov -f slather-report/cobertura.xml + curl -X POST -d @slather-report/cobertura.xml "https://codecov.io/upload/v2?token="$(CODECOV_TOKEN)"&commit="$(SHA)"&branch="$(BRANCH)"&job="$(TRAVIS_BUILD_NUMBER) + diff --git a/fastlane/.env b/fastlane/.env new file mode 100644 index 00000000..d1997e80 --- /dev/null +++ b/fastlane/.env @@ -0,0 +1,4 @@ +AF_IOS_FRAMEWORK_SCHEME="OctoKit" +AF_TVOS_FRAMEWORK_SCHEME="OctoKit tvOS" +AF_OSX_FRAMEWORK_SCHEME="OctoKit Mac" + diff --git a/fastlane/.env.default b/fastlane/.env.default new file mode 100644 index 00000000..acb1c8fd --- /dev/null +++ b/fastlane/.env.default @@ -0,0 +1,15 @@ +AF_IOS_SDK=iphonesimulator9.2 +AF_MAC_SDK=macosx10.11 +AF_TVOS_SDK=appletvsimulator9.1 + +AF_CONFIGURATION=Release + +SCAN_SCHEME=$AF_IOS_FRAMEWORK_SCHEME +SCAN_DESTINATION="OS=9.2,name=iPhone 6s" +SCAN_SDK=$AF_IOS_SDK +SCAN_OUTPUT_DIRECTORY=fastlane/test-output +DEPLOY_PODSPEC=OctoKit.swift.podspec + +EXAMPLE_WORKSPACE=$AF_WORKSPACE +EXAMPLE_SCHEME=$AF_IOS_EXAMPLE_SCHEME +EXAMPLE_DESTINATION=$SCAN_DESTINATION diff --git a/fastlane/.env.deploy b/fastlane/.env.deploy new file mode 100644 index 00000000..768a33e5 --- /dev/null +++ b/fastlane/.env.deploy @@ -0,0 +1,14 @@ +DEPLOY_BRANCH=master +DEPLOY_PLIST_PATH=Framework/Info.plist +DEPLOY_PODSPEC=Octokit.swift.podspec +DEPLOY_REMOTE=origin + +DEPLOY_CHANGELOG_PATH=CHANGELOG.md +DEPLOY_CHANGELOG_DELIMITER=--- + +# Used for CHANGELOG Generation and Github Release Management +GITHUB_OWNER=nerdishbynature +GITHUB_REPOSITORY=RequestKit +# CI Should Provide GITHUB_API_TOKEN + +CARTHAGE_FRAMEWORK_NAME=OctoKit diff --git a/fastlane/.env.ios92 b/fastlane/.env.ios92 new file mode 100644 index 00000000..67e5e829 --- /dev/null +++ b/fastlane/.env.ios92 @@ -0,0 +1,2 @@ +SCAN_DESTINATION="OS=9.2,name=iPhone 6s" +EXAMPLE_DESTINATION=$SCAN_DESTINATION \ No newline at end of file diff --git a/fastlane/.env.ios93_xcode73 b/fastlane/.env.ios93_xcode73 new file mode 100644 index 00000000..b0516eb0 --- /dev/null +++ b/fastlane/.env.ios93_xcode73 @@ -0,0 +1,3 @@ +SCAN_DESTINATION="OS=9.3,name=iPhone 6s" +EXAMPLE_DESTINATION=$SCAN_DESTINATION +SCAN_SDK=iphonesimulator9.3 \ No newline at end of file diff --git a/fastlane/.env.osx b/fastlane/.env.osx new file mode 100644 index 00000000..d56e363c --- /dev/null +++ b/fastlane/.env.osx @@ -0,0 +1,6 @@ +SCAN_SCHEME=$AF_OSX_FRAMEWORK_SCHEME +SCAN_DESTINATION="arch=x86_64" +SCAN_SDK=$AF_OSX_SDK + +EXAMPLE_SCHEME=$AF_OSX_EXAMPLE_SCHEME +EXAMPLE_DESTINATION=$SCAN_DESTINATION \ No newline at end of file diff --git a/fastlane/.env.tvos91 b/fastlane/.env.tvos91 new file mode 100644 index 00000000..54cd02b3 --- /dev/null +++ b/fastlane/.env.tvos91 @@ -0,0 +1,6 @@ +SCAN_SCHEME=$AF_TVOS_FRAMEWORK_SCHEME +SCAN_DESTINATION="OS=9.1,name=Apple TV 1080p" +SCAN_SDK=$AF_TVOS_SDK + +EXAMPLE_SCHEME=$AF_TVOS_EXAMPLE_SCHEME +EXAMPLE_DESTINATION=$SCAN_DESTINATION \ No newline at end of file diff --git a/fastlane/Fastfile b/fastlane/Fastfile new file mode 100644 index 00000000..3e15f292 --- /dev/null +++ b/fastlane/Fastfile @@ -0,0 +1,4 @@ +import_from_git( + url: 'https://github.com/nerdishbynature/requestkit_fastlane.git', + branch: 'master' +) diff --git a/fastlane/README.md b/fastlane/README.md new file mode 100644 index 00000000..62b38ea6 --- /dev/null +++ b/fastlane/README.md @@ -0,0 +1,196 @@ +fastlane documentation +================ +# Installation +``` +sudo gem install fastlane +``` +# Available Actions +### ci_commit +``` +fastlane ci_commit +``` +Runs tests and builds example for the given environment + +The lane to run by ci on every commit This lanes calls the lanes `test_framework` and `build_example`. + +####Example: + +``` +fastlane ci_commit configuration:Debug --env ios91 +``` + +####Options + + * **`configuration`**: The build configuration to use. (`AF_CONFIGURATION`) + + +### test_framework +``` +fastlane test_framework +``` +Runs all tests for the given environment + +Set `scan` action environment variables to control test configuration + +####Example: + +``` +fastlane test_framework configuration:Debug --env ios91 +``` + +####Options + + * **`configuration`**: The build configuration to use. + + +### code_coverage +``` +fastlane code_coverage +``` +Produces code coverage information + +Set `scan` action environment variables to control test configuration + +####Example: + +``` +fastlane code_coverage configuration:Debug +``` + +####Options + + * **`configuration`**: The build configuration to use. The only supported configuration is the `Debug` configuration. + + +### prepare_framework_release +``` +fastlane prepare_framework_release +``` +Prepares the framework for release + +This lane should be run from your local machine, and will push a tag to the remote when finished. + + * Verifies the git branch is clean + + * Ensures the lane is running on the master branch + + * Verifies the Github milestone is ready for release + + * Pulls the remote to verify the latest the branch is up to date + + * Updates the version of the info plist path used by the framework + + * Updates the the version of the podspec + + * Generates a changelog based on the Github milestone + + * Updates the changelog file + + * Commits the changes + + * Pushes the commited branch + + * Creates a tag + + * Pushes the tag + +####Example: + +``` +fastlane prepare_framework_release version:3.0.0 --env deploy +``` + +####Options + +It is recommended to manage these options through a .env file. See `fastlane/.env.deploy` for an example. + + * **`version`** (required): The new version of the framework + + * **`allow_dirty_branch`**: Allows the git branch to be dirty before continuing. Defaults to false + + * **`remote`**: The name of the git remote. Defaults to `origin`. (`DEPLOY_REMOTE`) + + * **`allow_branch`**: The name of the branch to build from. Defaults to `master`. (`DEPLOY_BRANCH`) + + * **`skip_validate_github_milestone`**: Skips validating a Github milestone. Defaults to false + + * **`skip_git_pull`**: Skips pulling the git remote. Defaults to false + + * **`skip_plist_update`**: Skips updating the version of the info plist. Defaults to false + + * **`plist_path`**: The path of the plist file to update. (`DEPLOY_PLIST_PATH`) + + * **`skip_podspec_update`**: Skips updating the version of the podspec. Defaults to false + + * **`podspec`**: The path of the podspec file to update. (`DEPLOY_PODSPEC`) + + * **`skip_changelog`**: Skip generating a changelog. Defaults to false. + + * **`changelog_path`**: The path to the changelog file. (`DEPLOY_CHANGELOG_PATH`) + + * **`changelog_insert_delimiter`**: The delimiter to insert the changelog after. (`DEPLOY_CHANGELOG_DELIMITER`) + + +### complete_framework_release +``` +fastlane complete_framework_release +``` +Completes the framework release + +This lane should be from a CI machine, after the tests have passed on the tag build. This lane does the following: + + * Verifies the git branch is clean + + * Ensures the lane is running on the master branch + + * Pulls the remote to verify the latest the branch is up to date + + * Generates a changelog for the Github Release + + * Creates a Github Release + + * Builds Carthage Frameworks + + * Uploads Carthage Framework to Github Release + + * Pushes podspec to pod trunk + + * Lints the pod spec to ensure it is valid + + * Closes the associated Github milestone + +####Example: + +``` +fastlane complete_framework_release --env deploy +``` + +####Options + +It is recommended to manage these options through a .env file. See `fastlane/.env.deploy` for an example. + + * **`version`** (required): The new version of the framework. Defaults to the last tag in the repo + + * **`allow_dirty_branch`**: Allows the git branch to be dirty before continuing. Defaults to false + + * **`remote`**: The name of the git remote. Defaults to `origin`. (`DEPLOY_REMOTE`) + + * **`allow_branch`**: The name of the branch to build from. Defaults to `master`. (`DEPLOY_BRANCH`) + + * **`skip_github_release`**: Skips creating a Github release. Defaults to false + + * **`skip_carthage_framework`**: Skips creating a carthage framework. If building a swift framework, this should be disabled. Defaults to false. + + * **`skip_pod_push`**: Skips pushing the podspec to trunk. + + * **`skip_podspec_update`**: Skips updating the version of the podspec. Defaults to false + + * **`skip_closing_github_milestone`**: Skips closing the associated Github milestone. Defaults to false + + + +---- + +This README.md is auto-generated and will be re-generated every time to run [fastlane](https://fastlane.tools). +More information about fastlane can be found on [https://fastlane.tools](https://fastlane.tools). +The documentation of fastlane can be found on [GitHub](https://github.com/fastlane/fastlane). \ No newline at end of file diff --git a/fastlane/report.xml b/fastlane/report.xml new file mode 100644 index 00000000..713ff923 --- /dev/null +++ b/fastlane/report.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/fastlane/test-output/report.html b/fastlane/test-output/report.html new file mode 100644 index 00000000..d138586b --- /dev/null +++ b/fastlane/test-output/report.html @@ -0,0 +1,779 @@ + + + + + Test Results | xcpretty + + + + +
+
+

Test Results

+
+
+
+

50 tests

+ +
+
+ AllFailingPassing +
+
+
+
+ + +
+
+

OctoKitTests.ConfigurationTests

+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

0.120s

+ +

testAccessTokenFromResponse

+ +

0.267s

+ +

testAccessTokenURLRequest

+ +

0.018s

+ +

testAuthorizeURLRequest

+ +

0.004s

+ +

testEnterpriseTokenConfiguration

+ +

0.093s

+ +

testHandleOpenURL

+ +

0.003s

+ +

testOAuthConfiguration

+ +

0.002s

+ +

testOAuthTokenConfiguration

+ +

0.003s

+ +

testTokenConfiguration

+
+
+ + +
+
+

OctoKitTests.FollowTests

+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

0.005s

+ +

testFailToGetMyFollowers

+ +

0.006s

+ +

testFailToGetMyFollowing

+ +

0.005s

+ +

testFailToGetUsersFollowers

+ +

0.005s

+ +

testFailToGetUsersFollowing

+ +

0.024s

+ +

testGetMyFollowers

+ +

0.006s

+ +

testGetMyFollowing

+ +

0.006s

+ +

testGetUsersFollowers

+ +

0.005s

+ +

testGetUsersFollowing

+ +

0.003s

+ +

testReadingAuthenticatedUserFollowersURLRequest

+ +

0.003s

+ +

testReadingAuthenticatedUserFollowingURLRequest

+ +

0.002s

+ +

testReadingUserFollowersURLRequest

+ +

0.014s

+ +

testReadingUserFollowingURLRequest

+
+
+ + +
+
+

OctoKitTests.OctokitSwiftTests

+
+
+ + + + + + + + + + + + + + + + + +
+ +

0.004s

+ +

testOctokitInitializerWithConfig

+ +

0.001s

+ +

testOctokitInitializerWithEmptyConfig

+
+
+ + +
+
+

OctoKitTests.PublicKeyTests

+
+
+ + + + + + + + + + + + + + + + + +
+ +

0.018s

+ +

testPostPublicKey

+ +

0.004s

+ +

testPostPublicKeyURLRequest

+
+
+ + +
+
+

OctoKitTests.RepositoryTests

+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

0.007s

+ +

testFailToGetRepositories

+ +

0.006s

+ +

testFailToGetRepository

+ +

0.009s

+ +

testGetAuthenticatedRepositories

+ +

0.013s

+ +

testGetRepositories

+ +

0.010s

+ +

testGetRepository

+ +

0.006s

+ +

testReadAuthenticatedRepositoriesURLRequest

+ +

0.004s

+ +

testReadAuthenticatedRepositoriesURLRequestWithCustomPageAndPerPage

+ +

0.006s

+ +

testReadRepositoriesURLRequest

+ +

0.007s

+ +

testReadRepositoriesURLRequestWithCustomPageAndPerPage

+ +

0.004s

+ +

testReadRepositoryURLRequest

+ +

0.005s

+ +

testUserParsingFullRepository

+
+
+ + +
+
+

OctoKitTests.StarsTests

+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

0.006s

+ +

testFailToGetStarredRepositories

+ +

0.006s

+ +

testFailToGetUsersStarredRepositories

+ +

0.010s

+ +

testGetStarredRepositories

+ +

0.008s

+ +

testGetUsersStarredRepositories

+ +

0.008s

+ +

testMyStarsURLRequest

+ +

0.008s

+ +

testReadStarsURLRequest

+
+
+ + +
+
+

OctoKitTests.TimeTests

+
+
+ + + + + + + + + + +
+ +

0.003s

+ +

testDateParsing

+
+
+ + +
+
+

OctoKitTests.UserTests

+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

0.015s

+ +

testFailingToGetUser

+ +

0.011s

+ +

testFailToGetAuthenticatedUser

+ +

0.007s

+ +

testGettingAuthenticatedUser

+ +

0.017s

+ +

testGetUser

+ +

0.004s

+ +

testReadingAuthenticatedUserURLRequest

+ +

0.005s

+ +

testReadingUserURLRequest

+ +

0.005s

+ +

testUserParsingFullUser

+ +

0.004s

+ +

testUserParsingMinimalUser

+
+
+ +
+ + + diff --git a/fastlane/test-output/report.junit b/fastlane/test-output/report.junit new file mode 100644 index 00000000..2e31f770 --- /dev/null +++ b/fastlane/test-output/report.junit @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From 71506e15af77961e297939527106a139d4684140 Mon Sep 17 00:00:00 2001 From: Piet Brauer Date: Mon, 22 Feb 2016 15:26:17 +0800 Subject: [PATCH 033/302] Use all platforms branches --- Cartfile | 2 +- Cartfile.private | 2 +- Cartfile.resolved | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cartfile b/Cartfile index f80aaa58..ea52812c 100644 --- a/Cartfile +++ b/Cartfile @@ -1 +1 @@ -github "nerdishbynature/RequestKit" == 0.2.1 +github "nerdishbynature/RequestKit" "all-platforms" diff --git a/Cartfile.private b/Cartfile.private index 522666fa..ab9c05b8 100644 --- a/Cartfile.private +++ b/Cartfile.private @@ -1,2 +1,2 @@ -github "nerdishbynature/Nocilla" +github "nerdishbynature/Nocilla" "all-platforms" diff --git a/Cartfile.resolved b/Cartfile.resolved index c9bfbb7b..eb8e15d3 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1,2 +1,2 @@ -github "nerdishbynature/Nocilla" "0.10.0" -github "nerdishbynature/RequestKit" "0.2.1" +github "nerdishbynature/Nocilla" "57161f3454bebebf111e3e3b2a0b9cb300e2d0ac" +github "nerdishbynature/RequestKit" "928682d476221bf60705257f9d220836017baa65" From d0c8daa80f490ac132eb0b8aa9ae6fa1e224469c Mon Sep 17 00:00:00 2001 From: Piet Brauer Date: Mon, 22 Feb 2016 15:26:34 +0800 Subject: [PATCH 034/302] Add tvOS, watchOS and Mac targets w/ tests --- OctoKit.xcodeproj/project.pbxproj | 734 +++++++++++++++++++++++++++++- 1 file changed, 727 insertions(+), 7 deletions(-) diff --git a/OctoKit.xcodeproj/project.pbxproj b/OctoKit.xcodeproj/project.pbxproj index 917cdafd..0975020d 100644 --- a/OctoKit.xcodeproj/project.pbxproj +++ b/OctoKit.xcodeproj/project.pbxproj @@ -29,6 +29,74 @@ 23B2678C1BDDD756003887E3 /* PublicKey.swift in Sources */ = {isa = PBXBuildFile; fileRef = 23B267871BDDD756003887E3 /* PublicKey.swift */; }; 23B2678D1BDDD756003887E3 /* Repositories.swift in Sources */ = {isa = PBXBuildFile; fileRef = 23B267881BDDD756003887E3 /* Repositories.swift */; }; 23B2678E1BDDD756003887E3 /* User.swift in Sources */ = {isa = PBXBuildFile; fileRef = 23B267891BDDD756003887E3 /* User.swift */; }; + 23CAF26C1C7AB5FC005011C4 /* OctoKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 23CAF2621C7AB5FB005011C4 /* OctoKit.framework */; }; + 23CAF2881C7AB60D005011C4 /* OctoKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 23CAF27E1C7AB60C005011C4 /* OctoKit.framework */; }; + 23CAF2A21C7AB6BE005011C4 /* Configuration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 23B267851BDDD756003887E3 /* Configuration.swift */; }; + 23CAF2A31C7AB6BF005011C4 /* Configuration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 23B267851BDDD756003887E3 /* Configuration.swift */; }; + 23CAF2A41C7AB6BF005011C4 /* Configuration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 23B267851BDDD756003887E3 /* Configuration.swift */; }; + 23CAF2A51C7AB6C2005011C4 /* Follow.swift in Sources */ = {isa = PBXBuildFile; fileRef = E7EE59DB1BE119110012E3D2 /* Follow.swift */; }; + 23CAF2A61C7AB6C2005011C4 /* Follow.swift in Sources */ = {isa = PBXBuildFile; fileRef = E7EE59DB1BE119110012E3D2 /* Follow.swift */; }; + 23CAF2A71C7AB6C3005011C4 /* Follow.swift in Sources */ = {isa = PBXBuildFile; fileRef = E7EE59DB1BE119110012E3D2 /* Follow.swift */; }; + 23CAF2A81C7AB6C6005011C4 /* Octokit.swift in Sources */ = {isa = PBXBuildFile; fileRef = 23B267861BDDD756003887E3 /* Octokit.swift */; }; + 23CAF2A91C7AB6C6005011C4 /* Octokit.swift in Sources */ = {isa = PBXBuildFile; fileRef = 23B267861BDDD756003887E3 /* Octokit.swift */; }; + 23CAF2AA1C7AB6C7005011C4 /* Octokit.swift in Sources */ = {isa = PBXBuildFile; fileRef = 23B267861BDDD756003887E3 /* Octokit.swift */; }; + 23CAF2AB1C7AB6C9005011C4 /* PublicKey.swift in Sources */ = {isa = PBXBuildFile; fileRef = 23B267871BDDD756003887E3 /* PublicKey.swift */; }; + 23CAF2AC1C7AB6CA005011C4 /* PublicKey.swift in Sources */ = {isa = PBXBuildFile; fileRef = 23B267871BDDD756003887E3 /* PublicKey.swift */; }; + 23CAF2AD1C7AB6CA005011C4 /* PublicKey.swift in Sources */ = {isa = PBXBuildFile; fileRef = 23B267871BDDD756003887E3 /* PublicKey.swift */; }; + 23CAF2AE1C7AB6CD005011C4 /* Repositories.swift in Sources */ = {isa = PBXBuildFile; fileRef = 23B267881BDDD756003887E3 /* Repositories.swift */; }; + 23CAF2AF1C7AB6CD005011C4 /* Repositories.swift in Sources */ = {isa = PBXBuildFile; fileRef = 23B267881BDDD756003887E3 /* Repositories.swift */; }; + 23CAF2B01C7AB6CE005011C4 /* Repositories.swift in Sources */ = {isa = PBXBuildFile; fileRef = 23B267881BDDD756003887E3 /* Repositories.swift */; }; + 23CAF2B11C7AB6D1005011C4 /* User.swift in Sources */ = {isa = PBXBuildFile; fileRef = 23B267891BDDD756003887E3 /* User.swift */; }; + 23CAF2B21C7AB6D1005011C4 /* User.swift in Sources */ = {isa = PBXBuildFile; fileRef = 23B267891BDDD756003887E3 /* User.swift */; }; + 23CAF2B31C7AB6D2005011C4 /* User.swift in Sources */ = {isa = PBXBuildFile; fileRef = 23B267891BDDD756003887E3 /* User.swift */; }; + 23CAF2B41C7AB6D4005011C4 /* Stars.swift in Sources */ = {isa = PBXBuildFile; fileRef = E7EE59D71BDFEFB30012E3D2 /* Stars.swift */; }; + 23CAF2B51C7AB6D5005011C4 /* Stars.swift in Sources */ = {isa = PBXBuildFile; fileRef = E7EE59D71BDFEFB30012E3D2 /* Stars.swift */; }; + 23CAF2B61C7AB6D5005011C4 /* Stars.swift in Sources */ = {isa = PBXBuildFile; fileRef = E7EE59D71BDFEFB30012E3D2 /* Stars.swift */; }; + 23CAF2B71C7AB6EB005011C4 /* Time.swift in Sources */ = {isa = PBXBuildFile; fileRef = F8711EA11BFCAE9F005DDACA /* Time.swift */; }; + 23CAF2B81C7AB6EB005011C4 /* Time.swift in Sources */ = {isa = PBXBuildFile; fileRef = F8711EA11BFCAE9F005DDACA /* Time.swift */; }; + 23CAF2B91C7AB6EC005011C4 /* Time.swift in Sources */ = {isa = PBXBuildFile; fileRef = F8711EA11BFCAE9F005DDACA /* Time.swift */; }; + 23CAF2BA1C7AB6F1005011C4 /* ConfigurationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 234F4BC91BDDE3F900A58EF7 /* ConfigurationTests.swift */; }; + 23CAF2BB1C7AB6F1005011C4 /* ConfigurationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 234F4BC91BDDE3F900A58EF7 /* ConfigurationTests.swift */; }; + 23CAF2BC1C7AB6FC005011C4 /* FollowTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E7EE59DD1BE11C2A0012E3D2 /* FollowTests.swift */; }; + 23CAF2BD1C7AB6FC005011C4 /* FollowTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E7EE59DD1BE11C2A0012E3D2 /* FollowTests.swift */; }; + 23CAF2BE1C7AB6FE005011C4 /* OctokitSwiftTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 234F4BCB1BDDE3F900A58EF7 /* OctokitSwiftTests.swift */; }; + 23CAF2BF1C7AB6FF005011C4 /* OctokitSwiftTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 234F4BCB1BDDE3F900A58EF7 /* OctokitSwiftTests.swift */; }; + 23CAF2C01C7AB702005011C4 /* PublicKeyTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 234F4BCC1BDDE3F900A58EF7 /* PublicKeyTests.swift */; }; + 23CAF2C11C7AB702005011C4 /* PublicKeyTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 234F4BCC1BDDE3F900A58EF7 /* PublicKeyTests.swift */; }; + 23CAF2C21C7AB705005011C4 /* RepositoryTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 234F4BCD1BDDE3F900A58EF7 /* RepositoryTests.swift */; }; + 23CAF2C31C7AB706005011C4 /* RepositoryTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 234F4BCD1BDDE3F900A58EF7 /* RepositoryTests.swift */; }; + 23CAF2C41C7AB708005011C4 /* StarsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E7EE59D91BE10DA60012E3D2 /* StarsTests.swift */; }; + 23CAF2C51C7AB709005011C4 /* StarsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E7EE59D91BE10DA60012E3D2 /* StarsTests.swift */; }; + 23CAF2C61C7AB70B005011C4 /* TestHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 234F4BCE1BDDE3F900A58EF7 /* TestHelper.swift */; }; + 23CAF2C71C7AB70C005011C4 /* TestHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 234F4BCE1BDDE3F900A58EF7 /* TestHelper.swift */; }; + 23CAF2C81C7AB70E005011C4 /* TimeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F8711EA31BFCB02D005DDACA /* TimeTests.swift */; }; + 23CAF2C91C7AB70F005011C4 /* TimeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F8711EA31BFCB02D005DDACA /* TimeTests.swift */; }; + 23CAF2CA1C7AB711005011C4 /* UserTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 234F4BCF1BDDE3F900A58EF7 /* UserTests.swift */; }; + 23CAF2CB1C7AB712005011C4 /* UserTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 234F4BCF1BDDE3F900A58EF7 /* UserTests.swift */; }; + 23CAF2CC1C7AB728005011C4 /* OctoKit.h in Headers */ = {isa = PBXBuildFile; fileRef = 239BE7CD1B8C47A100D2CE22 /* OctoKit.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 23CAF2CE1C7AB73D005011C4 /* OctoKit.h in Headers */ = {isa = PBXBuildFile; fileRef = 239BE7CD1B8C47A100D2CE22 /* OctoKit.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 23CAF2D11C7AB759005011C4 /* OctoKit.h in Headers */ = {isa = PBXBuildFile; fileRef = 239BE7CD1B8C47A100D2CE22 /* OctoKit.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 23CAF2D51C7AB9C0005011C4 /* RequestKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 23CAF2D41C7AB9C0005011C4 /* RequestKit.framework */; }; + 23CAF2D91C7AB9DB005011C4 /* RequestKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 23CAF2D81C7AB9DB005011C4 /* RequestKit.framework */; }; + 23CAF2DA1C7ABA67005011C4 /* RequestKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 23CAF2D61C7AB9CE005011C4 /* RequestKit.framework */; }; + 23F6433D1C7AEEB6000427B3 /* Nocilla.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 23F6433C1C7AEEB6000427B3 /* Nocilla.framework */; }; + 23F6433E1C7AEECE000427B3 /* Nocilla.framework in Carthage embed */ = {isa = PBXBuildFile; fileRef = 23F6433C1C7AEEB6000427B3 /* Nocilla.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + 23F6433F1C7AEED7000427B3 /* RequestKit.framework in Carthage embed */ = {isa = PBXBuildFile; fileRef = 23CAF2D41C7AB9C0005011C4 /* RequestKit.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + 23F643431C7AEF2F000427B3 /* Nocilla.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 23F643421C7AEF2F000427B3 /* Nocilla.framework */; }; + 23F643441C7AEF32000427B3 /* Nocilla.framework in Carthage embed */ = {isa = PBXBuildFile; fileRef = 23F643421C7AEF2F000427B3 /* Nocilla.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + 23F643451C7AEF37000427B3 /* RequestKit.framework in Carthage embed */ = {isa = PBXBuildFile; fileRef = 23CAF2D61C7AB9CE005011C4 /* RequestKit.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + 23F643461C7AEF63000427B3 /* public_key.json in Resources */ = {isa = PBXBuildFile; fileRef = 234F4BD81BDDE44600A58EF7 /* public_key.json */; }; + 23F643471C7AEF63000427B3 /* public_key.json in Resources */ = {isa = PBXBuildFile; fileRef = 234F4BD81BDDE44600A58EF7 /* public_key.json */; }; + 23F643481C7AEF66000427B3 /* repo.json in Resources */ = {isa = PBXBuildFile; fileRef = 234F4BD91BDDE44600A58EF7 /* repo.json */; }; + 23F643491C7AEF67000427B3 /* repo.json in Resources */ = {isa = PBXBuildFile; fileRef = 234F4BD91BDDE44600A58EF7 /* repo.json */; }; + 23F6434A1C7AEF69000427B3 /* user_me.json in Resources */ = {isa = PBXBuildFile; fileRef = 234F4BDA1BDDE44600A58EF7 /* user_me.json */; }; + 23F6434B1C7AEF6A000427B3 /* user_me.json in Resources */ = {isa = PBXBuildFile; fileRef = 234F4BDA1BDDE44600A58EF7 /* user_me.json */; }; + 23F6434C1C7AEF6C000427B3 /* user_mietzmithut.json in Resources */ = {isa = PBXBuildFile; fileRef = 234F4BDB1BDDE44600A58EF7 /* user_mietzmithut.json */; }; + 23F6434D1C7AEF6D000427B3 /* user_mietzmithut.json in Resources */ = {isa = PBXBuildFile; fileRef = 234F4BDB1BDDE44600A58EF7 /* user_mietzmithut.json */; }; + 23F6434E1C7AEF6F000427B3 /* user_repos.json in Resources */ = {isa = PBXBuildFile; fileRef = 234F4BDC1BDDE44600A58EF7 /* user_repos.json */; }; + 23F6434F1C7AEF70000427B3 /* user_repos.json in Resources */ = {isa = PBXBuildFile; fileRef = 234F4BDC1BDDE44600A58EF7 /* user_repos.json */; }; + 23F643501C7AEF72000427B3 /* users.json in Resources */ = {isa = PBXBuildFile; fileRef = E7EE59DF1BE139FD0012E3D2 /* users.json */; }; + 23F643511C7AEF73000427B3 /* users.json in Resources */ = {isa = PBXBuildFile; fileRef = E7EE59DF1BE139FD0012E3D2 /* users.json */; }; E7EE59D81BDFEFB30012E3D2 /* Stars.swift in Sources */ = {isa = PBXBuildFile; fileRef = E7EE59D71BDFEFB30012E3D2 /* Stars.swift */; }; E7EE59DA1BE10DA60012E3D2 /* StarsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E7EE59D91BE10DA60012E3D2 /* StarsTests.swift */; }; E7EE59DC1BE119110012E3D2 /* Follow.swift in Sources */ = {isa = PBXBuildFile; fileRef = E7EE59DB1BE119110012E3D2 /* Follow.swift */; }; @@ -46,6 +114,20 @@ remoteGlobalIDString = 239BE7C81B8C47A100D2CE22; remoteInfo = OctoKit; }; + 23CAF26D1C7AB5FC005011C4 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = F01C6F2C1A6429CC0072FA44 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 23CAF2611C7AB5FB005011C4; + remoteInfo = "OctoKit tvOS"; + }; + 23CAF2891C7AB60D005011C4 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = F01C6F2C1A6429CC0072FA44 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 23CAF27D1C7AB60C005011C4; + remoteInfo = "OctoKit Mac"; + }; /* End PBXContainerItemProxy section */ /* Begin PBXCopyFilesBuildPhase section */ @@ -61,6 +143,30 @@ name = "Carthage embed"; runOnlyForDeploymentPostprocessing = 0; }; + 23F6433A1C7AEE7C000427B3 /* Carthage embed */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + 23F6433E1C7AEECE000427B3 /* Nocilla.framework in Carthage embed */, + 23F6433F1C7AEED7000427B3 /* RequestKit.framework in Carthage embed */, + ); + name = "Carthage embed"; + runOnlyForDeploymentPostprocessing = 0; + }; + 23F643411C7AEF13000427B3 /* Carthage embed */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + 23F643441C7AEF32000427B3 /* Nocilla.framework in Carthage embed */, + 23F643451C7AEF37000427B3 /* RequestKit.framework in Carthage embed */, + ); + name = "Carthage embed"; + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ @@ -87,6 +193,16 @@ 23B267881BDDD756003887E3 /* Repositories.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Repositories.swift; sourceTree = ""; }; 23B267891BDDD756003887E3 /* User.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = User.swift; sourceTree = ""; }; 23B2679C1BDDDBBE003887E3 /* Nocilla.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Nocilla.framework; path = Carthage/Build/iOS/Nocilla.framework; sourceTree = ""; }; + 23CAF2621C7AB5FB005011C4 /* OctoKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = OctoKit.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 23CAF26B1C7AB5FC005011C4 /* OctoKit tvOSTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "OctoKit tvOSTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; + 23CAF27E1C7AB60C005011C4 /* OctoKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = OctoKit.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 23CAF2871C7AB60D005011C4 /* OctoKit MacTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "OctoKit MacTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; + 23CAF29A1C7AB619005011C4 /* OctoKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = OctoKit.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 23CAF2D41C7AB9C0005011C4 /* RequestKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = RequestKit.framework; path = Carthage/Build/tvOS/RequestKit.framework; sourceTree = ""; }; + 23CAF2D61C7AB9CE005011C4 /* RequestKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = RequestKit.framework; path = Carthage/Build/Mac/RequestKit.framework; sourceTree = ""; }; + 23CAF2D81C7AB9DB005011C4 /* RequestKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = RequestKit.framework; path = Carthage/Build/watchOS/RequestKit.framework; sourceTree = ""; }; + 23F6433C1C7AEEB6000427B3 /* Nocilla.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Nocilla.framework; path = Carthage/Build/tvOS/Nocilla.framework; sourceTree = ""; }; + 23F643421C7AEF2F000427B3 /* Nocilla.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Nocilla.framework; path = Carthage/Build/Mac/Nocilla.framework; sourceTree = ""; }; E7EE59D71BDFEFB30012E3D2 /* Stars.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Stars.swift; sourceTree = ""; }; E7EE59D91BE10DA60012E3D2 /* StarsTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StarsTests.swift; sourceTree = ""; }; E7EE59DB1BE119110012E3D2 /* Follow.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Follow.swift; sourceTree = ""; }; @@ -114,6 +230,48 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 23CAF25E1C7AB5FB005011C4 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 23CAF2D51C7AB9C0005011C4 /* RequestKit.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 23CAF2681C7AB5FC005011C4 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 23F6433D1C7AEEB6000427B3 /* Nocilla.framework in Frameworks */, + 23CAF26C1C7AB5FC005011C4 /* OctoKit.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 23CAF27A1C7AB60C005011C4 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 23CAF2DA1C7ABA67005011C4 /* RequestKit.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 23CAF2841C7AB60D005011C4 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 23F643431C7AEF2F000427B3 /* Nocilla.framework in Frameworks */, + 23CAF2881C7AB60D005011C4 /* OctoKit.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 23CAF2961C7AB619005011C4 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 23CAF2D91C7AB9DB005011C4 /* RequestKit.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ @@ -176,6 +334,11 @@ B975D5A3F8B0384EFB0C5863 /* Frameworks */ = { isa = PBXGroup; children = ( + 23F643421C7AEF2F000427B3 /* Nocilla.framework */, + 23F6433C1C7AEEB6000427B3 /* Nocilla.framework */, + 23CAF2D81C7AB9DB005011C4 /* RequestKit.framework */, + 23CAF2D61C7AB9CE005011C4 /* RequestKit.framework */, + 23CAF2D41C7AB9C0005011C4 /* RequestKit.framework */, 234F4C3E1BDE0FE200A58EF7 /* RequestKit.framework */, 23B2679C1BDDDBBE003887E3 /* Nocilla.framework */, ); @@ -197,6 +360,11 @@ children = ( 239BE7C91B8C47A100D2CE22 /* OctoKit.framework */, 234F4BA91BDDE31A00A58EF7 /* OctoKitTests.xctest */, + 23CAF2621C7AB5FB005011C4 /* OctoKit.framework */, + 23CAF26B1C7AB5FC005011C4 /* OctoKit tvOSTests.xctest */, + 23CAF27E1C7AB60C005011C4 /* OctoKit.framework */, + 23CAF2871C7AB60D005011C4 /* OctoKit MacTests.xctest */, + 23CAF29A1C7AB619005011C4 /* OctoKit.framework */, ); name = Products; sourceTree = ""; @@ -212,6 +380,30 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 23CAF25F1C7AB5FB005011C4 /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + 23CAF2CC1C7AB728005011C4 /* OctoKit.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 23CAF27B1C7AB60C005011C4 /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + 23CAF2CE1C7AB73D005011C4 /* OctoKit.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 23CAF2971C7AB619005011C4 /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + 23CAF2D11C7AB759005011C4 /* OctoKit.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXHeadersBuildPhase section */ /* Begin PBXNativeTarget section */ @@ -252,6 +444,98 @@ productReference = 239BE7C91B8C47A100D2CE22 /* OctoKit.framework */; productType = "com.apple.product-type.framework"; }; + 23CAF2611C7AB5FB005011C4 /* OctoKit tvOS */ = { + isa = PBXNativeTarget; + buildConfigurationList = 23CAF2771C7AB5FC005011C4 /* Build configuration list for PBXNativeTarget "OctoKit tvOS" */; + buildPhases = ( + 23CAF25D1C7AB5FB005011C4 /* Sources */, + 23CAF25E1C7AB5FB005011C4 /* Frameworks */, + 23CAF25F1C7AB5FB005011C4 /* Headers */, + 23CAF2601C7AB5FB005011C4 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "OctoKit tvOS"; + productName = "OctoKit tvOS"; + productReference = 23CAF2621C7AB5FB005011C4 /* OctoKit.framework */; + productType = "com.apple.product-type.framework"; + }; + 23CAF26A1C7AB5FC005011C4 /* OctoKit tvOSTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 23CAF2781C7AB5FC005011C4 /* Build configuration list for PBXNativeTarget "OctoKit tvOSTests" */; + buildPhases = ( + 23CAF2671C7AB5FC005011C4 /* Sources */, + 23CAF2681C7AB5FC005011C4 /* Frameworks */, + 23CAF2691C7AB5FC005011C4 /* Resources */, + 23F6433A1C7AEE7C000427B3 /* Carthage embed */, + ); + buildRules = ( + ); + dependencies = ( + 23CAF26E1C7AB5FC005011C4 /* PBXTargetDependency */, + ); + name = "OctoKit tvOSTests"; + productName = "OctoKit tvOSTests"; + productReference = 23CAF26B1C7AB5FC005011C4 /* OctoKit tvOSTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; + 23CAF27D1C7AB60C005011C4 /* OctoKit Mac */ = { + isa = PBXNativeTarget; + buildConfigurationList = 23CAF28F1C7AB60D005011C4 /* Build configuration list for PBXNativeTarget "OctoKit Mac" */; + buildPhases = ( + 23CAF2791C7AB60C005011C4 /* Sources */, + 23CAF27A1C7AB60C005011C4 /* Frameworks */, + 23CAF27B1C7AB60C005011C4 /* Headers */, + 23CAF27C1C7AB60C005011C4 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "OctoKit Mac"; + productName = "OctoKit Mac"; + productReference = 23CAF27E1C7AB60C005011C4 /* OctoKit.framework */; + productType = "com.apple.product-type.framework"; + }; + 23CAF2861C7AB60D005011C4 /* OctoKit MacTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 23CAF2921C7AB60D005011C4 /* Build configuration list for PBXNativeTarget "OctoKit MacTests" */; + buildPhases = ( + 23CAF2831C7AB60D005011C4 /* Sources */, + 23CAF2841C7AB60D005011C4 /* Frameworks */, + 23CAF2851C7AB60D005011C4 /* Resources */, + 23F643411C7AEF13000427B3 /* Carthage embed */, + ); + buildRules = ( + ); + dependencies = ( + 23CAF28A1C7AB60D005011C4 /* PBXTargetDependency */, + ); + name = "OctoKit MacTests"; + productName = "OctoKit MacTests"; + productReference = 23CAF2871C7AB60D005011C4 /* OctoKit MacTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; + 23CAF2991C7AB619005011C4 /* OctoKit watchOS */ = { + isa = PBXNativeTarget; + buildConfigurationList = 23CAF29F1C7AB619005011C4 /* Build configuration list for PBXNativeTarget "OctoKit watchOS" */; + buildPhases = ( + 23CAF2951C7AB619005011C4 /* Sources */, + 23CAF2961C7AB619005011C4 /* Frameworks */, + 23CAF2971C7AB619005011C4 /* Headers */, + 23CAF2981C7AB619005011C4 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "OctoKit watchOS"; + productName = "OctoKit watchOS"; + productReference = 23CAF29A1C7AB619005011C4 /* OctoKit.framework */; + productType = "com.apple.product-type.framework"; + }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ @@ -259,7 +543,7 @@ isa = PBXProject; attributes = { LastSwiftMigration = 0700; - LastSwiftUpdateCheck = 0710; + LastSwiftUpdateCheck = 0720; LastUpgradeCheck = 0700; ORGANIZATIONNAME = "nerdish by nature"; TargetAttributes = { @@ -269,6 +553,21 @@ 239BE7C81B8C47A100D2CE22 = { CreatedOnToolsVersion = 6.4; }; + 23CAF2611C7AB5FB005011C4 = { + CreatedOnToolsVersion = 7.2.1; + }; + 23CAF26A1C7AB5FC005011C4 = { + CreatedOnToolsVersion = 7.2.1; + }; + 23CAF27D1C7AB60C005011C4 = { + CreatedOnToolsVersion = 7.2.1; + }; + 23CAF2861C7AB60D005011C4 = { + CreatedOnToolsVersion = 7.2.1; + }; + 23CAF2991C7AB619005011C4 = { + CreatedOnToolsVersion = 7.2.1; + }; }; }; buildConfigurationList = F01C6F2F1A6429CC0072FA44 /* Build configuration list for PBXProject "OctoKit" */; @@ -286,6 +585,11 @@ targets = ( 239BE7C81B8C47A100D2CE22 /* OctoKit */, 234F4BA81BDDE31A00A58EF7 /* OctoKitTests */, + 23CAF2611C7AB5FB005011C4 /* OctoKit tvOS */, + 23CAF26A1C7AB5FC005011C4 /* OctoKit tvOSTests */, + 23CAF27D1C7AB60C005011C4 /* OctoKit Mac */, + 23CAF2861C7AB60D005011C4 /* OctoKit MacTests */, + 23CAF2991C7AB619005011C4 /* OctoKit watchOS */, ); }; /* End PBXProject section */ @@ -311,6 +615,53 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 23CAF2601C7AB5FB005011C4 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 23CAF2691C7AB5FC005011C4 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 23F643501C7AEF72000427B3 /* users.json in Resources */, + 23F6434A1C7AEF69000427B3 /* user_me.json in Resources */, + 23F643461C7AEF63000427B3 /* public_key.json in Resources */, + 23F643481C7AEF66000427B3 /* repo.json in Resources */, + 23F6434E1C7AEF6F000427B3 /* user_repos.json in Resources */, + 23F6434C1C7AEF6C000427B3 /* user_mietzmithut.json in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 23CAF27C1C7AB60C005011C4 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 23CAF2851C7AB60D005011C4 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 23F643511C7AEF73000427B3 /* users.json in Resources */, + 23F6434B1C7AEF6A000427B3 /* user_me.json in Resources */, + 23F643471C7AEF63000427B3 /* public_key.json in Resources */, + 23F643491C7AEF67000427B3 /* repo.json in Resources */, + 23F6434F1C7AEF70000427B3 /* user_repos.json in Resources */, + 23F6434D1C7AEF6D000427B3 /* user_mietzmithut.json in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 23CAF2981C7AB619005011C4 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXResourcesBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -345,6 +696,83 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 23CAF25D1C7AB5FB005011C4 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 23CAF2A51C7AB6C2005011C4 /* Follow.swift in Sources */, + 23CAF2AE1C7AB6CD005011C4 /* Repositories.swift in Sources */, + 23CAF2B11C7AB6D1005011C4 /* User.swift in Sources */, + 23CAF2A21C7AB6BE005011C4 /* Configuration.swift in Sources */, + 23CAF2B71C7AB6EB005011C4 /* Time.swift in Sources */, + 23CAF2B41C7AB6D4005011C4 /* Stars.swift in Sources */, + 23CAF2AB1C7AB6C9005011C4 /* PublicKey.swift in Sources */, + 23CAF2A81C7AB6C6005011C4 /* Octokit.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 23CAF2671C7AB5FC005011C4 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 23CAF2BC1C7AB6FC005011C4 /* FollowTests.swift in Sources */, + 23CAF2C41C7AB708005011C4 /* StarsTests.swift in Sources */, + 23CAF2C61C7AB70B005011C4 /* TestHelper.swift in Sources */, + 23CAF2BE1C7AB6FE005011C4 /* OctokitSwiftTests.swift in Sources */, + 23CAF2C81C7AB70E005011C4 /* TimeTests.swift in Sources */, + 23CAF2C01C7AB702005011C4 /* PublicKeyTests.swift in Sources */, + 23CAF2CA1C7AB711005011C4 /* UserTests.swift in Sources */, + 23CAF2C21C7AB705005011C4 /* RepositoryTests.swift in Sources */, + 23CAF2BA1C7AB6F1005011C4 /* ConfigurationTests.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 23CAF2791C7AB60C005011C4 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 23CAF2A61C7AB6C2005011C4 /* Follow.swift in Sources */, + 23CAF2AF1C7AB6CD005011C4 /* Repositories.swift in Sources */, + 23CAF2B21C7AB6D1005011C4 /* User.swift in Sources */, + 23CAF2A31C7AB6BF005011C4 /* Configuration.swift in Sources */, + 23CAF2B81C7AB6EB005011C4 /* Time.swift in Sources */, + 23CAF2B51C7AB6D5005011C4 /* Stars.swift in Sources */, + 23CAF2AC1C7AB6CA005011C4 /* PublicKey.swift in Sources */, + 23CAF2A91C7AB6C6005011C4 /* Octokit.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 23CAF2831C7AB60D005011C4 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 23CAF2BD1C7AB6FC005011C4 /* FollowTests.swift in Sources */, + 23CAF2C51C7AB709005011C4 /* StarsTests.swift in Sources */, + 23CAF2C71C7AB70C005011C4 /* TestHelper.swift in Sources */, + 23CAF2BF1C7AB6FF005011C4 /* OctokitSwiftTests.swift in Sources */, + 23CAF2C91C7AB70F005011C4 /* TimeTests.swift in Sources */, + 23CAF2C11C7AB702005011C4 /* PublicKeyTests.swift in Sources */, + 23CAF2CB1C7AB712005011C4 /* UserTests.swift in Sources */, + 23CAF2C31C7AB706005011C4 /* RepositoryTests.swift in Sources */, + 23CAF2BB1C7AB6F1005011C4 /* ConfigurationTests.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 23CAF2951C7AB619005011C4 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 23CAF2A71C7AB6C3005011C4 /* Follow.swift in Sources */, + 23CAF2B01C7AB6CE005011C4 /* Repositories.swift in Sources */, + 23CAF2B31C7AB6D2005011C4 /* User.swift in Sources */, + 23CAF2A41C7AB6BF005011C4 /* Configuration.swift in Sources */, + 23CAF2B91C7AB6EC005011C4 /* Time.swift in Sources */, + 23CAF2B61C7AB6D5005011C4 /* Stars.swift in Sources */, + 23CAF2AD1C7AB6CA005011C4 /* PublicKey.swift in Sources */, + 23CAF2AA1C7AB6C7005011C4 /* Octokit.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ @@ -353,6 +781,16 @@ target = 239BE7C81B8C47A100D2CE22 /* OctoKit */; targetProxy = 234F4BAF1BDDE31A00A58EF7 /* PBXContainerItemProxy */; }; + 23CAF26E1C7AB5FC005011C4 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 23CAF2611C7AB5FB005011C4 /* OctoKit tvOS */; + targetProxy = 23CAF26D1C7AB5FC005011C4 /* PBXContainerItemProxy */; + }; + 23CAF28A1C7AB60D005011C4 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 23CAF27D1C7AB60C005011C4 /* OctoKit Mac */; + targetProxy = 23CAF2891C7AB60D005011C4 /* PBXContainerItemProxy */; + }; /* End PBXTargetDependency section */ /* Begin XCBuildConfiguration section */ @@ -410,12 +848,9 @@ "DEBUG=1", "$(inherited)", ); - INFOPLIST_FILE = OctoKit/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = "com.nerdishbynature.$(PRODUCT_NAME:rfc1034identifier)"; - PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; TARGETED_DEVICE_FAMILY = "1,2"; @@ -440,12 +875,9 @@ "$(PROJECT_DIR)/Carthage/Build/iOS", ); GCC_NO_COMMON_BLOCKS = YES; - INFOPLIST_FILE = OctoKit/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = "com.nerdishbynature.$(PRODUCT_NAME:rfc1034identifier)"; - PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; @@ -453,6 +885,243 @@ }; name = Release; }; + 23CAF2731C7AB5FC005011C4 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = dwarf; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Carthage/Build/tvOS", + ); + GCC_NO_COMMON_BLOCKS = YES; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + SDKROOT = appletvos; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = 3; + TVOS_DEPLOYMENT_TARGET = 9.1; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Debug; + }; + 23CAF2741C7AB5FC005011C4 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + COPY_PHASE_STRIP = NO; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Carthage/Build/tvOS", + ); + GCC_NO_COMMON_BLOCKS = YES; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + SDKROOT = appletvos; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = 3; + TVOS_DEPLOYMENT_TARGET = 9.1; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Release; + }; + 23CAF2751C7AB5FC005011C4 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + DEBUG_INFORMATION_FORMAT = dwarf; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Carthage/Build/tvOS", + ); + GCC_NO_COMMON_BLOCKS = YES; + INFOPLIST_FILE = OctoKitTests/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "com.nerdishbynature.OctoKit-tvOSTests"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = appletvos; + TVOS_DEPLOYMENT_TARGET = 9.1; + }; + name = Debug; + }; + 23CAF2761C7AB5FC005011C4 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Carthage/Build/tvOS", + ); + GCC_NO_COMMON_BLOCKS = YES; + INFOPLIST_FILE = OctoKitTests/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "com.nerdishbynature.OctoKit-tvOSTests"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = appletvos; + TVOS_DEPLOYMENT_TARGET = 9.1; + }; + name = Release; + }; + 23CAF2901C7AB60D005011C4 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_IDENTITY = "-"; + COMBINE_HIDPI_IMAGES = YES; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = dwarf; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Carthage/Build/Mac", + ); + FRAMEWORK_VERSION = A; + GCC_NO_COMMON_BLOCKS = YES; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; + MACOSX_DEPLOYMENT_TARGET = 10.11; + SDKROOT = macosx; + SKIP_INSTALL = YES; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Debug; + }; + 23CAF2911C7AB60D005011C4 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_IDENTITY = "-"; + COMBINE_HIDPI_IMAGES = YES; + COPY_PHASE_STRIP = NO; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Carthage/Build/Mac", + ); + FRAMEWORK_VERSION = A; + GCC_NO_COMMON_BLOCKS = YES; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; + MACOSX_DEPLOYMENT_TARGET = 10.11; + SDKROOT = macosx; + SKIP_INSTALL = YES; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Release; + }; + 23CAF2931C7AB60D005011C4 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_IDENTITY = "-"; + COMBINE_HIDPI_IMAGES = YES; + DEBUG_INFORMATION_FORMAT = dwarf; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Carthage/Build/Mac", + ); + GCC_NO_COMMON_BLOCKS = YES; + INFOPLIST_FILE = OctoKitTests/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; + MACOSX_DEPLOYMENT_TARGET = 10.11; + PRODUCT_BUNDLE_IDENTIFIER = "com.nerdishbynature.OctoKit-MacTests"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = macosx; + }; + name = Debug; + }; + 23CAF2941C7AB60D005011C4 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_IDENTITY = "-"; + COMBINE_HIDPI_IMAGES = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Carthage/Build/Mac", + ); + GCC_NO_COMMON_BLOCKS = YES; + INFOPLIST_FILE = OctoKitTests/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; + MACOSX_DEPLOYMENT_TARGET = 10.11; + PRODUCT_BUNDLE_IDENTIFIER = "com.nerdishbynature.OctoKit-MacTests"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = macosx; + }; + name = Release; + }; + 23CAF2A01C7AB619005011C4 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + APPLICATION_EXTENSION_API_ONLY = YES; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = dwarf; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Carthage/Build/watchOS", + ); + GCC_NO_COMMON_BLOCKS = YES; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + SDKROOT = watchos; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = 4; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + WATCHOS_DEPLOYMENT_TARGET = 2.1; + }; + name = Debug; + }; + 23CAF2A11C7AB619005011C4 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + APPLICATION_EXTENSION_API_ONLY = YES; + COPY_PHASE_STRIP = NO; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Carthage/Build/watchOS", + ); + GCC_NO_COMMON_BLOCKS = YES; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + SDKROOT = watchos; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = 4; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + WATCHOS_DEPLOYMENT_TARGET = 2.1; + }; + name = Release; + }; F01C6F511A6429CC0072FA44 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -488,9 +1157,12 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; + INFOPLIST_FILE = OctoKit/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 8.1; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; + PRODUCT_BUNDLE_IDENTIFIER = com.nerdishbynature.OctoKit; + PRODUCT_NAME = OctoKit; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; }; @@ -524,8 +1196,11 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; + INFOPLIST_FILE = OctoKit/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 8.1; MTL_ENABLE_DEBUG_INFO = NO; + PRODUCT_BUNDLE_IDENTIFIER = com.nerdishbynature.OctoKit; + PRODUCT_NAME = OctoKit; SDKROOT = iphoneos; VALIDATE_PRODUCT = YES; }; @@ -552,6 +1227,51 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; + 23CAF2771C7AB5FC005011C4 /* Build configuration list for PBXNativeTarget "OctoKit tvOS" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 23CAF2731C7AB5FC005011C4 /* Debug */, + 23CAF2741C7AB5FC005011C4 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 23CAF2781C7AB5FC005011C4 /* Build configuration list for PBXNativeTarget "OctoKit tvOSTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 23CAF2751C7AB5FC005011C4 /* Debug */, + 23CAF2761C7AB5FC005011C4 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 23CAF28F1C7AB60D005011C4 /* Build configuration list for PBXNativeTarget "OctoKit Mac" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 23CAF2901C7AB60D005011C4 /* Debug */, + 23CAF2911C7AB60D005011C4 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 23CAF2921C7AB60D005011C4 /* Build configuration list for PBXNativeTarget "OctoKit MacTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 23CAF2931C7AB60D005011C4 /* Debug */, + 23CAF2941C7AB60D005011C4 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 23CAF29F1C7AB619005011C4 /* Build configuration list for PBXNativeTarget "OctoKit watchOS" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 23CAF2A01C7AB619005011C4 /* Debug */, + 23CAF2A11C7AB619005011C4 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; F01C6F2F1A6429CC0072FA44 /* Build configuration list for PBXProject "OctoKit" */ = { isa = XCConfigurationList; buildConfigurations = ( From 5d64ded2d2dddd1dbcf068325f4c879babc74e1a Mon Sep 17 00:00:00 2001 From: Piet Brauer Date: Mon, 22 Feb 2016 15:26:43 +0800 Subject: [PATCH 035/302] Use Foundation instead of UIKit --- OctoKit/OctoKit.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OctoKit/OctoKit.h b/OctoKit/OctoKit.h index b9dc0a79..93a5786b 100644 --- a/OctoKit/OctoKit.h +++ b/OctoKit/OctoKit.h @@ -6,7 +6,7 @@ // Copyright (c) 2015 nerdish by nature. All rights reserved. // -#import +#import //! Project version number for OctoKit. FOUNDATION_EXPORT double OctoKitVersionNumber; From 6dba14a3dfb96a71235127954eea644562acc8c3 Mon Sep 17 00:00:00 2001 From: Piet Brauer Date: Mon, 22 Feb 2016 15:31:12 +0800 Subject: [PATCH 036/302] Remove fastlane files --- fastlane/README.md | 196 -------- fastlane/report.xml | 21 - fastlane/test-output/report.html | 779 ------------------------------ fastlane/test-output/report.junit | 69 --- 4 files changed, 1065 deletions(-) delete mode 100644 fastlane/README.md delete mode 100644 fastlane/report.xml delete mode 100644 fastlane/test-output/report.html delete mode 100644 fastlane/test-output/report.junit diff --git a/fastlane/README.md b/fastlane/README.md deleted file mode 100644 index 62b38ea6..00000000 --- a/fastlane/README.md +++ /dev/null @@ -1,196 +0,0 @@ -fastlane documentation -================ -# Installation -``` -sudo gem install fastlane -``` -# Available Actions -### ci_commit -``` -fastlane ci_commit -``` -Runs tests and builds example for the given environment - -The lane to run by ci on every commit This lanes calls the lanes `test_framework` and `build_example`. - -####Example: - -``` -fastlane ci_commit configuration:Debug --env ios91 -``` - -####Options - - * **`configuration`**: The build configuration to use. (`AF_CONFIGURATION`) - - -### test_framework -``` -fastlane test_framework -``` -Runs all tests for the given environment - -Set `scan` action environment variables to control test configuration - -####Example: - -``` -fastlane test_framework configuration:Debug --env ios91 -``` - -####Options - - * **`configuration`**: The build configuration to use. - - -### code_coverage -``` -fastlane code_coverage -``` -Produces code coverage information - -Set `scan` action environment variables to control test configuration - -####Example: - -``` -fastlane code_coverage configuration:Debug -``` - -####Options - - * **`configuration`**: The build configuration to use. The only supported configuration is the `Debug` configuration. - - -### prepare_framework_release -``` -fastlane prepare_framework_release -``` -Prepares the framework for release - -This lane should be run from your local machine, and will push a tag to the remote when finished. - - * Verifies the git branch is clean - - * Ensures the lane is running on the master branch - - * Verifies the Github milestone is ready for release - - * Pulls the remote to verify the latest the branch is up to date - - * Updates the version of the info plist path used by the framework - - * Updates the the version of the podspec - - * Generates a changelog based on the Github milestone - - * Updates the changelog file - - * Commits the changes - - * Pushes the commited branch - - * Creates a tag - - * Pushes the tag - -####Example: - -``` -fastlane prepare_framework_release version:3.0.0 --env deploy -``` - -####Options - -It is recommended to manage these options through a .env file. See `fastlane/.env.deploy` for an example. - - * **`version`** (required): The new version of the framework - - * **`allow_dirty_branch`**: Allows the git branch to be dirty before continuing. Defaults to false - - * **`remote`**: The name of the git remote. Defaults to `origin`. (`DEPLOY_REMOTE`) - - * **`allow_branch`**: The name of the branch to build from. Defaults to `master`. (`DEPLOY_BRANCH`) - - * **`skip_validate_github_milestone`**: Skips validating a Github milestone. Defaults to false - - * **`skip_git_pull`**: Skips pulling the git remote. Defaults to false - - * **`skip_plist_update`**: Skips updating the version of the info plist. Defaults to false - - * **`plist_path`**: The path of the plist file to update. (`DEPLOY_PLIST_PATH`) - - * **`skip_podspec_update`**: Skips updating the version of the podspec. Defaults to false - - * **`podspec`**: The path of the podspec file to update. (`DEPLOY_PODSPEC`) - - * **`skip_changelog`**: Skip generating a changelog. Defaults to false. - - * **`changelog_path`**: The path to the changelog file. (`DEPLOY_CHANGELOG_PATH`) - - * **`changelog_insert_delimiter`**: The delimiter to insert the changelog after. (`DEPLOY_CHANGELOG_DELIMITER`) - - -### complete_framework_release -``` -fastlane complete_framework_release -``` -Completes the framework release - -This lane should be from a CI machine, after the tests have passed on the tag build. This lane does the following: - - * Verifies the git branch is clean - - * Ensures the lane is running on the master branch - - * Pulls the remote to verify the latest the branch is up to date - - * Generates a changelog for the Github Release - - * Creates a Github Release - - * Builds Carthage Frameworks - - * Uploads Carthage Framework to Github Release - - * Pushes podspec to pod trunk - - * Lints the pod spec to ensure it is valid - - * Closes the associated Github milestone - -####Example: - -``` -fastlane complete_framework_release --env deploy -``` - -####Options - -It is recommended to manage these options through a .env file. See `fastlane/.env.deploy` for an example. - - * **`version`** (required): The new version of the framework. Defaults to the last tag in the repo - - * **`allow_dirty_branch`**: Allows the git branch to be dirty before continuing. Defaults to false - - * **`remote`**: The name of the git remote. Defaults to `origin`. (`DEPLOY_REMOTE`) - - * **`allow_branch`**: The name of the branch to build from. Defaults to `master`. (`DEPLOY_BRANCH`) - - * **`skip_github_release`**: Skips creating a Github release. Defaults to false - - * **`skip_carthage_framework`**: Skips creating a carthage framework. If building a swift framework, this should be disabled. Defaults to false. - - * **`skip_pod_push`**: Skips pushing the podspec to trunk. - - * **`skip_podspec_update`**: Skips updating the version of the podspec. Defaults to false - - * **`skip_closing_github_milestone`**: Skips closing the associated Github milestone. Defaults to false - - - ----- - -This README.md is auto-generated and will be re-generated every time to run [fastlane](https://fastlane.tools). -More information about fastlane can be found on [https://fastlane.tools](https://fastlane.tools). -The documentation of fastlane can be found on [GitHub](https://github.com/fastlane/fastlane). \ No newline at end of file diff --git a/fastlane/report.xml b/fastlane/report.xml deleted file mode 100644 index 713ff923..00000000 --- a/fastlane/report.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - diff --git a/fastlane/test-output/report.html b/fastlane/test-output/report.html deleted file mode 100644 index d138586b..00000000 --- a/fastlane/test-output/report.html +++ /dev/null @@ -1,779 +0,0 @@ - - - - - Test Results | xcpretty - - - - -
-
-

Test Results

-
-
-
-

50 tests

- -
-
- AllFailingPassing -
-
-
-
- - -
-
-

OctoKitTests.ConfigurationTests

-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -

0.120s

- -

testAccessTokenFromResponse

- -

0.267s

- -

testAccessTokenURLRequest

- -

0.018s

- -

testAuthorizeURLRequest

- -

0.004s

- -

testEnterpriseTokenConfiguration

- -

0.093s

- -

testHandleOpenURL

- -

0.003s

- -

testOAuthConfiguration

- -

0.002s

- -

testOAuthTokenConfiguration

- -

0.003s

- -

testTokenConfiguration

-
-
- - -
-
-

OctoKitTests.FollowTests

-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -

0.005s

- -

testFailToGetMyFollowers

- -

0.006s

- -

testFailToGetMyFollowing

- -

0.005s

- -

testFailToGetUsersFollowers

- -

0.005s

- -

testFailToGetUsersFollowing

- -

0.024s

- -

testGetMyFollowers

- -

0.006s

- -

testGetMyFollowing

- -

0.006s

- -

testGetUsersFollowers

- -

0.005s

- -

testGetUsersFollowing

- -

0.003s

- -

testReadingAuthenticatedUserFollowersURLRequest

- -

0.003s

- -

testReadingAuthenticatedUserFollowingURLRequest

- -

0.002s

- -

testReadingUserFollowersURLRequest

- -

0.014s

- -

testReadingUserFollowingURLRequest

-
-
- - -
-
-

OctoKitTests.OctokitSwiftTests

-
-
- - - - - - - - - - - - - - - - - -
- -

0.004s

- -

testOctokitInitializerWithConfig

- -

0.001s

- -

testOctokitInitializerWithEmptyConfig

-
-
- - -
-
-

OctoKitTests.PublicKeyTests

-
-
- - - - - - - - - - - - - - - - - -
- -

0.018s

- -

testPostPublicKey

- -

0.004s

- -

testPostPublicKeyURLRequest

-
-
- - -
-
-

OctoKitTests.RepositoryTests

-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -

0.007s

- -

testFailToGetRepositories

- -

0.006s

- -

testFailToGetRepository

- -

0.009s

- -

testGetAuthenticatedRepositories

- -

0.013s

- -

testGetRepositories

- -

0.010s

- -

testGetRepository

- -

0.006s

- -

testReadAuthenticatedRepositoriesURLRequest

- -

0.004s

- -

testReadAuthenticatedRepositoriesURLRequestWithCustomPageAndPerPage

- -

0.006s

- -

testReadRepositoriesURLRequest

- -

0.007s

- -

testReadRepositoriesURLRequestWithCustomPageAndPerPage

- -

0.004s

- -

testReadRepositoryURLRequest

- -

0.005s

- -

testUserParsingFullRepository

-
-
- - -
-
-

OctoKitTests.StarsTests

-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -

0.006s

- -

testFailToGetStarredRepositories

- -

0.006s

- -

testFailToGetUsersStarredRepositories

- -

0.010s

- -

testGetStarredRepositories

- -

0.008s

- -

testGetUsersStarredRepositories

- -

0.008s

- -

testMyStarsURLRequest

- -

0.008s

- -

testReadStarsURLRequest

-
-
- - -
-
-

OctoKitTests.TimeTests

-
-
- - - - - - - - - - -
- -

0.003s

- -

testDateParsing

-
-
- - -
-
-

OctoKitTests.UserTests

-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -

0.015s

- -

testFailingToGetUser

- -

0.011s

- -

testFailToGetAuthenticatedUser

- -

0.007s

- -

testGettingAuthenticatedUser

- -

0.017s

- -

testGetUser

- -

0.004s

- -

testReadingAuthenticatedUserURLRequest

- -

0.005s

- -

testReadingUserURLRequest

- -

0.005s

- -

testUserParsingFullUser

- -

0.004s

- -

testUserParsingMinimalUser

-
-
- -
- - - diff --git a/fastlane/test-output/report.junit b/fastlane/test-output/report.junit deleted file mode 100644 index 2e31f770..00000000 --- a/fastlane/test-output/report.junit +++ /dev/null @@ -1,69 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file From 8450ab86cdcc4cc273c15031c93134ba6383b548 Mon Sep 17 00:00:00 2001 From: Piet Brauer Date: Mon, 22 Feb 2016 15:37:05 +0800 Subject: [PATCH 037/302] Add the schemes --- .../xcschemes/OctoKit Mac.xcscheme | 99 +++++++++++++++++++ .../xcschemes/OctoKit tvOS.xcscheme | 99 +++++++++++++++++++ .../xcschemes/OctoKit watchOS.xcscheme | 80 +++++++++++++++ 3 files changed, 278 insertions(+) create mode 100644 OctoKit.xcodeproj/xcshareddata/xcschemes/OctoKit Mac.xcscheme create mode 100644 OctoKit.xcodeproj/xcshareddata/xcschemes/OctoKit tvOS.xcscheme create mode 100644 OctoKit.xcodeproj/xcshareddata/xcschemes/OctoKit watchOS.xcscheme diff --git a/OctoKit.xcodeproj/xcshareddata/xcschemes/OctoKit Mac.xcscheme b/OctoKit.xcodeproj/xcshareddata/xcschemes/OctoKit Mac.xcscheme new file mode 100644 index 00000000..84724b78 --- /dev/null +++ b/OctoKit.xcodeproj/xcshareddata/xcschemes/OctoKit Mac.xcscheme @@ -0,0 +1,99 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OctoKit.xcodeproj/xcshareddata/xcschemes/OctoKit tvOS.xcscheme b/OctoKit.xcodeproj/xcshareddata/xcschemes/OctoKit tvOS.xcscheme new file mode 100644 index 00000000..362a2ef2 --- /dev/null +++ b/OctoKit.xcodeproj/xcshareddata/xcschemes/OctoKit tvOS.xcscheme @@ -0,0 +1,99 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OctoKit.xcodeproj/xcshareddata/xcschemes/OctoKit watchOS.xcscheme b/OctoKit.xcodeproj/xcshareddata/xcschemes/OctoKit watchOS.xcscheme new file mode 100644 index 00000000..b8e757aa --- /dev/null +++ b/OctoKit.xcodeproj/xcshareddata/xcschemes/OctoKit watchOS.xcscheme @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 38600797bb87afb8de62efa3494c2b8a6bafde33 Mon Sep 17 00:00:00 2001 From: Piet Brauer Date: Mon, 22 Feb 2016 15:52:11 +0800 Subject: [PATCH 038/302] Remove @testable and only test public APIs --- OctoKit.xcodeproj/project.pbxproj | 8 ------- OctoKitTests/ConfigurationTests.swift | 19 +-------------- OctoKitTests/FollowTests.swift | 28 +---------------------- OctoKitTests/PublicKeyTests.swift | 10 +------- OctoKitTests/RepositoryTests.swift | 33 +-------------------------- OctoKitTests/StarsTests.swift | 16 +------------ OctoKitTests/TimeTests.swift | 12 ---------- OctoKitTests/UserTests.swift | 16 +------------ 8 files changed, 6 insertions(+), 136 deletions(-) delete mode 100644 OctoKitTests/TimeTests.swift diff --git a/OctoKit.xcodeproj/project.pbxproj b/OctoKit.xcodeproj/project.pbxproj index 0975020d..97e15470 100644 --- a/OctoKit.xcodeproj/project.pbxproj +++ b/OctoKit.xcodeproj/project.pbxproj @@ -69,8 +69,6 @@ 23CAF2C51C7AB709005011C4 /* StarsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E7EE59D91BE10DA60012E3D2 /* StarsTests.swift */; }; 23CAF2C61C7AB70B005011C4 /* TestHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 234F4BCE1BDDE3F900A58EF7 /* TestHelper.swift */; }; 23CAF2C71C7AB70C005011C4 /* TestHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 234F4BCE1BDDE3F900A58EF7 /* TestHelper.swift */; }; - 23CAF2C81C7AB70E005011C4 /* TimeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F8711EA31BFCB02D005DDACA /* TimeTests.swift */; }; - 23CAF2C91C7AB70F005011C4 /* TimeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F8711EA31BFCB02D005DDACA /* TimeTests.swift */; }; 23CAF2CA1C7AB711005011C4 /* UserTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 234F4BCF1BDDE3F900A58EF7 /* UserTests.swift */; }; 23CAF2CB1C7AB712005011C4 /* UserTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 234F4BCF1BDDE3F900A58EF7 /* UserTests.swift */; }; 23CAF2CC1C7AB728005011C4 /* OctoKit.h in Headers */ = {isa = PBXBuildFile; fileRef = 239BE7CD1B8C47A100D2CE22 /* OctoKit.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -103,7 +101,6 @@ E7EE59DE1BE11C2A0012E3D2 /* FollowTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E7EE59DD1BE11C2A0012E3D2 /* FollowTests.swift */; }; E7EE59E01BE139FD0012E3D2 /* users.json in Resources */ = {isa = PBXBuildFile; fileRef = E7EE59DF1BE139FD0012E3D2 /* users.json */; }; F8711EA21BFCAE9F005DDACA /* Time.swift in Sources */ = {isa = PBXBuildFile; fileRef = F8711EA11BFCAE9F005DDACA /* Time.swift */; }; - F8711EA41BFCB02D005DDACA /* TimeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F8711EA31BFCB02D005DDACA /* TimeTests.swift */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -209,7 +206,6 @@ E7EE59DD1BE11C2A0012E3D2 /* FollowTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FollowTests.swift; sourceTree = ""; }; E7EE59DF1BE139FD0012E3D2 /* users.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = users.json; sourceTree = ""; }; F8711EA11BFCAE9F005DDACA /* Time.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Time.swift; sourceTree = ""; }; - F8711EA31BFCB02D005DDACA /* TimeTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TimeTests.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -286,7 +282,6 @@ 234F4BCD1BDDE3F900A58EF7 /* RepositoryTests.swift */, E7EE59D91BE10DA60012E3D2 /* StarsTests.swift */, 234F4BCE1BDDE3F900A58EF7 /* TestHelper.swift */, - F8711EA31BFCB02D005DDACA /* TimeTests.swift */, 234F4BCF1BDDE3F900A58EF7 /* UserTests.swift */, 234F4BAD1BDDE31A00A58EF7 /* Info.plist */, ); @@ -672,7 +667,6 @@ 234F4BD61BDDE3F900A58EF7 /* UserTests.swift in Sources */, 234F4BD31BDDE3F900A58EF7 /* PublicKeyTests.swift in Sources */, 234F4BD41BDDE3F900A58EF7 /* RepositoryTests.swift in Sources */, - F8711EA41BFCB02D005DDACA /* TimeTests.swift in Sources */, E7EE59DE1BE11C2A0012E3D2 /* FollowTests.swift in Sources */, 234F4BD51BDDE3F900A58EF7 /* TestHelper.swift in Sources */, 234F4BD01BDDE3F900A58EF7 /* ConfigurationTests.swift in Sources */, @@ -719,7 +713,6 @@ 23CAF2C41C7AB708005011C4 /* StarsTests.swift in Sources */, 23CAF2C61C7AB70B005011C4 /* TestHelper.swift in Sources */, 23CAF2BE1C7AB6FE005011C4 /* OctokitSwiftTests.swift in Sources */, - 23CAF2C81C7AB70E005011C4 /* TimeTests.swift in Sources */, 23CAF2C01C7AB702005011C4 /* PublicKeyTests.swift in Sources */, 23CAF2CA1C7AB711005011C4 /* UserTests.swift in Sources */, 23CAF2C21C7AB705005011C4 /* RepositoryTests.swift in Sources */, @@ -750,7 +743,6 @@ 23CAF2C51C7AB709005011C4 /* StarsTests.swift in Sources */, 23CAF2C71C7AB70C005011C4 /* TestHelper.swift in Sources */, 23CAF2BF1C7AB6FF005011C4 /* OctokitSwiftTests.swift in Sources */, - 23CAF2C91C7AB70F005011C4 /* TimeTests.swift in Sources */, 23CAF2C11C7AB702005011C4 /* PublicKeyTests.swift in Sources */, 23CAF2CB1C7AB712005011C4 /* UserTests.swift in Sources */, 23CAF2C31C7AB706005011C4 /* RepositoryTests.swift in Sources */, diff --git a/OctoKitTests/ConfigurationTests.swift b/OctoKitTests/ConfigurationTests.swift index 2aafcf1e..bb2514ce 100644 --- a/OctoKitTests/ConfigurationTests.swift +++ b/OctoKitTests/ConfigurationTests.swift @@ -1,6 +1,6 @@ import XCTest import Foundation -@testable import OctoKit +import OctoKit import Nocilla class ConfigurationTests: XCTestCase { @@ -41,23 +41,6 @@ class ConfigurationTests: XCTestCase { XCTAssertEqual(subject.apiEndpoint, enterpriseURL) } - func testAuthorizeURLRequest() { - let config = OAuthConfiguration(token: "12345", secret: "6789", scopes: ["repo", "read:org"]) - let request = OAuthRouter.Authorize(config).URLRequest - let expected = NSURL(string: "https://github.com/login/oauth/authorize?client_id=12345&scope=repo%2Cread%3Aorg")! - XCTAssertEqual(request!.URL!, expected) - } - - func testAccessTokenURLRequest() { - let config = OAuthConfiguration(token: "12345", secret: "6789", scopes: ["repo", "read:org"]) - let request = OAuthRouter.AccessToken(config, "dhfjgh23493").URLRequest - let expected = NSURL(string: "https://github.com/login/oauth/access_token")! - let expectedBody = "client_id=12345&client_secret=6789&code=dhfjgh23493" - XCTAssertEqual(request!.URL!, expected) - let string = NSString(data: request!.HTTPBody!, encoding: NSUTF8StringEncoding)! - XCTAssertEqual(string as String, expectedBody) - } - func testAccessTokenFromResponse() { let config = OAuthConfiguration(token: "12345", secret: "6789", scopes: ["repo", "read:org"]) let response = "access_token=017ec60f4a182&scope=read%3Aorg%2Crepo&token_type=bearer" diff --git a/OctoKitTests/FollowTests.swift b/OctoKitTests/FollowTests.swift index 75394c73..f91b37dd 100644 --- a/OctoKitTests/FollowTests.swift +++ b/OctoKitTests/FollowTests.swift @@ -1,5 +1,5 @@ import XCTest -@testable import OctoKit +import OctoKit import Nocilla class FollowTests: XCTestCase { @@ -13,32 +13,6 @@ class FollowTests: XCTestCase { LSNocilla.sharedInstance().clearStubs() LSNocilla.sharedInstance().stop() } - - // MARK: URLRequest Tests - - func testReadingUserFollowersURLRequest() { - let kit = Octokit() - let request = FollowRouter.ReadFollowers("octocat", kit.configuration).URLRequest - XCTAssertEqual(request!.URL!, NSURL(string: "https://api.github.com/users/octocat/followers")!) - } - - func testReadingAuthenticatedUserFollowersURLRequest() { - let kit = Octokit(TokenConfiguration("12345")) - let request = FollowRouter.ReadAuthenticatedFollowers(kit.configuration).URLRequest - XCTAssertEqual(request!.URL!, NSURL(string: "https://api.github.com/user/followers?access_token=12345")!) - } - - func testReadingUserFollowingURLRequest() { - let kit = Octokit() - let request = FollowRouter.ReadFollowing("octocat", kit.configuration).URLRequest - XCTAssertEqual(request!.URL!, NSURL(string: "https://api.github.com/users/octocat/following")!) - } - - func testReadingAuthenticatedUserFollowingURLRequest() { - let kit = Octokit(TokenConfiguration("12345")) - let request = FollowRouter.ReadAuthenticatedFollowing(kit.configuration).URLRequest - XCTAssertEqual(request!.URL!, NSURL(string: "https://api.github.com/user/following?access_token=12345")!) - } // MARK: Actual Request tests diff --git a/OctoKitTests/PublicKeyTests.swift b/OctoKitTests/PublicKeyTests.swift index 07711124..54872cec 100644 --- a/OctoKitTests/PublicKeyTests.swift +++ b/OctoKitTests/PublicKeyTests.swift @@ -1,5 +1,5 @@ import XCTest -@testable import OctoKit +import OctoKit import Nocilla class PublicKeyTests: XCTestCase { @@ -14,14 +14,6 @@ class PublicKeyTests: XCTestCase { LSNocilla.sharedInstance().stop() } - // MARK: URLRequest Tests - - func testPostPublicKeyURLRequest() { - let kit = Octokit(TokenConfiguration("12345")) - let request = PublicKeyRouter.PostPublicKey("test-key", "test title", kit.configuration).URLRequest - XCTAssertEqual(request!.URL!, NSURL(string: "https://api.github.com/user/keys?access_token=12345")!) - } - // MARK: Actual Request tests func testPostPublicKey() { diff --git a/OctoKitTests/RepositoryTests.swift b/OctoKitTests/RepositoryTests.swift index fb40f752..03f9b902 100644 --- a/OctoKitTests/RepositoryTests.swift +++ b/OctoKitTests/RepositoryTests.swift @@ -1,5 +1,5 @@ import XCTest -@testable import OctoKit +import OctoKit import Nocilla class RepositoryTests: XCTestCase { @@ -14,37 +14,6 @@ class RepositoryTests: XCTestCase { LSNocilla.sharedInstance().stop() } - // MARK: URLRequest Tests - - func testReadRepositoriesURLRequest() { - let kit = Octokit(TokenConfiguration()) - let request = RepositoryRouter.ReadRepositories(kit.configuration, "octocat", "1", "100").URLRequest - XCTAssertEqual(request!.URL!, NSURL(string: "https://api.github.com/users/octocat/repos?page=1&per_page=100")!) - } - - func testReadRepositoriesURLRequestWithCustomPageAndPerPage() { - let kit = Octokit(TokenConfiguration()) - let request = RepositoryRouter.ReadRepositories(kit.configuration, "octocat", "5", "50").URLRequest - XCTAssertEqual(request!.URL!, NSURL(string: "https://api.github.com/users/octocat/repos?page=5&per_page=50")!) - } - - func testReadAuthenticatedRepositoriesURLRequest() { - let kit = Octokit(TokenConfiguration("12345")) - let request = RepositoryRouter.ReadAuthenticatedRepositories(kit.configuration, "1", "100").URLRequest - XCTAssertEqual(request!.URL!, NSURL(string: "https://api.github.com/user/repos?access_token=12345&page=1&per_page=100")!) - } - - func testReadAuthenticatedRepositoriesURLRequestWithCustomPageAndPerPage() { - let kit = Octokit(TokenConfiguration("12345")) - let request = RepositoryRouter.ReadAuthenticatedRepositories(kit.configuration, "5", "50").URLRequest - XCTAssertEqual(request!.URL!, NSURL(string: "https://api.github.com/user/repos?access_token=12345&page=5&per_page=50")!) - } - - func testReadRepositoryURLRequest() { - let request = RepositoryRouter.ReadRepository(Octokit().configuration, "mietzmithut", "Test").URLRequest - XCTAssertEqual(request!.URL!, NSURL(string: "https://api.github.com/repos/mietzmithut/Test")!) - } - // MARK: Actual Request tests func testGetRepositories() { diff --git a/OctoKitTests/StarsTests.swift b/OctoKitTests/StarsTests.swift index db85b839..5aeae96a 100644 --- a/OctoKitTests/StarsTests.swift +++ b/OctoKitTests/StarsTests.swift @@ -1,5 +1,5 @@ import XCTest -@testable import OctoKit +import OctoKit import Nocilla class StarsTests: XCTestCase { @@ -15,20 +15,6 @@ class StarsTests: XCTestCase { LSNocilla.sharedInstance().stop() } - // MARK: URLRequest Tests - - func testReadStarsURLRequest() { - let kit = Octokit(TokenConfiguration("12345")) - let request = StarsRouter.ReadStars("octocat", kit.configuration).URLRequest - XCTAssertEqual(request!.URL!, NSURL(string: "https://api.github.com/users/octocat/starred?access_token=12345")!) - } - - func testMyStarsURLRequest() { - let kit = Octokit(TokenConfiguration("12345")) - let request = StarsRouter.ReadAuthenticatedStars(kit.configuration).URLRequest - XCTAssertEqual(request!.URL!, NSURL(string: "https://api.github.com/user/starred?access_token=12345")!) - } - // MARK: Actual Request tests func testGetStarredRepositories() { diff --git a/OctoKitTests/TimeTests.swift b/OctoKitTests/TimeTests.swift deleted file mode 100644 index 08a4cae4..00000000 --- a/OctoKitTests/TimeTests.swift +++ /dev/null @@ -1,12 +0,0 @@ -import XCTest -@testable import OctoKit - -class TimeTests: XCTestCase { - func testDateParsing() { - // "pushed_at": "2015-04-28T13:38:52Z", - let string = "2015-04-28T13:38:52Z" - let date = Time.rfc3339Date(string) - XCTAssertNotNil(date) - XCTAssertEqual(date!, NSDate(timeIntervalSinceReferenceDate: 451921132)) - } -} diff --git a/OctoKitTests/UserTests.swift b/OctoKitTests/UserTests.swift index c44565f4..c0377e7e 100644 --- a/OctoKitTests/UserTests.swift +++ b/OctoKitTests/UserTests.swift @@ -1,5 +1,5 @@ import XCTest -@testable import OctoKit +import OctoKit import Nocilla class UserTests: XCTestCase { @@ -14,20 +14,6 @@ class UserTests: XCTestCase { LSNocilla.sharedInstance().stop() } - // MARK: URLRequest Tests - - func testReadingUserURLRequest() { - let kit = Octokit() - let request = UserRouter.ReadUser("mietzmithut", kit.configuration).URLRequest - XCTAssertEqual(request!.URL!, NSURL(string: "https://api.github.com/users/mietzmithut")!) - } - - func testReadingAuthenticatedUserURLRequest() { - let kit = Octokit(TokenConfiguration("12345")) - let request = UserRouter.ReadAuthenticatedUser(kit.configuration).URLRequest - XCTAssertEqual(request!.URL!, NSURL(string: "https://api.github.com/user?access_token=12345")!) - } - // MARK: Actual Request tests func testGetUser() { From d8a7c4d697760a264c1df9e2d158cb5d255b06df Mon Sep 17 00:00:00 2001 From: Piet Brauer Date: Tue, 23 Feb 2016 08:46:25 +0800 Subject: [PATCH 039/302] Enable code coverage --- Makefile | 2 +- OctoKit.xcodeproj/xcshareddata/xcschemes/OctoKit.xcscheme | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 85fad3f7..49840e5e 100644 --- a/Makefile +++ b/Makefile @@ -9,6 +9,6 @@ test: bundle exec fastlane code_coverage configuration:Debug --env default post_coverage: - bundle exec slather coverage --input-format profdata -x --ignore "../**/*/Xcode*" --ignore "Carthage/**" --output-directory slather-report --scheme OctoKit Octokit.xcodeproj + bundle exec slather coverage --input-format profdata -x --ignore "../**/*/Xcode*" --ignore "Carthage/**" --output-directory slather-report --scheme OctoKit OctoKit.xcodeproj curl -X POST -d @slather-report/cobertura.xml "https://codecov.io/upload/v2?token="$(CODECOV_TOKEN)"&commit="$(SHA)"&branch="$(BRANCH)"&job="$(TRAVIS_BUILD_NUMBER) diff --git a/OctoKit.xcodeproj/xcshareddata/xcschemes/OctoKit.xcscheme b/OctoKit.xcodeproj/xcshareddata/xcschemes/OctoKit.xcscheme index 3d2d5db0..a3a3599f 100644 --- a/OctoKit.xcodeproj/xcshareddata/xcschemes/OctoKit.xcscheme +++ b/OctoKit.xcodeproj/xcshareddata/xcschemes/OctoKit.xcscheme @@ -26,7 +26,8 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" - shouldUseLaunchSchemeArgsEnv = "YES"> + shouldUseLaunchSchemeArgsEnv = "YES" + codeCoverageEnabled = "YES"> From 4df9639dd8497ae0a6cfd3dd159b021f0b2f500a Mon Sep 17 00:00:00 2001 From: Piet Brauer Date: Tue, 23 Feb 2016 09:01:17 +0800 Subject: [PATCH 040/302] Add all platforms --- OctoKit.swift.podspec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/OctoKit.swift.podspec b/OctoKit.swift.podspec index f3c95500..fc066553 100644 --- a/OctoKit.swift.podspec +++ b/OctoKit.swift.podspec @@ -13,7 +13,10 @@ Pod::Spec.new do |s| s.social_media_url = "https://twitter.com/pietbrauer" s.module_name = "Octokit" s.dependency "NBNRequestKit", "~> 0.2.1" - s.platform = :ios, "8.0" s.requires_arc = true s.source_files = "OctoKit/*.swift" + s.ios.deployment_target = '8.0' + s.osx.deployment_target = '10.10' + s.watchos.deployment_target = '2.0' + s.tvos.deployment_target = '9.0' end From 43da8a3dce7a0656ad9ebefc5f9d629f641779d6 Mon Sep 17 00:00:00 2001 From: Piet Brauer Date: Tue, 23 Feb 2016 16:14:22 +0800 Subject: [PATCH 041/302] Remove obsolete URLRequest and use default protocol implementation --- OctoKit/Follow.swift | 4 ---- OctoKit/PublicKey.swift | 7 ------- OctoKit/Repositories.swift | 11 ----------- OctoKit/User.swift | 9 --------- 4 files changed, 31 deletions(-) diff --git a/OctoKit/Follow.swift b/OctoKit/Follow.swift index 9bb58fa9..9a76993f 100644 --- a/OctoKit/Follow.swift +++ b/OctoKit/Follow.swift @@ -117,8 +117,4 @@ enum FollowRouter: Router { var params: [String: String] { return [:] } - - var URLRequest: NSURLRequest? { - return request() - } } diff --git a/OctoKit/PublicKey.swift b/OctoKit/PublicKey.swift index 1b496be2..02d97316 100644 --- a/OctoKit/PublicKey.swift +++ b/OctoKit/PublicKey.swift @@ -54,11 +54,4 @@ enum PublicKeyRouter: JSONPostRouter { return ["title": title, "key": publicKey] } } - - var URLRequest: NSURLRequest? { - switch self { - case .PostPublicKey(_, _, _): - return request() - } - } } diff --git a/OctoKit/Repositories.swift b/OctoKit/Repositories.swift index b9f041b8..fa69b713 100644 --- a/OctoKit/Repositories.swift +++ b/OctoKit/Repositories.swift @@ -133,15 +133,4 @@ enum RepositoryRouter: Router { return "/repos/\(owner)/\(name)" } } - - var URLRequest: NSURLRequest? { - switch self { - case .ReadRepositories(_, _, _, _): - return request() - case .ReadAuthenticatedRepositories(_, _, _): - return request() - case .ReadRepository(_, _, _): - return request() - } - } } diff --git a/OctoKit/User.swift b/OctoKit/User.swift index a38043df..545e5cdc 100644 --- a/OctoKit/User.swift +++ b/OctoKit/User.swift @@ -114,13 +114,4 @@ enum UserRouter: Router { var params: [String: String] { return [:] } - - var URLRequest: NSURLRequest? { - switch self { - case .ReadAuthenticatedUser(_): - return request() - case .ReadUser(_, _): - return request() - } - } } From 4c25fda8f73e09c99b10a7906610e7c700d360c3 Mon Sep 17 00:00:00 2001 From: Piet Brauer Date: Thu, 25 Feb 2016 10:59:30 +0800 Subject: [PATCH 042/302] Use released RequestKit and set deployment targets --- Cartfile | 2 +- Cartfile.resolved | 2 +- OctoKit.swift.podspec | 2 +- OctoKit.xcodeproj/project.pbxproj | 8 ++++---- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Cartfile b/Cartfile index ea52812c..1676ef82 100644 --- a/Cartfile +++ b/Cartfile @@ -1 +1 @@ -github "nerdishbynature/RequestKit" "all-platforms" +github "nerdishbynature/RequestKit" ~> 0.2.2 diff --git a/Cartfile.resolved b/Cartfile.resolved index eb8e15d3..f253b411 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1,2 +1,2 @@ github "nerdishbynature/Nocilla" "57161f3454bebebf111e3e3b2a0b9cb300e2d0ac" -github "nerdishbynature/RequestKit" "928682d476221bf60705257f9d220836017baa65" +github "nerdishbynature/RequestKit" "0.2.2" diff --git a/OctoKit.swift.podspec b/OctoKit.swift.podspec index fc066553..7d84e4cd 100644 --- a/OctoKit.swift.podspec +++ b/OctoKit.swift.podspec @@ -12,7 +12,7 @@ Pod::Spec.new do |s| s.source = { :git => "https://github.com/nerdishbynature/octokit.swift.git", :tag => s.version.to_s } s.social_media_url = "https://twitter.com/pietbrauer" s.module_name = "Octokit" - s.dependency "NBNRequestKit", "~> 0.2.1" + s.dependency "NBNRequestKit", "~> 0.2.2" s.requires_arc = true s.source_files = "OctoKit/*.swift" s.ios.deployment_target = '8.0' diff --git a/OctoKit.xcodeproj/project.pbxproj b/OctoKit.xcodeproj/project.pbxproj index 97e15470..707e06d9 100644 --- a/OctoKit.xcodeproj/project.pbxproj +++ b/OctoKit.xcodeproj/project.pbxproj @@ -896,7 +896,7 @@ SDKROOT = appletvos; SKIP_INSTALL = YES; TARGETED_DEVICE_FAMILY = 3; - TVOS_DEPLOYMENT_TARGET = 9.1; + TVOS_DEPLOYMENT_TARGET = 9.0; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; }; @@ -922,7 +922,7 @@ SDKROOT = appletvos; SKIP_INSTALL = YES; TARGETED_DEVICE_FAMILY = 3; - TVOS_DEPLOYMENT_TARGET = 9.1; + TVOS_DEPLOYMENT_TARGET = 9.0; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; }; @@ -984,7 +984,7 @@ GCC_NO_COMMON_BLOCKS = YES; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; - MACOSX_DEPLOYMENT_TARGET = 10.11; + MACOSX_DEPLOYMENT_TARGET = 10.10; SDKROOT = macosx; SKIP_INSTALL = YES; VERSIONING_SYSTEM = "apple-generic"; @@ -1012,7 +1012,7 @@ GCC_NO_COMMON_BLOCKS = YES; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; - MACOSX_DEPLOYMENT_TARGET = 10.11; + MACOSX_DEPLOYMENT_TARGET = 10.10; SDKROOT = macosx; SKIP_INSTALL = YES; VERSIONING_SYSTEM = "apple-generic"; From 0921d8577fb3bfef7a10bec2509a33f2376ae5dd Mon Sep 17 00:00:00 2001 From: Piet Brauer Date: Thu, 25 Feb 2016 11:44:05 +0800 Subject: [PATCH 043/302] Remove iOS 9.3 Xcode 7.3 tests --- .travis.yml | 2 -- fastlane/.env.ios93_xcode73 | 3 --- 2 files changed, 5 deletions(-) delete mode 100644 fastlane/.env.ios93_xcode73 diff --git a/.travis.yml b/.travis.yml index 17a4dbbf..d8b84311 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,8 +16,6 @@ matrix: env: FASTLANE_ENV=tvos91 - osx_image: xcode7.2 env: FASTLANE_ENV=osx - - osx_image: xcode7.3 - env: FASTLANE_ENV=ios93_xcode73 before_install: - make install script: diff --git a/fastlane/.env.ios93_xcode73 b/fastlane/.env.ios93_xcode73 deleted file mode 100644 index b0516eb0..00000000 --- a/fastlane/.env.ios93_xcode73 +++ /dev/null @@ -1,3 +0,0 @@ -SCAN_DESTINATION="OS=9.3,name=iPhone 6s" -EXAMPLE_DESTINATION=$SCAN_DESTINATION -SCAN_SDK=iphonesimulator9.3 \ No newline at end of file From bd469acc7169652e09cddb6e1c0132df729b629c Mon Sep 17 00:00:00 2001 From: Piet Brauer Date: Thu, 25 Feb 2016 13:35:50 +0800 Subject: [PATCH 044/302] Bump version --- OctoKit.swift.podspec | 2 +- OctoKit/Info.plist | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/OctoKit.swift.podspec b/OctoKit.swift.podspec index 7d84e4cd..da0d34b5 100644 --- a/OctoKit.swift.podspec +++ b/OctoKit.swift.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "OctoKit.swift" - s.version = "0.5.1" + s.version = "0.5.2" s.summary = "A Swift API Client for GitHub and GitHub Enterprise" s.description = <<-DESC You are looking at the A Swift API Client for GitHub and GitHub Enterprise. diff --git a/OctoKit/Info.plist b/OctoKit/Info.plist index 504fc36a..0d4fc0a8 100644 --- a/OctoKit/Info.plist +++ b/OctoKit/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 0.5.1 + 0.5.2 CFBundleSignature ???? CFBundleVersion From 4338212503ed02d180a25e751728e46e366de17f Mon Sep 17 00:00:00 2001 From: thomaspaulmann Date: Mon, 29 Feb 2016 11:36:48 +0100 Subject: [PATCH 045/302] Add support for Issues of authenticated User --- OctoKit/Issue.swift | 92 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 OctoKit/Issue.swift diff --git a/OctoKit/Issue.swift b/OctoKit/Issue.swift new file mode 100644 index 00000000..46c5bafd --- /dev/null +++ b/OctoKit/Issue.swift @@ -0,0 +1,92 @@ +import Foundation +import RequestKit + +// MARK: model + +@objc public class Issue: NSObject { + public let id: Int + public var url: String? + public var number: Int? + public var title: String? + public var body: String? + public var state: String? + public var user: User? + public var assignee: User? + public var createdAt: NSDate? + public var closedAt: NSDate? + public var updatedAt: NSDate? + + public init(_ json: [String: AnyObject]) { + if let id = json["id"] as? Int { + self.id = id + url = json["url"] as? String + number = json["number"] as? Int + title = json["title"] as? String + body = json["body"] as? String + state = json["state"] as? String + user = User(json["user"] as? [String: AnyObject] ?? [:]) + assignee = User(json["assignee"] as? [String: AnyObject] ?? [:]) + createdAt = Time.rfc3339Date(json["created_at"] as? String) + closedAt = Time.rfc3339Date(json["closed_at"] as? String) + updatedAt = Time.rfc3339Date(json["updated_at"] as? String) + } else { + id = -1 + } + } +} + +// MARK: request + +public extension Octokit { + + /** + Fetches the issues of the authenticated user + - parameter completion: Callback for the outcome of the fetch. + */ + public func myIssues(completion: (response: Response<[Issue]>) -> Void) { + let router = IssueRouter.ReadAuthenticatedIssues(configuration) + router.loadJSON([[String: AnyObject]].self) { json, error in + if let error = error { + completion(response: Response.Failure(error)) + } else { + if let json = json { + let parsedIssue = json.map { Issue($0) } + completion(response: Response.Success(parsedIssue)) + } + } + } + } +} + +// MARK: Router + +enum IssueRouter: Router { + case ReadAuthenticatedIssues(Configuration) + + var method: HTTPMethod { + return .GET + } + + var encoding: HTTPEncoding { + return .URL + } + + var configuration: Configuration { + switch self { + case .ReadAuthenticatedIssues(let config): return config + } + } + + var path: String { + switch self { + case .ReadAuthenticatedIssues: + return "user/issues" + } + } + + var params: [String: String] { + return [:] + } +} + + From 6ba4dcde78c4e53b6aaa3f9c11d4f83ce54a7615 Mon Sep 17 00:00:00 2001 From: thomaspaulmann Date: Mon, 29 Feb 2016 11:37:01 +0100 Subject: [PATCH 046/302] Add Tests for fetching Issues of User --- OctoKitTests/IssueTests.swift | 41 +++++++++++++ OctoKitTests/issue.json | 106 ++++++++++++++++++++++++++++++++++ 2 files changed, 147 insertions(+) create mode 100644 OctoKitTests/IssueTests.swift create mode 100644 OctoKitTests/issue.json diff --git a/OctoKitTests/IssueTests.swift b/OctoKitTests/IssueTests.swift new file mode 100644 index 00000000..0aedcfcf --- /dev/null +++ b/OctoKitTests/IssueTests.swift @@ -0,0 +1,41 @@ +import XCTest +import OctoKit +import Nocilla + +class IssueTests: XCTestCase { + override func setUp() { + super.setUp() + LSNocilla.sharedInstance().start() + } + + override func tearDown() { + super.tearDown() + LSNocilla.sharedInstance().clearStubs() + LSNocilla.sharedInstance().stop() + } + + // MARK: Actual Request tests + + func testGetMyIssues() { + let config = TokenConfiguration("12345") + if let json = Helper.stringFromFile("issue") { + stubRequest("GET", "https://api.github.com/user/issues?access_token=12345").andReturn(200).withHeaders(["Content-Type": "application/json"]).withBody(json) + let expectation = expectationWithDescription("user_issues") + Octokit(config).myIssues() { response in + switch response { + case .Success(let issues): + XCTAssertEqual(issues.count, 1) + expectation.fulfill() + case .Failure: + XCTAssert(false, "should not get an error") + expectation.fulfill() + } + } + waitForExpectationsWithTimeout(1) { (error) in + XCTAssertNil(error, "\(error)") + } + } else { + XCTFail("json shouldn't be nil") + } + } +} \ No newline at end of file diff --git a/OctoKitTests/issue.json b/OctoKitTests/issue.json new file mode 100644 index 00000000..7046abff --- /dev/null +++ b/OctoKitTests/issue.json @@ -0,0 +1,106 @@ + [ + { + "id": 1, + "url": "https://api.github.com/repos/octocat/Hello-World/issues/1347", + "repository_url": "https://api.github.com/repos/octocat/Hello-World", + "labels_url": "https://api.github.com/repos/octocat/Hello-World/issues/1347/labels{/name}", + "comments_url": "https://api.github.com/repos/octocat/Hello-World/issues/1347/comments", + "events_url": "https://api.github.com/repos/octocat/Hello-World/issues/1347/events", + "html_url": "https://github.com/octocat/Hello-World/issues/1347", + "number": 1347, + "state": "open", + "title": "Found a bug", + "body": "I'm having a problem with this.", + "user": { + "login": "octocat", + "id": 1, + "avatar_url": "https://github.com/images/error/octocat_happy.gif", + "gravatar_id": "", + "url": "https://api.github.com/users/octocat", + "html_url": "https://github.com/octocat", + "followers_url": "https://api.github.com/users/octocat/followers", + "following_url": "https://api.github.com/users/octocat/following{/other_user}", + "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", + "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", + "organizations_url": "https://api.github.com/users/octocat/orgs", + "repos_url": "https://api.github.com/users/octocat/repos", + "events_url": "https://api.github.com/users/octocat/events{/privacy}", + "received_events_url": "https://api.github.com/users/octocat/received_events", + "type": "User", + "site_admin": false + }, + "labels": [ + { + "url": "https://api.github.com/repos/octocat/Hello-World/labels/bug", + "name": "bug", + "color": "f29513" + } + ], + "assignee": { + "login": "octocat", + "id": 1, + "avatar_url": "https://github.com/images/error/octocat_happy.gif", + "gravatar_id": "", + "url": "https://api.github.com/users/octocat", + "html_url": "https://github.com/octocat", + "followers_url": "https://api.github.com/users/octocat/followers", + "following_url": "https://api.github.com/users/octocat/following{/other_user}", + "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", + "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", + "organizations_url": "https://api.github.com/users/octocat/orgs", + "repos_url": "https://api.github.com/users/octocat/repos", + "events_url": "https://api.github.com/users/octocat/events{/privacy}", + "received_events_url": "https://api.github.com/users/octocat/received_events", + "type": "User", + "site_admin": false + }, + "milestone": { + "url": "https://api.github.com/repos/octocat/Hello-World/milestones/1", + "html_url": "https://github.com/octocat/Hello-World/milestones/v1.0", + "labels_url": "https://api.github.com/repos/octocat/Hello-World/milestones/1/labels", + "id": 1002604, + "number": 1, + "state": "open", + "title": "v1.0", + "description": "Tracking milestone for version 1.0", + "creator": { + "login": "octocat", + "id": 1, + "avatar_url": "https://github.com/images/error/octocat_happy.gif", + "gravatar_id": "", + "url": "https://api.github.com/users/octocat", + "html_url": "https://github.com/octocat", + "followers_url": "https://api.github.com/users/octocat/followers", + "following_url": "https://api.github.com/users/octocat/following{/other_user}", + "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", + "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", + "organizations_url": "https://api.github.com/users/octocat/orgs", + "repos_url": "https://api.github.com/users/octocat/repos", + "events_url": "https://api.github.com/users/octocat/events{/privacy}", + "received_events_url": "https://api.github.com/users/octocat/received_events", + "type": "User", + "site_admin": false + }, + "open_issues": 4, + "closed_issues": 8, + "created_at": "2011-04-10T20:09:31Z", + "updated_at": "2014-03-03T18:58:10Z", + "closed_at": "2013-02-12T13:22:01Z", + "due_on": "2012-10-09T23:39:01Z" + }, + "locked": false, + "comments": 0, + "pull_request": { + "url": "https://api.github.com/repos/octocat/Hello-World/pulls/1347", + "html_url": "https://github.com/octocat/Hello-World/pull/1347", + "diff_url": "https://github.com/octocat/Hello-World/pull/1347.diff", + "patch_url": "https://github.com/octocat/Hello-World/pull/1347.patch" + }, + "closed_at": null, + "created_at": "2011-04-22T13:33:48Z", + "updated_at": "2011-04-22T13:33:48Z" + } +] \ No newline at end of file From 1ed1ca57fcb51410c2afea55895de512207f6e20 Mon Sep 17 00:00:00 2001 From: thomaspaulmann Date: Mon, 29 Feb 2016 11:41:57 +0100 Subject: [PATCH 047/302] Add Usage of Issues to README --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.md b/README.md index d532ee64..bf061fa0 100644 --- a/README.md +++ b/README.md @@ -245,3 +245,16 @@ Octokit().myFollowing() { response in } ``` +## Issues + +```swift +Octokit(config).myIssues() { response in + switch response { + case .Success(let issues): + // do something with the issues + case .Failure: + // handle any errors + } +} +``` + From 86c3fd7d128a13b5a58c39da1a18dc33d551bfe1 Mon Sep 17 00:00:00 2001 From: thomaspaulmann Date: Mon, 29 Feb 2016 21:05:14 +0100 Subject: [PATCH 048/302] Add paging for Issues --- OctoKit/Issue.swift | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/OctoKit/Issue.swift b/OctoKit/Issue.swift index 46c5bafd..8ca2445a 100644 --- a/OctoKit/Issue.swift +++ b/OctoKit/Issue.swift @@ -41,17 +41,19 @@ public extension Octokit { /** Fetches the issues of the authenticated user + - parameter page: Current page for issue pagination. `1` by default. + - parameter perPage: Number of issues per page. `100` by default. - parameter completion: Callback for the outcome of the fetch. */ - public func myIssues(completion: (response: Response<[Issue]>) -> Void) { - let router = IssueRouter.ReadAuthenticatedIssues(configuration) + public func myIssues(page: String = "1", perPage: String = "100", completion: (response: Response<[Issue]>) -> Void) { + let router = IssueRouter.ReadAuthenticatedIssues(configuration, page, perPage) router.loadJSON([[String: AnyObject]].self) { json, error in if let error = error { completion(response: Response.Failure(error)) } else { if let json = json { - let parsedIssue = json.map { Issue($0) } - completion(response: Response.Success(parsedIssue)) + let parsedIssues = json.map { Issue($0) } + completion(response: Response.Success(parsedIssues)) } } } @@ -61,7 +63,7 @@ public extension Octokit { // MARK: Router enum IssueRouter: Router { - case ReadAuthenticatedIssues(Configuration) + case ReadAuthenticatedIssues(Configuration, String, String) var method: HTTPMethod { return .GET @@ -73,19 +75,23 @@ enum IssueRouter: Router { var configuration: Configuration { switch self { - case .ReadAuthenticatedIssues(let config): return config + case .ReadAuthenticatedIssues(let config, _, _): + return config } } - var path: String { + var params: [String: String] { switch self { - case .ReadAuthenticatedIssues: - return "user/issues" + case .ReadAuthenticatedIssues(_, let page, let perPage): + return ["per_page": perPage, "page": page] } } - var params: [String: String] { - return [:] + var path: String { + switch self { + case .ReadAuthenticatedIssues: + return "issues" + } } } From 2f11d9a0d50ea7aca9e177c46bc53cc68bd7fbbd Mon Sep 17 00:00:00 2001 From: thomaspaulmann Date: Mon, 29 Feb 2016 21:30:40 +0100 Subject: [PATCH 049/302] Fix Test for Issues --- OctoKitTests/IssueTests.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OctoKitTests/IssueTests.swift b/OctoKitTests/IssueTests.swift index 0aedcfcf..cb6c794a 100644 --- a/OctoKitTests/IssueTests.swift +++ b/OctoKitTests/IssueTests.swift @@ -19,8 +19,8 @@ class IssueTests: XCTestCase { func testGetMyIssues() { let config = TokenConfiguration("12345") if let json = Helper.stringFromFile("issue") { - stubRequest("GET", "https://api.github.com/user/issues?access_token=12345").andReturn(200).withHeaders(["Content-Type": "application/json"]).withBody(json) - let expectation = expectationWithDescription("user_issues") + stubRequest("GET", "https://api.github.com/issues?access_token=12345&page=1&per_page=100").andReturn(200).withHeaders(["Content-Type": "application/json"]).withBody(json) + let expectation = expectationWithDescription("issues") Octokit(config).myIssues() { response in switch response { case .Success(let issues): From b9730045d6e0e649286f09e8adc6ebbac66680c0 Mon Sep 17 00:00:00 2001 From: thomaspaulmann Date: Tue, 1 Mar 2016 18:38:05 +0100 Subject: [PATCH 050/302] Update README for better understanding of myIssues() --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index bf061fa0..3bdbcdd7 100644 --- a/README.md +++ b/README.md @@ -247,6 +247,8 @@ Octokit().myFollowing() { response in ## Issues +Get all issues across all the authenticated user's visible repositories including owned repositories, member repositories, and organization repositories. + ```swift Octokit(config).myIssues() { response in switch response { From 58669e1f05a82ddc7696e040b07b3fba180752c4 Mon Sep 17 00:00:00 2001 From: Nate West Date: Wed, 2 Mar 2016 08:10:59 -0500 Subject: [PATCH 051/302] Add Issue files to the .xcodeproj --- OctoKit.xcodeproj/project.pbxproj | 12 ++++++++++++ OctoKitTests/{ => Fixtures}/issue.json | 0 2 files changed, 12 insertions(+) rename OctoKitTests/{ => Fixtures}/issue.json (100%) diff --git a/OctoKit.xcodeproj/project.pbxproj b/OctoKit.xcodeproj/project.pbxproj index 707e06d9..1d628c4e 100644 --- a/OctoKit.xcodeproj/project.pbxproj +++ b/OctoKit.xcodeproj/project.pbxproj @@ -95,6 +95,9 @@ 23F6434F1C7AEF70000427B3 /* user_repos.json in Resources */ = {isa = PBXBuildFile; fileRef = 234F4BDC1BDDE44600A58EF7 /* user_repos.json */; }; 23F643501C7AEF72000427B3 /* users.json in Resources */ = {isa = PBXBuildFile; fileRef = E7EE59DF1BE139FD0012E3D2 /* users.json */; }; 23F643511C7AEF73000427B3 /* users.json in Resources */ = {isa = PBXBuildFile; fileRef = E7EE59DF1BE139FD0012E3D2 /* users.json */; }; + E7EDEA6A1C871CEB006BAAF2 /* Issue.swift in Sources */ = {isa = PBXBuildFile; fileRef = E7EDEA691C871CEB006BAAF2 /* Issue.swift */; }; + E7EDEA6C1C871D01006BAAF2 /* IssueTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E7EDEA6B1C871D01006BAAF2 /* IssueTests.swift */; }; + E7EDEA6E1C871D0E006BAAF2 /* issue.json in Resources */ = {isa = PBXBuildFile; fileRef = E7EDEA6D1C871D0E006BAAF2 /* issue.json */; }; E7EE59D81BDFEFB30012E3D2 /* Stars.swift in Sources */ = {isa = PBXBuildFile; fileRef = E7EE59D71BDFEFB30012E3D2 /* Stars.swift */; }; E7EE59DA1BE10DA60012E3D2 /* StarsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E7EE59D91BE10DA60012E3D2 /* StarsTests.swift */; }; E7EE59DC1BE119110012E3D2 /* Follow.swift in Sources */ = {isa = PBXBuildFile; fileRef = E7EE59DB1BE119110012E3D2 /* Follow.swift */; }; @@ -200,6 +203,9 @@ 23CAF2D81C7AB9DB005011C4 /* RequestKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = RequestKit.framework; path = Carthage/Build/watchOS/RequestKit.framework; sourceTree = ""; }; 23F6433C1C7AEEB6000427B3 /* Nocilla.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Nocilla.framework; path = Carthage/Build/tvOS/Nocilla.framework; sourceTree = ""; }; 23F643421C7AEF2F000427B3 /* Nocilla.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Nocilla.framework; path = Carthage/Build/Mac/Nocilla.framework; sourceTree = ""; }; + E7EDEA691C871CEB006BAAF2 /* Issue.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Issue.swift; sourceTree = ""; }; + E7EDEA6B1C871D01006BAAF2 /* IssueTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IssueTests.swift; sourceTree = ""; }; + E7EDEA6D1C871D0E006BAAF2 /* issue.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = issue.json; path = Fixtures/issue.json; sourceTree = ""; }; E7EE59D71BDFEFB30012E3D2 /* Stars.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Stars.swift; sourceTree = ""; }; E7EE59D91BE10DA60012E3D2 /* StarsTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StarsTests.swift; sourceTree = ""; }; E7EE59DB1BE119110012E3D2 /* Follow.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Follow.swift; sourceTree = ""; }; @@ -277,6 +283,7 @@ 234F4BD71BDDE40400A58EF7 /* Fixtures */, 234F4BC91BDDE3F900A58EF7 /* ConfigurationTests.swift */, E7EE59DD1BE11C2A0012E3D2 /* FollowTests.swift */, + E7EDEA6B1C871D01006BAAF2 /* IssueTests.swift */, 234F4BCB1BDDE3F900A58EF7 /* OctokitSwiftTests.swift */, 234F4BCC1BDDE3F900A58EF7 /* PublicKeyTests.swift */, 234F4BCD1BDDE3F900A58EF7 /* RepositoryTests.swift */, @@ -291,6 +298,7 @@ 234F4BD71BDDE40400A58EF7 /* Fixtures */ = { isa = PBXGroup; children = ( + E7EDEA6D1C871D0E006BAAF2 /* issue.json */, 234F4BD81BDDE44600A58EF7 /* public_key.json */, 234F4BD91BDDE44600A58EF7 /* repo.json */, 234F4BDA1BDDE44600A58EF7 /* user_me.json */, @@ -304,6 +312,7 @@ 239BE7CA1B8C47A100D2CE22 /* OctoKit */ = { isa = PBXGroup; children = ( + E7EDEA691C871CEB006BAAF2 /* Issue.swift */, 239BE7CD1B8C47A100D2CE22 /* OctoKit.h */, 23B267851BDDD756003887E3 /* Configuration.swift */, E7EE59DB1BE119110012E3D2 /* Follow.swift */, @@ -600,6 +609,7 @@ 234F4BDE1BDDE44600A58EF7 /* repo.json in Resources */, 234F4BE11BDDE44600A58EF7 /* user_repos.json in Resources */, 234F4BE01BDDE44600A58EF7 /* user_mietzmithut.json in Resources */, + E7EDEA6E1C871D0E006BAAF2 /* issue.json in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -666,6 +676,7 @@ files = ( 234F4BD61BDDE3F900A58EF7 /* UserTests.swift in Sources */, 234F4BD31BDDE3F900A58EF7 /* PublicKeyTests.swift in Sources */, + E7EDEA6C1C871D01006BAAF2 /* IssueTests.swift in Sources */, 234F4BD41BDDE3F900A58EF7 /* RepositoryTests.swift in Sources */, E7EE59DE1BE11C2A0012E3D2 /* FollowTests.swift in Sources */, 234F4BD51BDDE3F900A58EF7 /* TestHelper.swift in Sources */, @@ -687,6 +698,7 @@ 23B2678C1BDDD756003887E3 /* PublicKey.swift in Sources */, 23B2678E1BDDD756003887E3 /* User.swift in Sources */, 23B2678B1BDDD756003887E3 /* Octokit.swift in Sources */, + E7EDEA6A1C871CEB006BAAF2 /* Issue.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/OctoKitTests/issue.json b/OctoKitTests/Fixtures/issue.json similarity index 100% rename from OctoKitTests/issue.json rename to OctoKitTests/Fixtures/issue.json From 691bc027d4b523aac8998c82888634ad533c9ba1 Mon Sep 17 00:00:00 2001 From: Nate West Date: Wed, 2 Mar 2016 08:18:57 -0500 Subject: [PATCH 052/302] Add files to all of the targets --- OctoKit.xcodeproj/project.pbxproj | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/OctoKit.xcodeproj/project.pbxproj b/OctoKit.xcodeproj/project.pbxproj index 1d628c4e..043d78ae 100644 --- a/OctoKit.xcodeproj/project.pbxproj +++ b/OctoKit.xcodeproj/project.pbxproj @@ -98,6 +98,13 @@ E7EDEA6A1C871CEB006BAAF2 /* Issue.swift in Sources */ = {isa = PBXBuildFile; fileRef = E7EDEA691C871CEB006BAAF2 /* Issue.swift */; }; E7EDEA6C1C871D01006BAAF2 /* IssueTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E7EDEA6B1C871D01006BAAF2 /* IssueTests.swift */; }; E7EDEA6E1C871D0E006BAAF2 /* issue.json in Resources */ = {isa = PBXBuildFile; fileRef = E7EDEA6D1C871D0E006BAAF2 /* issue.json */; }; + E7EDEA6F1C871F81006BAAF2 /* Issue.swift in Sources */ = {isa = PBXBuildFile; fileRef = E7EDEA691C871CEB006BAAF2 /* Issue.swift */; }; + E7EDEA701C871F81006BAAF2 /* Issue.swift in Sources */ = {isa = PBXBuildFile; fileRef = E7EDEA691C871CEB006BAAF2 /* Issue.swift */; }; + E7EDEA711C871F82006BAAF2 /* Issue.swift in Sources */ = {isa = PBXBuildFile; fileRef = E7EDEA691C871CEB006BAAF2 /* Issue.swift */; }; + E7EDEA721C871F94006BAAF2 /* IssueTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E7EDEA6B1C871D01006BAAF2 /* IssueTests.swift */; }; + E7EDEA731C871F95006BAAF2 /* IssueTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E7EDEA6B1C871D01006BAAF2 /* IssueTests.swift */; }; + E7EDEA741C871FA8006BAAF2 /* issue.json in Resources */ = {isa = PBXBuildFile; fileRef = E7EDEA6D1C871D0E006BAAF2 /* issue.json */; }; + E7EDEA751C871FA9006BAAF2 /* issue.json in Resources */ = {isa = PBXBuildFile; fileRef = E7EDEA6D1C871D0E006BAAF2 /* issue.json */; }; E7EE59D81BDFEFB30012E3D2 /* Stars.swift in Sources */ = {isa = PBXBuildFile; fileRef = E7EE59D71BDFEFB30012E3D2 /* Stars.swift */; }; E7EE59DA1BE10DA60012E3D2 /* StarsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E7EE59D91BE10DA60012E3D2 /* StarsTests.swift */; }; E7EE59DC1BE119110012E3D2 /* Follow.swift in Sources */ = {isa = PBXBuildFile; fileRef = E7EE59DB1BE119110012E3D2 /* Follow.swift */; }; @@ -637,6 +644,7 @@ 23F643481C7AEF66000427B3 /* repo.json in Resources */, 23F6434E1C7AEF6F000427B3 /* user_repos.json in Resources */, 23F6434C1C7AEF6C000427B3 /* user_mietzmithut.json in Resources */, + E7EDEA741C871FA8006BAAF2 /* issue.json in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -657,6 +665,7 @@ 23F643491C7AEF67000427B3 /* repo.json in Resources */, 23F6434F1C7AEF70000427B3 /* user_repos.json in Resources */, 23F6434D1C7AEF6D000427B3 /* user_mietzmithut.json in Resources */, + E7EDEA751C871FA9006BAAF2 /* issue.json in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -714,6 +723,7 @@ 23CAF2B41C7AB6D4005011C4 /* Stars.swift in Sources */, 23CAF2AB1C7AB6C9005011C4 /* PublicKey.swift in Sources */, 23CAF2A81C7AB6C6005011C4 /* Octokit.swift in Sources */, + E7EDEA6F1C871F81006BAAF2 /* Issue.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -723,6 +733,7 @@ files = ( 23CAF2BC1C7AB6FC005011C4 /* FollowTests.swift in Sources */, 23CAF2C41C7AB708005011C4 /* StarsTests.swift in Sources */, + E7EDEA721C871F94006BAAF2 /* IssueTests.swift in Sources */, 23CAF2C61C7AB70B005011C4 /* TestHelper.swift in Sources */, 23CAF2BE1C7AB6FE005011C4 /* OctokitSwiftTests.swift in Sources */, 23CAF2C01C7AB702005011C4 /* PublicKeyTests.swift in Sources */, @@ -744,6 +755,7 @@ 23CAF2B51C7AB6D5005011C4 /* Stars.swift in Sources */, 23CAF2AC1C7AB6CA005011C4 /* PublicKey.swift in Sources */, 23CAF2A91C7AB6C6005011C4 /* Octokit.swift in Sources */, + E7EDEA701C871F81006BAAF2 /* Issue.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -753,6 +765,7 @@ files = ( 23CAF2BD1C7AB6FC005011C4 /* FollowTests.swift in Sources */, 23CAF2C51C7AB709005011C4 /* StarsTests.swift in Sources */, + E7EDEA731C871F95006BAAF2 /* IssueTests.swift in Sources */, 23CAF2C71C7AB70C005011C4 /* TestHelper.swift in Sources */, 23CAF2BF1C7AB6FF005011C4 /* OctokitSwiftTests.swift in Sources */, 23CAF2C11C7AB702005011C4 /* PublicKeyTests.swift in Sources */, @@ -774,6 +787,7 @@ 23CAF2B61C7AB6D5005011C4 /* Stars.swift in Sources */, 23CAF2AD1C7AB6CA005011C4 /* PublicKey.swift in Sources */, 23CAF2AA1C7AB6C7005011C4 /* Octokit.swift in Sources */, + E7EDEA711C871F82006BAAF2 /* Issue.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; From 0bfedc77432cbec885ddebae55c06a306708afcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguye=CC=82=CC=83n?= Date: Sun, 28 Feb 2016 22:11:22 -0800 Subject: [PATCH 053/302] Issue creation and editing Added basic support for creating and editing issues. Also added model objects for milestones and labels. --- OctoKit.xcodeproj/project.pbxproj | 46 +++++-- OctoKit/Issue.swift | 198 +++++++++++++++++++++++++--- OctoKit/Label.swift | 43 ++++++ OctoKit/Milestone.swift | 56 ++++++++ OctoKitTests/Fixtures/issue.json | 210 +++++++++++++++--------------- OctoKitTests/Fixtures/issues.json | 106 +++++++++++++++ OctoKitTests/IssueTests.swift | 43 +++++- README.md | 41 ++++++ 8 files changed, 607 insertions(+), 136 deletions(-) create mode 100644 OctoKit/Label.swift create mode 100644 OctoKit/Milestone.swift create mode 100644 OctoKitTests/Fixtures/issues.json diff --git a/OctoKit.xcodeproj/project.pbxproj b/OctoKit.xcodeproj/project.pbxproj index 043d78ae..eafadbf5 100644 --- a/OctoKit.xcodeproj/project.pbxproj +++ b/OctoKit.xcodeproj/project.pbxproj @@ -95,16 +95,27 @@ 23F6434F1C7AEF70000427B3 /* user_repos.json in Resources */ = {isa = PBXBuildFile; fileRef = 234F4BDC1BDDE44600A58EF7 /* user_repos.json */; }; 23F643501C7AEF72000427B3 /* users.json in Resources */ = {isa = PBXBuildFile; fileRef = E7EE59DF1BE139FD0012E3D2 /* users.json */; }; 23F643511C7AEF73000427B3 /* users.json in Resources */ = {isa = PBXBuildFile; fileRef = E7EE59DF1BE139FD0012E3D2 /* users.json */; }; + DABBDE501C8C0C20008F57CD /* issue.json in Resources */ = {isa = PBXBuildFile; fileRef = DABBDE4F1C8C0C20008F57CD /* issue.json */; }; + DABBDE511C8C0C20008F57CD /* issue.json in Resources */ = {isa = PBXBuildFile; fileRef = DABBDE4F1C8C0C20008F57CD /* issue.json */; }; + DABBDE521C8C0C20008F57CD /* issue.json in Resources */ = {isa = PBXBuildFile; fileRef = DABBDE4F1C8C0C20008F57CD /* issue.json */; }; + DAEFC5901C83D85100CF3785 /* Label.swift in Sources */ = {isa = PBXBuildFile; fileRef = DAEFC58F1C83D85100CF3785 /* Label.swift */; }; + DAEFC5911C83D85100CF3785 /* Label.swift in Sources */ = {isa = PBXBuildFile; fileRef = DAEFC58F1C83D85100CF3785 /* Label.swift */; }; + DAEFC5921C83D85100CF3785 /* Label.swift in Sources */ = {isa = PBXBuildFile; fileRef = DAEFC58F1C83D85100CF3785 /* Label.swift */; }; + DAEFC5931C83D85100CF3785 /* Label.swift in Sources */ = {isa = PBXBuildFile; fileRef = DAEFC58F1C83D85100CF3785 /* Label.swift */; }; + DAEFC5951C83EF0D00CF3785 /* Milestone.swift in Sources */ = {isa = PBXBuildFile; fileRef = DAEFC5941C83EF0D00CF3785 /* Milestone.swift */; }; + DAEFC5961C83EF0D00CF3785 /* Milestone.swift in Sources */ = {isa = PBXBuildFile; fileRef = DAEFC5941C83EF0D00CF3785 /* Milestone.swift */; }; + DAEFC5971C83EF0D00CF3785 /* Milestone.swift in Sources */ = {isa = PBXBuildFile; fileRef = DAEFC5941C83EF0D00CF3785 /* Milestone.swift */; }; + DAEFC5981C83EF0D00CF3785 /* Milestone.swift in Sources */ = {isa = PBXBuildFile; fileRef = DAEFC5941C83EF0D00CF3785 /* Milestone.swift */; }; E7EDEA6A1C871CEB006BAAF2 /* Issue.swift in Sources */ = {isa = PBXBuildFile; fileRef = E7EDEA691C871CEB006BAAF2 /* Issue.swift */; }; E7EDEA6C1C871D01006BAAF2 /* IssueTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E7EDEA6B1C871D01006BAAF2 /* IssueTests.swift */; }; - E7EDEA6E1C871D0E006BAAF2 /* issue.json in Resources */ = {isa = PBXBuildFile; fileRef = E7EDEA6D1C871D0E006BAAF2 /* issue.json */; }; + E7EDEA6E1C871D0E006BAAF2 /* issues.json in Resources */ = {isa = PBXBuildFile; fileRef = E7EDEA6D1C871D0E006BAAF2 /* issues.json */; }; E7EDEA6F1C871F81006BAAF2 /* Issue.swift in Sources */ = {isa = PBXBuildFile; fileRef = E7EDEA691C871CEB006BAAF2 /* Issue.swift */; }; E7EDEA701C871F81006BAAF2 /* Issue.swift in Sources */ = {isa = PBXBuildFile; fileRef = E7EDEA691C871CEB006BAAF2 /* Issue.swift */; }; E7EDEA711C871F82006BAAF2 /* Issue.swift in Sources */ = {isa = PBXBuildFile; fileRef = E7EDEA691C871CEB006BAAF2 /* Issue.swift */; }; E7EDEA721C871F94006BAAF2 /* IssueTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E7EDEA6B1C871D01006BAAF2 /* IssueTests.swift */; }; E7EDEA731C871F95006BAAF2 /* IssueTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E7EDEA6B1C871D01006BAAF2 /* IssueTests.swift */; }; - E7EDEA741C871FA8006BAAF2 /* issue.json in Resources */ = {isa = PBXBuildFile; fileRef = E7EDEA6D1C871D0E006BAAF2 /* issue.json */; }; - E7EDEA751C871FA9006BAAF2 /* issue.json in Resources */ = {isa = PBXBuildFile; fileRef = E7EDEA6D1C871D0E006BAAF2 /* issue.json */; }; + E7EDEA741C871FA8006BAAF2 /* issues.json in Resources */ = {isa = PBXBuildFile; fileRef = E7EDEA6D1C871D0E006BAAF2 /* issues.json */; }; + E7EDEA751C871FA9006BAAF2 /* issues.json in Resources */ = {isa = PBXBuildFile; fileRef = E7EDEA6D1C871D0E006BAAF2 /* issues.json */; }; E7EE59D81BDFEFB30012E3D2 /* Stars.swift in Sources */ = {isa = PBXBuildFile; fileRef = E7EE59D71BDFEFB30012E3D2 /* Stars.swift */; }; E7EE59DA1BE10DA60012E3D2 /* StarsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E7EE59D91BE10DA60012E3D2 /* StarsTests.swift */; }; E7EE59DC1BE119110012E3D2 /* Follow.swift in Sources */ = {isa = PBXBuildFile; fileRef = E7EE59DB1BE119110012E3D2 /* Follow.swift */; }; @@ -210,9 +221,12 @@ 23CAF2D81C7AB9DB005011C4 /* RequestKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = RequestKit.framework; path = Carthage/Build/watchOS/RequestKit.framework; sourceTree = ""; }; 23F6433C1C7AEEB6000427B3 /* Nocilla.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Nocilla.framework; path = Carthage/Build/tvOS/Nocilla.framework; sourceTree = ""; }; 23F643421C7AEF2F000427B3 /* Nocilla.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Nocilla.framework; path = Carthage/Build/Mac/Nocilla.framework; sourceTree = ""; }; + DABBDE4F1C8C0C20008F57CD /* issue.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = issue.json; path = Fixtures/issue.json; sourceTree = ""; }; + DAEFC58F1C83D85100CF3785 /* Label.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Label.swift; sourceTree = ""; }; + DAEFC5941C83EF0D00CF3785 /* Milestone.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Milestone.swift; sourceTree = ""; }; E7EDEA691C871CEB006BAAF2 /* Issue.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Issue.swift; sourceTree = ""; }; E7EDEA6B1C871D01006BAAF2 /* IssueTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IssueTests.swift; sourceTree = ""; }; - E7EDEA6D1C871D0E006BAAF2 /* issue.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = issue.json; path = Fixtures/issue.json; sourceTree = ""; }; + E7EDEA6D1C871D0E006BAAF2 /* issues.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = issues.json; path = Fixtures/issues.json; sourceTree = ""; }; E7EE59D71BDFEFB30012E3D2 /* Stars.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Stars.swift; sourceTree = ""; }; E7EE59D91BE10DA60012E3D2 /* StarsTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StarsTests.swift; sourceTree = ""; }; E7EE59DB1BE119110012E3D2 /* Follow.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Follow.swift; sourceTree = ""; }; @@ -305,7 +319,8 @@ 234F4BD71BDDE40400A58EF7 /* Fixtures */ = { isa = PBXGroup; children = ( - E7EDEA6D1C871D0E006BAAF2 /* issue.json */, + DABBDE4F1C8C0C20008F57CD /* issue.json */, + E7EDEA6D1C871D0E006BAAF2 /* issues.json */, 234F4BD81BDDE44600A58EF7 /* public_key.json */, 234F4BD91BDDE44600A58EF7 /* repo.json */, 234F4BDA1BDDE44600A58EF7 /* user_me.json */, @@ -319,10 +334,12 @@ 239BE7CA1B8C47A100D2CE22 /* OctoKit */ = { isa = PBXGroup; children = ( - E7EDEA691C871CEB006BAAF2 /* Issue.swift */, 239BE7CD1B8C47A100D2CE22 /* OctoKit.h */, 23B267851BDDD756003887E3 /* Configuration.swift */, E7EE59DB1BE119110012E3D2 /* Follow.swift */, + E7EDEA691C871CEB006BAAF2 /* Issue.swift */, + DAEFC58F1C83D85100CF3785 /* Label.swift */, + DAEFC5941C83EF0D00CF3785 /* Milestone.swift */, 23B267861BDDD756003887E3 /* Octokit.swift */, 23B267871BDDD756003887E3 /* PublicKey.swift */, 23B267881BDDD756003887E3 /* Repositories.swift */, @@ -613,10 +630,11 @@ E7EE59E01BE139FD0012E3D2 /* users.json in Resources */, 234F4BDF1BDDE44600A58EF7 /* user_me.json in Resources */, 234F4BDD1BDDE44600A58EF7 /* public_key.json in Resources */, + DABBDE501C8C0C20008F57CD /* issue.json in Resources */, 234F4BDE1BDDE44600A58EF7 /* repo.json in Resources */, 234F4BE11BDDE44600A58EF7 /* user_repos.json in Resources */, 234F4BE01BDDE44600A58EF7 /* user_mietzmithut.json in Resources */, - E7EDEA6E1C871D0E006BAAF2 /* issue.json in Resources */, + E7EDEA6E1C871D0E006BAAF2 /* issues.json in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -641,10 +659,11 @@ 23F643501C7AEF72000427B3 /* users.json in Resources */, 23F6434A1C7AEF69000427B3 /* user_me.json in Resources */, 23F643461C7AEF63000427B3 /* public_key.json in Resources */, + DABBDE511C8C0C20008F57CD /* issue.json in Resources */, 23F643481C7AEF66000427B3 /* repo.json in Resources */, 23F6434E1C7AEF6F000427B3 /* user_repos.json in Resources */, 23F6434C1C7AEF6C000427B3 /* user_mietzmithut.json in Resources */, - E7EDEA741C871FA8006BAAF2 /* issue.json in Resources */, + E7EDEA741C871FA8006BAAF2 /* issues.json in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -662,10 +681,11 @@ 23F643511C7AEF73000427B3 /* users.json in Resources */, 23F6434B1C7AEF6A000427B3 /* user_me.json in Resources */, 23F643471C7AEF63000427B3 /* public_key.json in Resources */, + DABBDE521C8C0C20008F57CD /* issue.json in Resources */, 23F643491C7AEF67000427B3 /* repo.json in Resources */, 23F6434F1C7AEF70000427B3 /* user_repos.json in Resources */, 23F6434D1C7AEF6D000427B3 /* user_mietzmithut.json in Resources */, - E7EDEA751C871FA9006BAAF2 /* issue.json in Resources */, + E7EDEA751C871FA9006BAAF2 /* issues.json in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -706,8 +726,10 @@ F8711EA21BFCAE9F005DDACA /* Time.swift in Sources */, 23B2678C1BDDD756003887E3 /* PublicKey.swift in Sources */, 23B2678E1BDDD756003887E3 /* User.swift in Sources */, + DAEFC5951C83EF0D00CF3785 /* Milestone.swift in Sources */, 23B2678B1BDDD756003887E3 /* Octokit.swift in Sources */, E7EDEA6A1C871CEB006BAAF2 /* Issue.swift in Sources */, + DAEFC5901C83D85100CF3785 /* Label.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -722,8 +744,10 @@ 23CAF2B71C7AB6EB005011C4 /* Time.swift in Sources */, 23CAF2B41C7AB6D4005011C4 /* Stars.swift in Sources */, 23CAF2AB1C7AB6C9005011C4 /* PublicKey.swift in Sources */, + DAEFC5961C83EF0D00CF3785 /* Milestone.swift in Sources */, 23CAF2A81C7AB6C6005011C4 /* Octokit.swift in Sources */, E7EDEA6F1C871F81006BAAF2 /* Issue.swift in Sources */, + DAEFC5911C83D85100CF3785 /* Label.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -754,8 +778,10 @@ 23CAF2B81C7AB6EB005011C4 /* Time.swift in Sources */, 23CAF2B51C7AB6D5005011C4 /* Stars.swift in Sources */, 23CAF2AC1C7AB6CA005011C4 /* PublicKey.swift in Sources */, + DAEFC5971C83EF0D00CF3785 /* Milestone.swift in Sources */, 23CAF2A91C7AB6C6005011C4 /* Octokit.swift in Sources */, E7EDEA701C871F81006BAAF2 /* Issue.swift in Sources */, + DAEFC5921C83D85100CF3785 /* Label.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -786,8 +812,10 @@ 23CAF2B91C7AB6EC005011C4 /* Time.swift in Sources */, 23CAF2B61C7AB6D5005011C4 /* Stars.swift in Sources */, 23CAF2AD1C7AB6CA005011C4 /* PublicKey.swift in Sources */, + DAEFC5981C83EF0D00CF3785 /* Milestone.swift in Sources */, 23CAF2AA1C7AB6C7005011C4 /* Octokit.swift in Sources */, E7EDEA711C871F82006BAAF2 /* Issue.swift in Sources */, + DAEFC5931C83D85100CF3785 /* Label.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/OctoKit/Issue.swift b/OctoKit/Issue.swift index 8ca2445a..f0e728b1 100644 --- a/OctoKit/Issue.swift +++ b/OctoKit/Issue.swift @@ -3,34 +3,80 @@ import RequestKit // MARK: model +public enum IssueState: String { + case Open = "open" + case Closed = "closed" +} + @objc public class Issue: NSObject { - public let id: Int - public var url: String? + public var id: Int + public var url: NSURL? + public var repositoryURL: NSURL? + public var labelsURL: NSURL? + public var commentsURL: NSURL? + public var eventsURL: NSURL? + public var htmlURL: NSURL? public var number: Int? + public var state: IssueState? public var title: String? public var body: String? - public var state: String? public var user: User? + public var labels: [Label]? public var assignee: User? - public var createdAt: NSDate? - public var closedAt: NSDate? - public var updatedAt: NSDate? + public var milestone: Milestone? + public var locked: Bool? + public var numberOfComments: Int? + public var closureDate: NSDate? + public var creationDate: NSDate? + public var updateDate: NSDate? + public var closer: User? public init(_ json: [String: AnyObject]) { if let id = json["id"] as? Int { self.id = id - url = json["url"] as? String + if let urlString = json["url"] as? String, url = NSURL(string: urlString) { + self.url = url + } + if let urlString = json["repository_url"] as? String, url = NSURL(string: urlString) { + repositoryURL = url + } + if let urlString = json["labels_url"] as? String, url = NSURL(string: urlString) { + labelsURL = url + } + if let urlString = json["comments_url"] as? String, url = NSURL(string: urlString) { + commentsURL = url + } + if let urlString = json["events_url"] as? String, url = NSURL(string: urlString) { + eventsURL = url + } + if let urlString = json["html_url"] as? String, url = NSURL(string: urlString) { + htmlURL = url + } number = json["number"] as? Int + switch json["state"] as? String ?? "" { + case "open": + state = .Open + case "closed": + state = .Closed + default: + break + } title = json["title"] as? String body = json["body"] as? String - state = json["state"] as? String user = User(json["user"] as? [String: AnyObject] ?? [:]) + if let labelDictionaries = json["labels"] as? [[String: AnyObject]] { + labels = labelDictionaries.flatMap { Label($0) } + } assignee = User(json["assignee"] as? [String: AnyObject] ?? [:]) - createdAt = Time.rfc3339Date(json["created_at"] as? String) - closedAt = Time.rfc3339Date(json["closed_at"] as? String) - updatedAt = Time.rfc3339Date(json["updated_at"] as? String) + milestone = Milestone(json["milestone"] as? [String: AnyObject] ?? [:]) + locked = json["locked"] as? Bool + numberOfComments = json["comments"] as? Int + closureDate = Time.rfc3339Date(json["closed_at"] as? String) + creationDate = Time.rfc3339Date(json["created_at"] as? String) + updateDate = Time.rfc3339Date(json["updated_at"] as? String) + closer = User(json["closed_by"] as? [String: AnyObject] ?? [:]) } else { - id = -1 + self.id = -1 } } } @@ -58,25 +104,109 @@ public extension Octokit { } } } + + /** + Fetches an issue in a repository + - parameter owner: The user or organization that owns the repository. + - parameter repository: The name of the repository. + - parameter number: The number of the issue. + - parameter completion: Callback for the outcome of the fetch. + */ + public func issue(owner: String, repository: String, number: Int, completion: (response: Response) -> Void) { + let router = IssueRouter.ReadIssue(configuration, owner, repository, number) + router.loadJSON([String: AnyObject].self) { json, error in + if let error = error { + completion(response: Response.Failure(error)) + } else { + if let json = json { + let issue = Issue(json) + completion(response: Response.Success(issue)) + } + } + } + } + + /** + Creates an issue in a repository. + - parameter owner: The user or organization that owns the repository. + - parameter repository: The name of the repository. + - parameter title: The title of the issue. + - parameter body: The body text of the issue in GitHub-flavored Markdown format. + - parameter assignee: The name of the user to assign the issue to. This parameter is ignored if the user lacks push access to the repository. + - parameter completion: Callback for the issue that is created. + */ + public func postIssue(owner: String, repository: String, title: String, body: String? = nil, assignee: String? = nil, completion: (response:Response) -> Void) { + let router = IssueRouter.PostIssue(configuration, owner, repository, title, body, assignee) + router.postJSON([String: AnyObject].self) { json, error in + if let error = error { + completion(response: Response.Failure(error)) + } else { + if let json = json { + let issue = Issue(json) + completion(response: Response.Success(issue)) + } + } + } + } + + /** + Edits an issue in a repository. + - parameter owner: The user or organization that owns the repository. + - parameter repository: The name of the repository. + - parameter number: The number of the issue. + - parameter title: The title of the issue. + - parameter body: The body text of the issue in GitHub-flavored Markdown format. + - parameter assignee: The name of the user to assign the issue to. This parameter is ignored if the user lacks push access to the repository. + - parameter state: Whether the issue is open or closed. + - parameter completion: Callback for the issue that is created. + */ + public func patchIssue(owner: String, repository: String, number: Int, title: String? = nil, body: String? = nil, assignee: String? = nil, state: IssueState? = nil, completion: (response:Response) -> Void) { + let router = IssueRouter.PatchIssue(configuration, owner, repository, number, title, body, assignee, state) + router.postJSON([String: AnyObject].self) { json, error in + if let error = error { + completion(response: Response.Failure(error)) + } else { + if let json = json { + let issue = Issue(json) + completion(response: Response.Success(issue)) + } + } + } + } } // MARK: Router -enum IssueRouter: Router { +enum IssueRouter: JSONPostRouter { case ReadAuthenticatedIssues(Configuration, String, String) + case ReadIssue(Configuration, String, String, Int) + case PostIssue(Configuration, String, String, String, String?, String?) + case PatchIssue(Configuration, String, String, Int, String?, String?, String?, IssueState?) var method: HTTPMethod { - return .GET + switch self { + case .PostIssue, .PatchIssue: + return .POST + default: + return .GET + } } var encoding: HTTPEncoding { - return .URL + switch self { + case .PostIssue, .PatchIssue: + return .JSON + default: + return .URL + } } var configuration: Configuration { switch self { - case .ReadAuthenticatedIssues(let config, _, _): - return config + case .ReadAuthenticatedIssues(let config, _, _): return config + case .ReadIssue(let config, _, _, _): return config + case .PostIssue(let config, _, _, _, _, _): return config + case .PatchIssue(let config, _, _, _, _, _, _, _): return config } } @@ -84,6 +214,32 @@ enum IssueRouter: Router { switch self { case .ReadAuthenticatedIssues(_, let page, let perPage): return ["per_page": perPage, "page": page] + case .ReadIssue: + return [:] + case .PostIssue(_, _, _, let title, let body, let assignee): + var params = ["title": title] + if let body = body { + params["body"] = body + } + if let assignee = assignee { + params["assignee"] = assignee + } + return params + case .PatchIssue(_, _, _, _, let title, let body, let assignee, let state): + var params: [String: String] = [:] + if let title = title { + params["title"] = title + } + if let body = body { + params["body"] = body + } + if let assignee = assignee { + params["assignee"] = assignee + } + if let state = state { + params["state"] = state.rawValue + } + return params } } @@ -91,8 +247,12 @@ enum IssueRouter: Router { switch self { case .ReadAuthenticatedIssues: return "issues" + case .ReadIssue(_, let owner, let repository, let number): + return "repos/\(owner)/\(repository)/issues/\(number)" + case .PostIssue(_, let owner, let repository, _, _, _): + return "repos/\(owner)/\(repository)/issues" + case .PatchIssue(_, let owner, let repository, let number, _, _, _, _): + return "repos/\(owner)/\(repository)/issues/\(number)" } } } - - diff --git a/OctoKit/Label.swift b/OctoKit/Label.swift new file mode 100644 index 00000000..3181d7d3 --- /dev/null +++ b/OctoKit/Label.swift @@ -0,0 +1,43 @@ +#if os(OSX) + import Cocoa + typealias Color = NSColor +#elseif os(iOS) || os(tvOS) || os(watchOS) + import UIKit + typealias Color = UIColor +#endif + +extension Color { + convenience init?(hexTriplet hex: String) { + var hexChars = hex.characters + let red = Int(String(hexChars.prefix(2)), radix: 16) + hexChars = hexChars.dropFirst(2) + let green = Int(String(hexChars.prefix(2)), radix: 16) + hexChars = hexChars.dropFirst(2) + let blue = Int(String(hexChars), radix: 16) + if let red = red, green = green, blue = blue { + self.init(red: CGFloat(red) / 255.0, green: CGFloat(green) / 255.0, blue: CGFloat(blue) / 255.0, alpha: 1) + } else { + return nil + } + } +} + +@objc public class Label: NSObject { + public var url: NSURL? + public var name: String? + #if os(OSX) + public var color: NSColor? + #elseif os(iOS) || os(tvOS) || os(watchOS) + public var color: UIColor? + #endif + + public init(_ json: [String: AnyObject]) { + if let urlString = json["url"] as? String, url = NSURL(string: urlString) { + self.url = url + } + name = json["name"] as? String + if let colorString = json["color"] as? String { + color = Color(hexTriplet: colorString) + } + } +} diff --git a/OctoKit/Milestone.swift b/OctoKit/Milestone.swift new file mode 100644 index 00000000..eec068ab --- /dev/null +++ b/OctoKit/Milestone.swift @@ -0,0 +1,56 @@ +import Foundation + +@objc public enum MilestoneState: Int { + case Open + case Closed +} + +@objc public class Milestone: NSObject { + public var url: NSURL? + public var htmlURL: NSURL? + public var labelsURL: NSURL? + public var id: Int + public var number: Int? + public var state: MilestoneState? + public var title: String? + public var milestoneDescription: String? + public var creator: User? + public var numberOfOpenIssues: Int? + public var numberOfClosedIssues: Int? + public var creationDate: NSDate? + public var updateDate: NSDate? + public var closureDate: NSDate? + public var dueDate: NSDate? + + public init?(_ json: [String: AnyObject]) { + if let id = json["id"] as? Int { + if let urlString = json["html_url"] as? String, url = NSURL(string: urlString) { + htmlURL = url + } + if let urlString = json["labels_url"] as? String, url = NSURL(string: urlString) { + labelsURL = url + } + self.id = id + number = json["number"] as? Int + switch json["state"] as? String ?? "" { + case "open": + state = .Open + case "closed": + state = .Closed + default: + break + } + title = json["title"] as? String + milestoneDescription = json["description"] as? String + creator = User(json["creator"] as? [String: AnyObject] ?? [:]) + numberOfOpenIssues = json["open_issues"] as? Int + numberOfClosedIssues = json["closed_issues"] as? Int + creationDate = Time.rfc3339Date(json["created_at"] as? String) + updateDate = Time.rfc3339Date(json["updated_at"] as? String) + closureDate = Time.rfc3339Date(json["closed_at"] as? String) + dueDate = Time.rfc3339Date(json["due_on"] as? String) + } else { + self.id = -1 + } + } +} diff --git a/OctoKitTests/Fixtures/issue.json b/OctoKitTests/Fixtures/issue.json index 7046abff..700915f1 100644 --- a/OctoKitTests/Fixtures/issue.json +++ b/OctoKitTests/Fixtures/issue.json @@ -1,106 +1,104 @@ - [ - { - "id": 1, - "url": "https://api.github.com/repos/octocat/Hello-World/issues/1347", - "repository_url": "https://api.github.com/repos/octocat/Hello-World", - "labels_url": "https://api.github.com/repos/octocat/Hello-World/issues/1347/labels{/name}", - "comments_url": "https://api.github.com/repos/octocat/Hello-World/issues/1347/comments", - "events_url": "https://api.github.com/repos/octocat/Hello-World/issues/1347/events", - "html_url": "https://github.com/octocat/Hello-World/issues/1347", - "number": 1347, - "state": "open", - "title": "Found a bug", - "body": "I'm having a problem with this.", - "user": { - "login": "octocat", - "id": 1, - "avatar_url": "https://github.com/images/error/octocat_happy.gif", - "gravatar_id": "", - "url": "https://api.github.com/users/octocat", - "html_url": "https://github.com/octocat", - "followers_url": "https://api.github.com/users/octocat/followers", - "following_url": "https://api.github.com/users/octocat/following{/other_user}", - "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", - "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", - "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", - "organizations_url": "https://api.github.com/users/octocat/orgs", - "repos_url": "https://api.github.com/users/octocat/repos", - "events_url": "https://api.github.com/users/octocat/events{/privacy}", - "received_events_url": "https://api.github.com/users/octocat/received_events", - "type": "User", - "site_admin": false - }, - "labels": [ - { - "url": "https://api.github.com/repos/octocat/Hello-World/labels/bug", - "name": "bug", - "color": "f29513" - } - ], - "assignee": { - "login": "octocat", - "id": 1, - "avatar_url": "https://github.com/images/error/octocat_happy.gif", - "gravatar_id": "", - "url": "https://api.github.com/users/octocat", - "html_url": "https://github.com/octocat", - "followers_url": "https://api.github.com/users/octocat/followers", - "following_url": "https://api.github.com/users/octocat/following{/other_user}", - "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", - "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", - "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", - "organizations_url": "https://api.github.com/users/octocat/orgs", - "repos_url": "https://api.github.com/users/octocat/repos", - "events_url": "https://api.github.com/users/octocat/events{/privacy}", - "received_events_url": "https://api.github.com/users/octocat/received_events", - "type": "User", - "site_admin": false - }, - "milestone": { - "url": "https://api.github.com/repos/octocat/Hello-World/milestones/1", - "html_url": "https://github.com/octocat/Hello-World/milestones/v1.0", - "labels_url": "https://api.github.com/repos/octocat/Hello-World/milestones/1/labels", - "id": 1002604, - "number": 1, - "state": "open", - "title": "v1.0", - "description": "Tracking milestone for version 1.0", - "creator": { - "login": "octocat", - "id": 1, - "avatar_url": "https://github.com/images/error/octocat_happy.gif", - "gravatar_id": "", - "url": "https://api.github.com/users/octocat", - "html_url": "https://github.com/octocat", - "followers_url": "https://api.github.com/users/octocat/followers", - "following_url": "https://api.github.com/users/octocat/following{/other_user}", - "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", - "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", - "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", - "organizations_url": "https://api.github.com/users/octocat/orgs", - "repos_url": "https://api.github.com/users/octocat/repos", - "events_url": "https://api.github.com/users/octocat/events{/privacy}", - "received_events_url": "https://api.github.com/users/octocat/received_events", - "type": "User", - "site_admin": false - }, - "open_issues": 4, - "closed_issues": 8, - "created_at": "2011-04-10T20:09:31Z", - "updated_at": "2014-03-03T18:58:10Z", - "closed_at": "2013-02-12T13:22:01Z", - "due_on": "2012-10-09T23:39:01Z" - }, - "locked": false, - "comments": 0, - "pull_request": { - "url": "https://api.github.com/repos/octocat/Hello-World/pulls/1347", - "html_url": "https://github.com/octocat/Hello-World/pull/1347", - "diff_url": "https://github.com/octocat/Hello-World/pull/1347.diff", - "patch_url": "https://github.com/octocat/Hello-World/pull/1347.patch" - }, - "closed_at": null, - "created_at": "2011-04-22T13:33:48Z", - "updated_at": "2011-04-22T13:33:48Z" - } -] \ No newline at end of file +{ + "id": 1, + "url": "https://api.github.com/repos/octocat/Hello-World/issues/1347", + "repository_url": "https://api.github.com/repos/octocat/Hello-World", + "labels_url": "https://api.github.com/repos/octocat/Hello-World/issues/1347/labels{/name}", + "comments_url": "https://api.github.com/repos/octocat/Hello-World/issues/1347/comments", + "events_url": "https://api.github.com/repos/octocat/Hello-World/issues/1347/events", + "html_url": "https://github.com/octocat/Hello-World/issues/1347", + "number": 1347, + "state": "open", + "title": "Found a bug", + "body": "I'm having a problem with this.", + "user": { + "login": "octocat", + "id": 1, + "avatar_url": "https://github.com/images/error/octocat_happy.gif", + "gravatar_id": "", + "url": "https://api.github.com/users/octocat", + "html_url": "https://github.com/octocat", + "followers_url": "https://api.github.com/users/octocat/followers", + "following_url": "https://api.github.com/users/octocat/following{/other_user}", + "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", + "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", + "organizations_url": "https://api.github.com/users/octocat/orgs", + "repos_url": "https://api.github.com/users/octocat/repos", + "events_url": "https://api.github.com/users/octocat/events{/privacy}", + "received_events_url": "https://api.github.com/users/octocat/received_events", + "type": "User", + "site_admin": false + }, + "labels": [ + { + "url": "https://api.github.com/repos/octocat/Hello-World/labels/bug", + "name": "bug", + "color": "f29513" + } + ], + "assignee": { + "login": "octocat", + "id": 1, + "avatar_url": "https://github.com/images/error/octocat_happy.gif", + "gravatar_id": "", + "url": "https://api.github.com/users/octocat", + "html_url": "https://github.com/octocat", + "followers_url": "https://api.github.com/users/octocat/followers", + "following_url": "https://api.github.com/users/octocat/following{/other_user}", + "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", + "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", + "organizations_url": "https://api.github.com/users/octocat/orgs", + "repos_url": "https://api.github.com/users/octocat/repos", + "events_url": "https://api.github.com/users/octocat/events{/privacy}", + "received_events_url": "https://api.github.com/users/octocat/received_events", + "type": "User", + "site_admin": false + }, + "milestone": { + "url": "https://api.github.com/repos/octocat/Hello-World/milestones/1", + "html_url": "https://github.com/octocat/Hello-World/milestones/v1.0", + "labels_url": "https://api.github.com/repos/octocat/Hello-World/milestones/1/labels", + "id": 1002604, + "number": 1, + "state": "open", + "title": "v1.0", + "description": "Tracking milestone for version 1.0", + "creator": { + "login": "octocat", + "id": 1, + "avatar_url": "https://github.com/images/error/octocat_happy.gif", + "gravatar_id": "", + "url": "https://api.github.com/users/octocat", + "html_url": "https://github.com/octocat", + "followers_url": "https://api.github.com/users/octocat/followers", + "following_url": "https://api.github.com/users/octocat/following{/other_user}", + "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", + "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", + "organizations_url": "https://api.github.com/users/octocat/orgs", + "repos_url": "https://api.github.com/users/octocat/repos", + "events_url": "https://api.github.com/users/octocat/events{/privacy}", + "received_events_url": "https://api.github.com/users/octocat/received_events", + "type": "User", + "site_admin": false + }, + "open_issues": 4, + "closed_issues": 8, + "created_at": "2011-04-10T20:09:31Z", + "updated_at": "2014-03-03T18:58:10Z", + "closed_at": "2013-02-12T13:22:01Z", + "due_on": "2012-10-09T23:39:01Z" + }, + "locked": false, + "comments": 0, + "pull_request": { + "url": "https://api.github.com/repos/octocat/Hello-World/pulls/1347", + "html_url": "https://github.com/octocat/Hello-World/pull/1347", + "diff_url": "https://github.com/octocat/Hello-World/pull/1347.diff", + "patch_url": "https://github.com/octocat/Hello-World/pull/1347.patch" + }, + "closed_at": null, + "created_at": "2011-04-22T13:33:48Z", + "updated_at": "2011-04-22T13:33:48Z" +} \ No newline at end of file diff --git a/OctoKitTests/Fixtures/issues.json b/OctoKitTests/Fixtures/issues.json new file mode 100644 index 00000000..7046abff --- /dev/null +++ b/OctoKitTests/Fixtures/issues.json @@ -0,0 +1,106 @@ + [ + { + "id": 1, + "url": "https://api.github.com/repos/octocat/Hello-World/issues/1347", + "repository_url": "https://api.github.com/repos/octocat/Hello-World", + "labels_url": "https://api.github.com/repos/octocat/Hello-World/issues/1347/labels{/name}", + "comments_url": "https://api.github.com/repos/octocat/Hello-World/issues/1347/comments", + "events_url": "https://api.github.com/repos/octocat/Hello-World/issues/1347/events", + "html_url": "https://github.com/octocat/Hello-World/issues/1347", + "number": 1347, + "state": "open", + "title": "Found a bug", + "body": "I'm having a problem with this.", + "user": { + "login": "octocat", + "id": 1, + "avatar_url": "https://github.com/images/error/octocat_happy.gif", + "gravatar_id": "", + "url": "https://api.github.com/users/octocat", + "html_url": "https://github.com/octocat", + "followers_url": "https://api.github.com/users/octocat/followers", + "following_url": "https://api.github.com/users/octocat/following{/other_user}", + "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", + "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", + "organizations_url": "https://api.github.com/users/octocat/orgs", + "repos_url": "https://api.github.com/users/octocat/repos", + "events_url": "https://api.github.com/users/octocat/events{/privacy}", + "received_events_url": "https://api.github.com/users/octocat/received_events", + "type": "User", + "site_admin": false + }, + "labels": [ + { + "url": "https://api.github.com/repos/octocat/Hello-World/labels/bug", + "name": "bug", + "color": "f29513" + } + ], + "assignee": { + "login": "octocat", + "id": 1, + "avatar_url": "https://github.com/images/error/octocat_happy.gif", + "gravatar_id": "", + "url": "https://api.github.com/users/octocat", + "html_url": "https://github.com/octocat", + "followers_url": "https://api.github.com/users/octocat/followers", + "following_url": "https://api.github.com/users/octocat/following{/other_user}", + "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", + "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", + "organizations_url": "https://api.github.com/users/octocat/orgs", + "repos_url": "https://api.github.com/users/octocat/repos", + "events_url": "https://api.github.com/users/octocat/events{/privacy}", + "received_events_url": "https://api.github.com/users/octocat/received_events", + "type": "User", + "site_admin": false + }, + "milestone": { + "url": "https://api.github.com/repos/octocat/Hello-World/milestones/1", + "html_url": "https://github.com/octocat/Hello-World/milestones/v1.0", + "labels_url": "https://api.github.com/repos/octocat/Hello-World/milestones/1/labels", + "id": 1002604, + "number": 1, + "state": "open", + "title": "v1.0", + "description": "Tracking milestone for version 1.0", + "creator": { + "login": "octocat", + "id": 1, + "avatar_url": "https://github.com/images/error/octocat_happy.gif", + "gravatar_id": "", + "url": "https://api.github.com/users/octocat", + "html_url": "https://github.com/octocat", + "followers_url": "https://api.github.com/users/octocat/followers", + "following_url": "https://api.github.com/users/octocat/following{/other_user}", + "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", + "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", + "organizations_url": "https://api.github.com/users/octocat/orgs", + "repos_url": "https://api.github.com/users/octocat/repos", + "events_url": "https://api.github.com/users/octocat/events{/privacy}", + "received_events_url": "https://api.github.com/users/octocat/received_events", + "type": "User", + "site_admin": false + }, + "open_issues": 4, + "closed_issues": 8, + "created_at": "2011-04-10T20:09:31Z", + "updated_at": "2014-03-03T18:58:10Z", + "closed_at": "2013-02-12T13:22:01Z", + "due_on": "2012-10-09T23:39:01Z" + }, + "locked": false, + "comments": 0, + "pull_request": { + "url": "https://api.github.com/repos/octocat/Hello-World/pulls/1347", + "html_url": "https://github.com/octocat/Hello-World/pull/1347", + "diff_url": "https://github.com/octocat/Hello-World/pull/1347.diff", + "patch_url": "https://github.com/octocat/Hello-World/pull/1347.patch" + }, + "closed_at": null, + "created_at": "2011-04-22T13:33:48Z", + "updated_at": "2011-04-22T13:33:48Z" + } +] \ No newline at end of file diff --git a/OctoKitTests/IssueTests.swift b/OctoKitTests/IssueTests.swift index cb6c794a..19158209 100644 --- a/OctoKitTests/IssueTests.swift +++ b/OctoKitTests/IssueTests.swift @@ -18,7 +18,7 @@ class IssueTests: XCTestCase { func testGetMyIssues() { let config = TokenConfiguration("12345") - if let json = Helper.stringFromFile("issue") { + if let json = Helper.stringFromFile("issues") { stubRequest("GET", "https://api.github.com/issues?access_token=12345&page=1&per_page=100").andReturn(200).withHeaders(["Content-Type": "application/json"]).withBody(json) let expectation = expectationWithDescription("issues") Octokit(config).myIssues() { response in @@ -38,4 +38,43 @@ class IssueTests: XCTestCase { XCTFail("json shouldn't be nil") } } -} \ No newline at end of file + + func testGetIssue() { + let (owner, repo, number) = ("octocat", "Hello-World", 1347) + if let json = Helper.stringFromFile("issue") { + stubRequest("GET", "https://api.github.com/repos/octocat/Hello-World/issues/1347").andReturn(200) + .withHeaders(["Content-Type": "application/json"]).withBody(json) + let expectation = expectationWithDescription("issue") + Octokit().issue(owner, repository: repo, number: number) { response in + switch response { + case .Success(let issue): + XCTAssertEqual(issue.number!, number) + expectation.fulfill() + case .Failure: + XCTAssert(false, "should not get an error") + expectation.fulfill() + } + } + } else { + XCTFail("json shouldn't be nil") + } + waitForExpectationsWithTimeout(1) { error in + XCTAssertNil(error, "\(error)") + } + } + + // MARK: Model Tests + + func testParsingIssue() { + let subject = Issue(Helper.JSONFromFile("issue") as! [String: AnyObject]) + XCTAssertEqual(subject.user!.login!, "octocat") + XCTAssertEqual(subject.user!.id, 1) + + XCTAssertEqual(subject.id, 1) + XCTAssertEqual(subject.number!, 1347) + XCTAssertEqual(subject.title!, "Found a bug") + XCTAssertEqual(subject.htmlURL, NSURL(string: "https://github.com/octocat/Hello-World/issues/1347")) + XCTAssertEqual(subject.state!, IssueState.Open) + XCTAssertEqual(subject.locked!, false) + } +} diff --git a/README.md b/README.md index 3bdbcdd7..3bd222f4 100644 --- a/README.md +++ b/README.md @@ -247,6 +247,8 @@ Octokit().myFollowing() { response in ## Issues +### Get issues of authenticated user + Get all issues across all the authenticated user's visible repositories including owned repositories, member repositories, and organization repositories. ```swift @@ -260,3 +262,42 @@ Octokit(config).myIssues() { response in } ``` +### Get a single issue + +```swift +let (owner, repo, number) = ("owner", "repo", 1347) // replace with actual owner, repo name, and issue number +Octokit(config).issue(owner, repository: repo, number: number) { response in + switch response { + case .Success(let issue): + // do something with the issue + case .Failure: + // handle any errors + } +} +``` + +### Open a new issue + +```swift +Octokit(config).postIssue("owner", repository: "repo", title: "Found a bug", body: "I'm having a problem with this.", assignee: "octocat") { response in + switch response { + case .Success(let issue): + // do something with the issue + case .Failure: + // handle any errors + } +} +``` + +### Edit an existing issue + +```swift +Octokit(config).patchIssue("owner", repository: "repo", number: 1347, title: "Found a bug", body: "I'm having a problem with this.", assignee: "octocat", state: .Closed) { response in + switch response { + case .Success(let issue): + // do something with the issue + case .Failure: + // handle any errors + } +} +``` From f3354e85673600c0317e892a6d9ac9235abdaa9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguye=CC=82=CC=83n?= Date: Sun, 6 Mar 2016 20:57:09 -0800 Subject: [PATCH 054/302] Addressed code review feedback Additionally removed extraneous unwrapping from existing tests. --- OctoKit/Issue.swift | 39 ++++++++++--------------- OctoKit/Milestone.swift | 42 ++++++++++----------------- OctoKitTests/ConfigurationTests.swift | 8 ++--- OctoKitTests/IssueTests.swift | 14 ++++----- OctoKitTests/RepositoryTests.swift | 18 ++++++------ OctoKitTests/UserTests.swift | 26 ++++++++--------- 6 files changed, 64 insertions(+), 83 deletions(-) diff --git a/OctoKit/Issue.swift b/OctoKit/Issue.swift index f0e728b1..051e56ab 100644 --- a/OctoKit/Issue.swift +++ b/OctoKit/Issue.swift @@ -3,7 +3,7 @@ import RequestKit // MARK: model -public enum IssueState: String { +public enum Openness: String { case Open = "open" case Closed = "closed" } @@ -17,7 +17,7 @@ public enum IssueState: String { public var eventsURL: NSURL? public var htmlURL: NSURL? public var number: Int? - public var state: IssueState? + public var state: Openness? public var title: String? public var body: String? public var user: User? @@ -25,11 +25,11 @@ public enum IssueState: String { public var assignee: User? public var milestone: Milestone? public var locked: Bool? - public var numberOfComments: Int? - public var closureDate: NSDate? - public var creationDate: NSDate? - public var updateDate: NSDate? - public var closer: User? + public var comments: Int? + public var closedAt: NSDate? + public var createdAt: NSDate? + public var updatedAt: NSDate? + public var closedBy: User? public init(_ json: [String: AnyObject]) { if let id = json["id"] as? Int { @@ -53,14 +53,7 @@ public enum IssueState: String { htmlURL = url } number = json["number"] as? Int - switch json["state"] as? String ?? "" { - case "open": - state = .Open - case "closed": - state = .Closed - default: - break - } + state = Openness(rawValue: json["state"] as? String ?? "") title = json["title"] as? String body = json["body"] as? String user = User(json["user"] as? [String: AnyObject] ?? [:]) @@ -70,13 +63,13 @@ public enum IssueState: String { assignee = User(json["assignee"] as? [String: AnyObject] ?? [:]) milestone = Milestone(json["milestone"] as? [String: AnyObject] ?? [:]) locked = json["locked"] as? Bool - numberOfComments = json["comments"] as? Int - closureDate = Time.rfc3339Date(json["closed_at"] as? String) - creationDate = Time.rfc3339Date(json["created_at"] as? String) - updateDate = Time.rfc3339Date(json["updated_at"] as? String) - closer = User(json["closed_by"] as? [String: AnyObject] ?? [:]) + comments = json["comments"] as? Int + closedAt = Time.rfc3339Date(json["closed_at"] as? String) + createdAt = Time.rfc3339Date(json["created_at"] as? String) + updatedAt = Time.rfc3339Date(json["updated_at"] as? String) + closedBy = User(json["closed_by"] as? [String: AnyObject] ?? [:]) } else { - self.id = -1 + id = -1 } } } @@ -160,7 +153,7 @@ public extension Octokit { - parameter state: Whether the issue is open or closed. - parameter completion: Callback for the issue that is created. */ - public func patchIssue(owner: String, repository: String, number: Int, title: String? = nil, body: String? = nil, assignee: String? = nil, state: IssueState? = nil, completion: (response:Response) -> Void) { + public func patchIssue(owner: String, repository: String, number: Int, title: String? = nil, body: String? = nil, assignee: String? = nil, state: Openness? = nil, completion: (response:Response) -> Void) { let router = IssueRouter.PatchIssue(configuration, owner, repository, number, title, body, assignee, state) router.postJSON([String: AnyObject].self) { json, error in if let error = error { @@ -181,7 +174,7 @@ enum IssueRouter: JSONPostRouter { case ReadAuthenticatedIssues(Configuration, String, String) case ReadIssue(Configuration, String, String, Int) case PostIssue(Configuration, String, String, String, String?, String?) - case PatchIssue(Configuration, String, String, Int, String?, String?, String?, IssueState?) + case PatchIssue(Configuration, String, String, Int, String?, String?, String?, Openness?) var method: HTTPMethod { switch self { diff --git a/OctoKit/Milestone.swift b/OctoKit/Milestone.swift index eec068ab..3a2a4e06 100644 --- a/OctoKit/Milestone.swift +++ b/OctoKit/Milestone.swift @@ -1,26 +1,21 @@ import Foundation -@objc public enum MilestoneState: Int { - case Open - case Closed -} - @objc public class Milestone: NSObject { public var url: NSURL? public var htmlURL: NSURL? public var labelsURL: NSURL? public var id: Int public var number: Int? - public var state: MilestoneState? + public var state: Openness? public var title: String? public var milestoneDescription: String? public var creator: User? - public var numberOfOpenIssues: Int? - public var numberOfClosedIssues: Int? - public var creationDate: NSDate? - public var updateDate: NSDate? - public var closureDate: NSDate? - public var dueDate: NSDate? + public var openIssues: Int? + public var closedIssues: Int? + public var createdAt: NSDate? + public var updatedAt: NSDate? + public var closedAt: NSDate? + public var dueOn: NSDate? public init?(_ json: [String: AnyObject]) { if let id = json["id"] as? Int { @@ -32,25 +27,18 @@ import Foundation } self.id = id number = json["number"] as? Int - switch json["state"] as? String ?? "" { - case "open": - state = .Open - case "closed": - state = .Closed - default: - break - } + state = Openness(rawValue: json["state"] as? String ?? "") title = json["title"] as? String milestoneDescription = json["description"] as? String creator = User(json["creator"] as? [String: AnyObject] ?? [:]) - numberOfOpenIssues = json["open_issues"] as? Int - numberOfClosedIssues = json["closed_issues"] as? Int - creationDate = Time.rfc3339Date(json["created_at"] as? String) - updateDate = Time.rfc3339Date(json["updated_at"] as? String) - closureDate = Time.rfc3339Date(json["closed_at"] as? String) - dueDate = Time.rfc3339Date(json["due_on"] as? String) + openIssues = json["open_issues"] as? Int + closedIssues = json["closed_issues"] as? Int + createdAt = Time.rfc3339Date(json["created_at"] as? String) + updatedAt = Time.rfc3339Date(json["updated_at"] as? String) + closedAt = Time.rfc3339Date(json["closed_at"] as? String) + dueOn = Time.rfc3339Date(json["due_on"] as? String) } else { - self.id = -1 + id = -1 } } } diff --git a/OctoKitTests/ConfigurationTests.swift b/OctoKitTests/ConfigurationTests.swift index bb2514ce..548da909 100644 --- a/OctoKitTests/ConfigurationTests.swift +++ b/OctoKitTests/ConfigurationTests.swift @@ -17,13 +17,13 @@ class ConfigurationTests: XCTestCase { func testTokenConfiguration() { let subject = TokenConfiguration("12345") - XCTAssertEqual(subject.accessToken!, "12345") + XCTAssertEqual(subject.accessToken, "12345") XCTAssertEqual(subject.apiEndpoint, "https://api.github.com") } func testEnterpriseTokenConfiguration() { let subject = TokenConfiguration("12345", url: enterpriseURL) - XCTAssertEqual(subject.accessToken!, "12345") + XCTAssertEqual(subject.accessToken, "12345") XCTAssertEqual(subject.apiEndpoint, enterpriseURL) } @@ -45,7 +45,7 @@ class ConfigurationTests: XCTestCase { let config = OAuthConfiguration(token: "12345", secret: "6789", scopes: ["repo", "read:org"]) let response = "access_token=017ec60f4a182&scope=read%3Aorg%2Crepo&token_type=bearer" let expectation = "017ec60f4a182" - XCTAssertEqual(config.accessTokenFromResponse(response)!, expectation) + XCTAssertEqual(config.accessTokenFromResponse(response), expectation) } func testHandleOpenURL() { @@ -55,7 +55,7 @@ class ConfigurationTests: XCTestCase { let expectation = expectationWithDescription("access_token") let url = NSURL(string: "urlscheme://authorize?code=dhfjgh23493")! config.handleOpenURL(url) { token in - XCTAssertEqual(token.accessToken!, "017ec60f4a182") + XCTAssertEqual(token.accessToken, "017ec60f4a182") expectation.fulfill() } waitForExpectationsWithTimeout(10, handler: { error in diff --git a/OctoKitTests/IssueTests.swift b/OctoKitTests/IssueTests.swift index 19158209..a7ac10f1 100644 --- a/OctoKitTests/IssueTests.swift +++ b/OctoKitTests/IssueTests.swift @@ -48,7 +48,7 @@ class IssueTests: XCTestCase { Octokit().issue(owner, repository: repo, number: number) { response in switch response { case .Success(let issue): - XCTAssertEqual(issue.number!, number) + XCTAssertEqual(issue.number, number) expectation.fulfill() case .Failure: XCTAssert(false, "should not get an error") @@ -67,14 +67,14 @@ class IssueTests: XCTestCase { func testParsingIssue() { let subject = Issue(Helper.JSONFromFile("issue") as! [String: AnyObject]) - XCTAssertEqual(subject.user!.login!, "octocat") - XCTAssertEqual(subject.user!.id, 1) + XCTAssertEqual(subject.user?.login, "octocat") + XCTAssertEqual(subject.user?.id, 1) XCTAssertEqual(subject.id, 1) - XCTAssertEqual(subject.number!, 1347) - XCTAssertEqual(subject.title!, "Found a bug") + XCTAssertEqual(subject.number, 1347) + XCTAssertEqual(subject.title, "Found a bug") XCTAssertEqual(subject.htmlURL, NSURL(string: "https://github.com/octocat/Hello-World/issues/1347")) - XCTAssertEqual(subject.state!, IssueState.Open) - XCTAssertEqual(subject.locked!, false) + XCTAssertEqual(subject.state, Openness.Open) + XCTAssertEqual(subject.locked, false) } } diff --git a/OctoKitTests/RepositoryTests.swift b/OctoKitTests/RepositoryTests.swift index 03f9b902..4247fe6e 100644 --- a/OctoKitTests/RepositoryTests.swift +++ b/OctoKitTests/RepositoryTests.swift @@ -94,8 +94,8 @@ class RepositoryTests: XCTestCase { Octokit().repository(owner, name: name) { response in switch response { case .Success(let repo): - XCTAssertEqual(repo.name!, name) - XCTAssertEqual(repo.owner.login!, owner) + XCTAssertEqual(repo.name, name) + XCTAssertEqual(repo.owner.login, owner) expectation.fulfill() case .Failure: XCTAssert(false, "should not get an error") @@ -137,18 +137,18 @@ class RepositoryTests: XCTestCase { func testUserParsingFullRepository() { let subject = Repository(Helper.JSONFromFile("repo") as! [String: AnyObject]) - XCTAssertEqual(subject.owner.login!, "mietzmithut") + XCTAssertEqual(subject.owner.login, "mietzmithut") XCTAssertEqual(subject.owner.id, 4672699) XCTAssertEqual(subject.id, 10824973) - XCTAssertEqual(subject.name!, "Test") - XCTAssertEqual(subject.fullName!, "mietzmithut/Test") + XCTAssertEqual(subject.name, "Test") + XCTAssertEqual(subject.fullName, "mietzmithut/Test") XCTAssertEqual(subject.isPrivate, false) XCTAssertEqual(subject.repositoryDescription, "") - XCTAssertEqual(subject.isFork!, false) - XCTAssertEqual(subject.gitURL!, "git://github.com/mietzmithut/Test.git") - XCTAssertEqual(subject.sshURL!, "git@github.com:mietzmithut/Test.git") - XCTAssertEqual(subject.cloneURL!, "https://github.com/mietzmithut/Test.git") + XCTAssertEqual(subject.isFork, false) + XCTAssertEqual(subject.gitURL, "git://github.com/mietzmithut/Test.git") + XCTAssertEqual(subject.sshURL, "git@github.com:mietzmithut/Test.git") + XCTAssertEqual(subject.cloneURL, "https://github.com/mietzmithut/Test.git") XCTAssertEqual(subject.size, 132) } } diff --git a/OctoKitTests/UserTests.swift b/OctoKitTests/UserTests.swift index c0377e7e..5c157f19 100644 --- a/OctoKitTests/UserTests.swift +++ b/OctoKitTests/UserTests.swift @@ -24,7 +24,7 @@ class UserTests: XCTestCase { Octokit().user(username) { response in switch response { case .Success(let user): - XCTAssertEqual(user.login!, username) + XCTAssertEqual(user.login, username) expectation.fulfill() case .Failure: XCTAssert(false, "should not get an user") @@ -69,7 +69,7 @@ class UserTests: XCTestCase { Octokit(TokenConfiguration("token")).me() { response in switch response { case .Success(let user): - XCTAssertEqual(user.login!, "pietbrauer") + XCTAssertEqual(user.login, "pietbrauer") expectation.fulfill() case .Failure(let error): XCTAssert(false, "should not retrieve an error \(error)") @@ -110,19 +110,19 @@ class UserTests: XCTestCase { func testUserParsingFullUser() { let subject = User(Helper.JSONFromFile("user_me") as! [String: AnyObject]) - XCTAssertEqual(subject.login!, "pietbrauer") + XCTAssertEqual(subject.login, "pietbrauer") XCTAssertEqual(subject.id, 759730) - XCTAssertEqual(subject.avatarURL!, "https://avatars.githubusercontent.com/u/759730?v=3") - XCTAssertEqual(subject.gravatarID!, "") - XCTAssertEqual(subject.type!, "User") - XCTAssertEqual(subject.name!, "Piet Brauer") - XCTAssertEqual(subject.company!, "XING AG") - XCTAssertEqual(subject.blog!, "xing.to/PietBrauer") - XCTAssertEqual(subject.location!, "Hamburg") + XCTAssertEqual(subject.avatarURL, "https://avatars.githubusercontent.com/u/759730?v=3") + XCTAssertEqual(subject.gravatarID, "") + XCTAssertEqual(subject.type, "User") + XCTAssertEqual(subject.name, "Piet Brauer") + XCTAssertEqual(subject.company, "XING AG") + XCTAssertEqual(subject.blog, "xing.to/PietBrauer") + XCTAssertEqual(subject.location, "Hamburg") XCTAssertNil(subject.email) - XCTAssertEqual(subject.numberOfPublicRepos!, 6) - XCTAssertEqual(subject.numberOfPublicGists!, 10) - XCTAssertEqual(subject.numberOfPrivateRepos!, 4) + XCTAssertEqual(subject.numberOfPublicRepos, 6) + XCTAssertEqual(subject.numberOfPublicGists, 10) + XCTAssertEqual(subject.numberOfPrivateRepos, 4) } func testUserParsingMinimalUser() { From d2096d4386ce21f99d63596cf73510d04cd79a9f Mon Sep 17 00:00:00 2001 From: Piet Brauer Date: Thu, 24 Mar 2016 14:42:02 +0800 Subject: [PATCH 055/302] Use Xcode 7.3 --- .gitignore | 3 + .travis.yml | 14 ++-- Cartfile | 2 +- Cartfile.resolved | 4 +- Gemfile.lock | 102 ++++++++++++-------------- fastlane/.env.default | 6 +- fastlane/.env.ios92 | 2 - fastlane/.env.ios93 | 2 + fastlane/{.env.tvos91 => .env.tvos92} | 4 +- 9 files changed, 66 insertions(+), 73 deletions(-) delete mode 100644 fastlane/.env.ios92 create mode 100644 fastlane/.env.ios93 rename fastlane/{.env.tvos91 => .env.tvos92} (54%) diff --git a/.gitignore b/.gitignore index 89940e39..83e7347c 100644 --- a/.gitignore +++ b/.gitignore @@ -19,6 +19,9 @@ DerivedData # AppCode .idea +fastlane/README.md +fastlane/test-output +fastlane/report.xml .DS_Store Pods/ diff --git a/.travis.yml b/.travis.yml index d8b84311..86f463d2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ language: objective-c -osx_image: xcode7.1 +osx_image: xcode7.3 sudo: false env: global: @@ -8,13 +8,13 @@ env: - FASTLANE_LANE=ci_commit matrix: include: - - osx_image: xcode7.2 + - osx_image: xcode7.3 env: FASTLANE_LANE=code_coverage FASTLANE_ENV=default - - osx_image: xcode7.2 - env: FASTLANE_ENV=ios92 - - osx_image: xcode7.2 - env: FASTLANE_ENV=tvos91 - - osx_image: xcode7.2 + - osx_image: xcode7.3 + env: FASTLANE_ENV=ios93 + - osx_image: xcode7.3 + env: FASTLANE_ENV=tvos92 + - osx_image: xcode7.3 env: FASTLANE_ENV=osx before_install: - make install diff --git a/Cartfile b/Cartfile index 1676ef82..9a3f8296 100644 --- a/Cartfile +++ b/Cartfile @@ -1 +1 @@ -github "nerdishbynature/RequestKit" ~> 0.2.2 +github "nerdishbynature/RequestKit" ~> 0.3.0 diff --git a/Cartfile.resolved b/Cartfile.resolved index f253b411..1522e6d5 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1,2 +1,2 @@ -github "nerdishbynature/Nocilla" "57161f3454bebebf111e3e3b2a0b9cb300e2d0ac" -github "nerdishbynature/RequestKit" "0.2.2" +github "nerdishbynature/Nocilla" "963cb6f4f23f4c03039df45316f893a9339a0068" +github "nerdishbynature/RequestKit" "0.3.0" diff --git a/Gemfile.lock b/Gemfile.lock index 4bf68f56..0400ff52 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ GEM remote: https://rubygems.org/ specs: - activesupport (4.2.5.1) + activesupport (4.2.6) i18n (~> 0.7) json (~> 1.7, >= 1.7.7) minitest (~> 5.1) @@ -9,9 +9,9 @@ GEM tzinfo (~> 1.1) addressable (2.3.8) babosa (1.0.2) - cert (1.3.0) + cert (1.4.0) fastlane_core (>= 0.29.1, < 1.0.0) - spaceship (>= 0.16.0, < 1.0.0) + spaceship (>= 0.22.0, < 1.0.0) claide (0.9.1) clamp (0.6.5) cocoapods (0.39.0) @@ -42,7 +42,6 @@ GEM nap (>= 0.8, < 2.0) netrc (= 0.7.8) cocoapods-try (0.5.1) - coderay (1.1.1) colored (1.2) commander (4.3.5) highline (~> 1.7.2) @@ -51,13 +50,13 @@ GEM commander (>= 4.3.5) highline (>= 1.7.1) security - deliver (1.10.3) + deliver (1.10.5) credentials_manager (>= 0.12.0, < 1.0.0) fastimage (~> 1.6) - fastlane_core (>= 0.36.4, < 1.0.0) + fastlane_core (>= 0.37.0, < 1.0.0) plist (~> 3.1.0) - spaceship (>= 0.19.0, <= 1.0.0) - domain_name (0.5.20160128) + spaceship (>= 0.19.0, < 1.0.0) + domain_name (0.5.20160310) unf (>= 0.0.5, < 1.0.0) dotenv (2.1.0) escape (0.0.4) @@ -71,32 +70,32 @@ GEM faraday (>= 0.7.4, < 0.10) fastimage (1.6.8) addressable (~> 2.3, >= 2.3.5) - fastlane (1.61.0) + fastlane (1.68.0) addressable (~> 2.3.8) - cert (>= 1.3.0, < 2.0.0) + cert (>= 1.4.0, < 2.0.0) credentials_manager (>= 0.15.0, < 1.0.0) - deliver (>= 1.10.1, < 2.0.0) - fastlane_core (>= 0.36.5, < 1.0.0) - frameit (>= 2.4.1, < 3.0.0) - gym (>= 1.6.1, < 2.0.0) + deliver (>= 1.10.5, < 2.0.0) + fastlane_core (>= 0.37.0, < 1.0.0) + frameit (>= 2.5.1, < 3.0.0) + gym (>= 1.6.2, < 2.0.0) krausefx-shenzhen (>= 0.14.7) - match (>= 0.3.0, < 1.0.0) - pem (>= 1.2.0, < 2.0.0) - pilot (>= 1.3.0, < 2.0.0) + match (>= 0.4.0, < 1.0.0) + pem (>= 1.3.0, < 2.0.0) + pilot (>= 1.4.1, < 2.0.0) plist (~> 3.1.0) - produce (>= 1.1.0, < 2.0.0) - scan (>= 0.5.0, < 1.0.0) - screengrab (>= 0.2.0, < 1.0.0) - sigh (>= 1.3.1, < 2.0.0) + produce (>= 1.1.1, < 2.0.0) + scan (>= 0.5.2, < 1.0.0) + screengrab (>= 0.3.1, < 1.0.0) + sigh (>= 1.6.0, < 2.0.0) slack-notifier (~> 1.3) - snapshot (>= 1.7.0, < 2.0.0) - spaceship (>= 0.19.4, < 1.0.0) + snapshot (>= 1.12.0, < 2.0.0) + spaceship (>= 0.24.0, < 1.0.0) supply (>= 0.4.0, < 1.0.0) terminal-notifier (~> 1.6.2) terminal-table (~> 1.4.5) - xcodeproj (>= 0.20, < 1.0.0) + xcodeproj (>= 0.20, < 2.0.0) xcpretty (>= 0.2.1) - fastlane_core (0.36.6) + fastlane_core (0.39.0) babosa colored commander (= 4.3.5) @@ -109,21 +108,19 @@ GEM rubyzip (~> 1.1.6) sentry-raven (~> 0.15) terminal-table (~> 1.4.5) - frameit (2.4.1) + frameit (2.5.1) deliver (> 0.3) fastimage (~> 1.6.3) - fastlane_core (>= 0.16.0, < 1.0.0) + fastlane_core (>= 0.36.1, < 1.0.0) mini_magick (~> 4.0.2) fuzzy_match (2.0.4) - google-api-client (0.9.2) - activesupport (>= 3.2) + google-api-client (0.9.4) addressable (~> 2.3) googleauth (~> 0.5) httpclient (~> 2.7) hurley (~> 0.1) memoist (~> 0.11) mime-types (>= 1.6) - multi_json (~> 1.11) representable (~> 2.3.0) retriable (~> 2.0) thor (~> 0.19) @@ -135,7 +132,7 @@ GEM multi_json (~> 1.11) os (~> 0.9) signet (~> 0.7) - gym (1.6.1) + gym (1.6.2) fastlane_core (>= 0.36.1, < 1.0.0) plist rubyzip (>= 1.1.7) @@ -148,7 +145,7 @@ GEM hurley (0.2) i18n (0.7.0) json (1.8.3) - jwt (1.5.2) + jwt (1.5.3) krausefx-shenzhen (0.14.7) commander (~> 4.3) dotenv (>= 0.7) @@ -162,21 +159,20 @@ GEM security (~> 0.1.3) terminal-table (~> 1.4.5) little-plugger (1.1.4) - logging (2.0.0) + logging (2.1.0) little-plugger (~> 1.1) multi_json (~> 1.10) - match (0.3.0) + match (0.4.0) cert (>= 1.2.8, < 2.0.0) credentials_manager (>= 0.13.0, < 1.0.0) - fastlane_core (>= 0.36.1, < 1.0.0) + fastlane_core (>= 0.39.0, < 1.0.0) security sigh (>= 1.2.2, < 2.0.0) - spaceship (>= 0.18.1, < 1.0.0) + spaceship (>= 0.24.0, < 1.0.0) memoist (0.14.0) - method_source (0.8.2) mime-types (3.0) mime-types-data (~> 3.2015) - mime-types-data (3.2015.1120) + mime-types-data (3.2016.0221) mini_magick (4.0.4) mini_portile2 (2.0.0) minitest (5.8.4) @@ -187,14 +183,14 @@ GEM nap (1.1.0) net-sftp (2.1.2) net-ssh (>= 2.6.5) - net-ssh (3.0.2) + net-ssh (3.1.1) netrc (0.7.8) nokogiri (1.6.7.2) mini_portile2 (~> 2.0.0.rc2) os (0.9.6) - pem (1.2.0) + pem (1.3.0) fastlane_core (>= 0.36.1, < 1.0.0) - spaceship (>= 0.19.3, < 1.0.0) + spaceship (>= 0.22.0, < 1.0.0) pilot (1.4.1) credentials_manager (>= 0.3.0) fastlane_core (>= 0.36.5, < 1.0.0) @@ -204,30 +200,26 @@ GEM produce (1.1.1) fastlane_core (>= 0.30.0, < 1.0.0) spaceship (>= 0.16.0) - pry (0.10.3) - coderay (~> 1.1.0) - method_source (~> 0.8.1) - slop (~> 3.4) representable (2.3.0) uber (~> 0.0.7) retriable (2.1.0) rouge (1.10.1) rubyzip (1.1.7) - scan (0.5.0) + scan (0.5.2) fastlane_core (>= 0.36.1, < 1.0.0) slack-notifier (~> 1.3) terminal-table xcpretty (>= 0.2.1) xcpretty-travis-formatter (>= 0.0.3) - screengrab (0.2.0) - fastlane_core (>= 0.36.1, < 1.0.0) + screengrab (0.3.1) + fastlane_core (>= 0.38.0, < 1.0.0) security (0.1.3) - sentry-raven (0.15.5) + sentry-raven (0.15.6) faraday (>= 0.7.6) - sigh (1.3.1) + sigh (1.6.0) fastlane_core (>= 0.36.1, < 1.0.0) plist (~> 3.1) - spaceship (>= 0.12.3) + spaceship (>= 0.22.0, < 1.0.0) signet (0.7.2) addressable (~> 2.3) faraday (~> 0.9) @@ -238,13 +230,12 @@ GEM clamp (~> 0.6) nokogiri (~> 1.6.3) xcodeproj (>= 0.28.2, < 1.1.0) - slop (3.6.0) - snapshot (1.8.0) + snapshot (1.12.1) fastimage (~> 1.6.3) fastlane_core (>= 0.36.1, < 1.0.0) plist (~> 3.1.0) xcpretty (>= 0.2.1) - spaceship (0.21.0) + spaceship (0.24.0) colored credentials_manager (>= 0.9.0) faraday (~> 0.9) @@ -253,8 +244,7 @@ GEM fastimage (~> 1.6) multi_xml (~> 0.5) plist (~> 3.1) - pry - supply (0.4.0) + supply (0.5.2) credentials_manager (>= 0.15.0) fastlane_core (>= 0.35.0) google-api-client (~> 0.9.1) diff --git a/fastlane/.env.default b/fastlane/.env.default index acb1c8fd..4ddc8573 100644 --- a/fastlane/.env.default +++ b/fastlane/.env.default @@ -1,11 +1,11 @@ -AF_IOS_SDK=iphonesimulator9.2 +AF_IOS_SDK=iphonesimulator9.3 AF_MAC_SDK=macosx10.11 -AF_TVOS_SDK=appletvsimulator9.1 +AF_TVOS_SDK=appletvsimulator9.2 AF_CONFIGURATION=Release SCAN_SCHEME=$AF_IOS_FRAMEWORK_SCHEME -SCAN_DESTINATION="OS=9.2,name=iPhone 6s" +SCAN_DESTINATION="OS=9.3,name=iPhone 6s" SCAN_SDK=$AF_IOS_SDK SCAN_OUTPUT_DIRECTORY=fastlane/test-output DEPLOY_PODSPEC=OctoKit.swift.podspec diff --git a/fastlane/.env.ios92 b/fastlane/.env.ios92 deleted file mode 100644 index 67e5e829..00000000 --- a/fastlane/.env.ios92 +++ /dev/null @@ -1,2 +0,0 @@ -SCAN_DESTINATION="OS=9.2,name=iPhone 6s" -EXAMPLE_DESTINATION=$SCAN_DESTINATION \ No newline at end of file diff --git a/fastlane/.env.ios93 b/fastlane/.env.ios93 new file mode 100644 index 00000000..de22ac58 --- /dev/null +++ b/fastlane/.env.ios93 @@ -0,0 +1,2 @@ +SCAN_DESTINATION="OS=9.3,name=iPhone 6s" +EXAMPLE_DESTINATION=$SCAN_DESTINATION diff --git a/fastlane/.env.tvos91 b/fastlane/.env.tvos92 similarity index 54% rename from fastlane/.env.tvos91 rename to fastlane/.env.tvos92 index 54cd02b3..7220bc3a 100644 --- a/fastlane/.env.tvos91 +++ b/fastlane/.env.tvos92 @@ -1,6 +1,6 @@ SCAN_SCHEME=$AF_TVOS_FRAMEWORK_SCHEME -SCAN_DESTINATION="OS=9.1,name=Apple TV 1080p" +SCAN_DESTINATION="OS=9.2,name=Apple TV 1080p" SCAN_SDK=$AF_TVOS_SDK EXAMPLE_SCHEME=$AF_TVOS_EXAMPLE_SCHEME -EXAMPLE_DESTINATION=$SCAN_DESTINATION \ No newline at end of file +EXAMPLE_DESTINATION=$SCAN_DESTINATION From 0d9eabbb03597949da283f4005f580a261e98355 Mon Sep 17 00:00:00 2001 From: Piet Brauer Date: Thu, 24 Mar 2016 14:59:00 +0800 Subject: [PATCH 056/302] Bump version --- OctoKit.swift.podspec | 4 ++-- OctoKit/Info.plist | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/OctoKit.swift.podspec b/OctoKit.swift.podspec index da0d34b5..48bee261 100644 --- a/OctoKit.swift.podspec +++ b/OctoKit.swift.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "OctoKit.swift" - s.version = "0.5.2" + s.version = "0.6.0" s.summary = "A Swift API Client for GitHub and GitHub Enterprise" s.description = <<-DESC You are looking at the A Swift API Client for GitHub and GitHub Enterprise. @@ -12,7 +12,7 @@ Pod::Spec.new do |s| s.source = { :git => "https://github.com/nerdishbynature/octokit.swift.git", :tag => s.version.to_s } s.social_media_url = "https://twitter.com/pietbrauer" s.module_name = "Octokit" - s.dependency "NBNRequestKit", "~> 0.2.2" + s.dependency "NBNRequestKit", "~> 0.3.0" s.requires_arc = true s.source_files = "OctoKit/*.swift" s.ios.deployment_target = '8.0' diff --git a/OctoKit/Info.plist b/OctoKit/Info.plist index 0d4fc0a8..63c3e67d 100644 --- a/OctoKit/Info.plist +++ b/OctoKit/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 0.5.2 + 0.6.0 CFBundleSignature ???? CFBundleVersion From 2f53c86fd7e9b28dd567b5e84da139170649ff3d Mon Sep 17 00:00:00 2001 From: Piet Brauer Date: Thu, 21 Apr 2016 07:06:39 +0700 Subject: [PATCH 057/302] No signup for authorize request --- OctoKit/Configuration.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OctoKit/Configuration.swift b/OctoKit/Configuration.swift index 3044557f..43f0c34d 100644 --- a/OctoKit/Configuration.swift +++ b/OctoKit/Configuration.swift @@ -116,7 +116,7 @@ enum OAuthRouter: Router { switch self { case .Authorize(let config): let scope = (config.scopes as NSArray).componentsJoinedByString(",") - return ["scope": scope, "client_id": config.token] + return ["scope": scope, "client_id": config.token, "allow_signup": "false"] case .AccessToken(let config, let code): return ["client_id": config.token, "client_secret": config.secret, "code": code] } From 9c7ef4633868f42b87ae4fcf4da54b5f7f3f489d Mon Sep 17 00:00:00 2001 From: Piet Brauer Date: Thu, 21 Apr 2016 07:14:09 +0700 Subject: [PATCH 058/302] Update jwt --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 0400ff52..89cc279d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -145,7 +145,7 @@ GEM hurley (0.2) i18n (0.7.0) json (1.8.3) - jwt (1.5.3) + jwt (1.5.4) krausefx-shenzhen (0.14.7) commander (~> 4.3) dotenv (>= 0.7) From 9bbce57d13ee3de9dd2306e171e2100d1620ffae Mon Sep 17 00:00:00 2001 From: Piet Brauer Date: Thu, 21 Apr 2016 07:32:08 +0700 Subject: [PATCH 059/302] Bump version --- OctoKit.swift.podspec | 2 +- OctoKit/Info.plist | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/OctoKit.swift.podspec b/OctoKit.swift.podspec index 48bee261..a79d78b6 100644 --- a/OctoKit.swift.podspec +++ b/OctoKit.swift.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "OctoKit.swift" - s.version = "0.6.0" + s.version = "0.6.1" s.summary = "A Swift API Client for GitHub and GitHub Enterprise" s.description = <<-DESC You are looking at the A Swift API Client for GitHub and GitHub Enterprise. diff --git a/OctoKit/Info.plist b/OctoKit/Info.plist index 63c3e67d..5b6037da 100644 --- a/OctoKit/Info.plist +++ b/OctoKit/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 0.6.0 + 0.6.1 CFBundleSignature ???? CFBundleVersion From 7a165033600eec93f5cb2b8588cd43e8f5430987 Mon Sep 17 00:00:00 2001 From: Piet Brauer Date: Mon, 28 Mar 2016 16:06:20 +0800 Subject: [PATCH 060/302] Update RequestKit to 1.0.0 --- Cartfile | 2 +- Cartfile.resolved | 3 +-- OctoKit/Follow.swift | 8 ++++---- OctoKit/Issue.swift | 8 ++++---- OctoKit/PublicKey.swift | 2 +- OctoKit/Repositories.swift | 4 ++-- OctoKit/Stars.swift | 4 ++-- OctoKit/User.swift | 4 ++-- 8 files changed, 17 insertions(+), 18 deletions(-) diff --git a/Cartfile b/Cartfile index 9a3f8296..d7f1ac68 100644 --- a/Cartfile +++ b/Cartfile @@ -1 +1 @@ -github "nerdishbynature/RequestKit" ~> 0.3.0 +github "nerdishbynature/RequestKit" ~> 1.0 diff --git a/Cartfile.resolved b/Cartfile.resolved index 1522e6d5..fd2994fb 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1,2 +1 @@ -github "nerdishbynature/Nocilla" "963cb6f4f23f4c03039df45316f893a9339a0068" -github "nerdishbynature/RequestKit" "0.3.0" +github "nerdishbynature/RequestKit" "1.0.0" diff --git a/OctoKit/Follow.swift b/OctoKit/Follow.swift index 9a76993f..e6399d1b 100644 --- a/OctoKit/Follow.swift +++ b/OctoKit/Follow.swift @@ -9,7 +9,7 @@ public extension Octokit { */ public func myFollowers(completion: (response: Response<[User]>) -> Void) { let router = FollowRouter.ReadAuthenticatedFollowers(configuration) - router.loadJSON([[String: AnyObject]].self) { json, error in + router.loadJSON(expectedResultType: [[String: AnyObject]].self) { json, error in if let error = error { completion(response: Response.Failure(error)) } else { @@ -28,7 +28,7 @@ public extension Octokit { */ public func followers(name: String, completion: (response: Response<[User]>) -> Void) { let router = FollowRouter.ReadFollowers(name, configuration) - router.loadJSON([[String: AnyObject]].self) { json, error in + router.loadJSON(expectedResultType: [[String: AnyObject]].self) { json, error in if let error = error { completion(response: Response.Failure(error)) } else { @@ -46,7 +46,7 @@ public extension Octokit { */ public func myFollowing(completion: (response: Response<[User]>) -> Void) { let router = FollowRouter.ReadAuthenticatedFollowing(configuration) - router.loadJSON([[String: AnyObject]].self) { json, error in + router.loadJSON(expectedResultType: [[String: AnyObject]].self) { json, error in if let error = error { completion(response: Response.Failure(error)) } else { @@ -65,7 +65,7 @@ public extension Octokit { */ public func following(name: String, completion: (response: Response<[User]>) -> Void) { let router = FollowRouter.ReadFollowing(name, configuration) - router.loadJSON([[String: AnyObject]].self) { json, error in + router.loadJSON(expectedResultType: [[String: AnyObject]].self) { json, error in if let error = error { completion(response: Response.Failure(error)) } else { diff --git a/OctoKit/Issue.swift b/OctoKit/Issue.swift index 051e56ab..e33d371c 100644 --- a/OctoKit/Issue.swift +++ b/OctoKit/Issue.swift @@ -86,7 +86,7 @@ public extension Octokit { */ public func myIssues(page: String = "1", perPage: String = "100", completion: (response: Response<[Issue]>) -> Void) { let router = IssueRouter.ReadAuthenticatedIssues(configuration, page, perPage) - router.loadJSON([[String: AnyObject]].self) { json, error in + router.loadJSON(expectedResultType: [[String: AnyObject]].self) { json, error in if let error = error { completion(response: Response.Failure(error)) } else { @@ -107,7 +107,7 @@ public extension Octokit { */ public func issue(owner: String, repository: String, number: Int, completion: (response: Response) -> Void) { let router = IssueRouter.ReadIssue(configuration, owner, repository, number) - router.loadJSON([String: AnyObject].self) { json, error in + router.loadJSON(expectedResultType: [String: AnyObject].self) { json, error in if let error = error { completion(response: Response.Failure(error)) } else { @@ -130,7 +130,7 @@ public extension Octokit { */ public func postIssue(owner: String, repository: String, title: String, body: String? = nil, assignee: String? = nil, completion: (response:Response) -> Void) { let router = IssueRouter.PostIssue(configuration, owner, repository, title, body, assignee) - router.postJSON([String: AnyObject].self) { json, error in + router.postJSON(expectedResultType: [String: AnyObject].self) { json, error in if let error = error { completion(response: Response.Failure(error)) } else { @@ -155,7 +155,7 @@ public extension Octokit { */ public func patchIssue(owner: String, repository: String, number: Int, title: String? = nil, body: String? = nil, assignee: String? = nil, state: Openness? = nil, completion: (response:Response) -> Void) { let router = IssueRouter.PatchIssue(configuration, owner, repository, number, title, body, assignee, state) - router.postJSON([String: AnyObject].self) { json, error in + router.postJSON(expectedResultType: [String: AnyObject].self) { json, error in if let error = error { completion(response: Response.Failure(error)) } else { diff --git a/OctoKit/PublicKey.swift b/OctoKit/PublicKey.swift index 02d97316..fa6c1112 100644 --- a/OctoKit/PublicKey.swift +++ b/OctoKit/PublicKey.swift @@ -6,7 +6,7 @@ import RequestKit public extension Octokit { public func postPublicKey(publicKey: String, title: String, completion: (response:Response) -> Void) { let router = PublicKeyRouter.PostPublicKey(publicKey, title, configuration) - router.postJSON([String: AnyObject].self) { json, error in + router.postJSON(expectedResultType: [String: AnyObject].self) { json, error in if let error = error { completion(response: Response.Failure(error)) } else { diff --git a/OctoKit/Repositories.swift b/OctoKit/Repositories.swift index fa69b713..b0ce5be5 100644 --- a/OctoKit/Repositories.swift +++ b/OctoKit/Repositories.swift @@ -56,7 +56,7 @@ public extension Octokit { let router = (owner != nil) ? RepositoryRouter.ReadRepositories(configuration, owner!, page, perPage) : RepositoryRouter.ReadAuthenticatedRepositories(configuration, page, perPage) - router.loadJSON([[String: AnyObject]].self) { json, error in + router.loadJSON(expectedResultType: [[String: AnyObject]].self) { json, error in if let error = error { completion(response: Response.Failure(error)) } @@ -76,7 +76,7 @@ public extension Octokit { */ public func repository(owner: String, name: String, completion: (response: Response) -> Void) { let router = RepositoryRouter.ReadRepository(configuration, owner, name) - router.loadJSON([String: AnyObject].self) { json, error in + router.loadJSON(expectedResultType: [String: AnyObject].self) { json, error in if let error = error { completion(response: Response.Failure(error)) } else { diff --git a/OctoKit/Stars.swift b/OctoKit/Stars.swift index e53bc357..65ddbaf8 100644 --- a/OctoKit/Stars.swift +++ b/OctoKit/Stars.swift @@ -10,7 +10,7 @@ public extension Octokit { */ public func stars(name: String, completion: (response: Response<[Repository]>) -> Void) { let router = StarsRouter.ReadStars(name, configuration) - router.loadJSON([[String: AnyObject]].self) { json, error in + router.loadJSON(expectedResultType: [[String: AnyObject]].self) { json, error in if let error = error { completion(response: Response.Failure(error)) } else { @@ -28,7 +28,7 @@ public extension Octokit { */ public func myStars(completion: (response: Response<[Repository]>) -> Void) { let router = StarsRouter.ReadAuthenticatedStars(configuration) - router.loadJSON([[String: AnyObject]].self) { json, error in + router.loadJSON(expectedResultType: [[String: AnyObject]].self) { json, error in if let error = error { completion(response: Response.Failure(error)) } else { diff --git a/OctoKit/User.swift b/OctoKit/User.swift index 545e5cdc..99e66062 100644 --- a/OctoKit/User.swift +++ b/OctoKit/User.swift @@ -50,7 +50,7 @@ public extension Octokit { */ public func user(name: String, completion: (response: Response) -> Void) { let router = UserRouter.ReadUser(name, self.configuration) - router.loadJSON([String: AnyObject].self) { json, error in + router.loadJSON(expectedResultType: [String: AnyObject].self) { json, error in if let error = error { completion(response: Response.Failure(error)) } else { @@ -68,7 +68,7 @@ public extension Octokit { */ public func me(completion: (response: Response) -> Void) { let router = UserRouter.ReadAuthenticatedUser(self.configuration) - router.loadJSON([String: AnyObject].self) { json, error in + router.loadJSON(expectedResultType: [String: AnyObject].self) { json, error in if let error = error { completion(response: Response.Failure(error)) } else { From 2cd0116c8ba7057a9922002790aaa3ebfa65cc52 Mon Sep 17 00:00:00 2001 From: Piet Brauer Date: Mon, 28 Mar 2016 16:35:58 +0800 Subject: [PATCH 061/302] Use TestSession --- OctoKit/Configuration.swift | 6 ++-- OctoKit/PublicKey.swift | 4 +-- OctoKitTests/PublicKeyTests.swift | 57 +++++++++++++++---------------- 3 files changed, 33 insertions(+), 34 deletions(-) diff --git a/OctoKit/Configuration.swift b/OctoKit/Configuration.swift index 43f0c34d..c7d6f2c6 100644 --- a/OctoKit/Configuration.swift +++ b/OctoKit/Configuration.swift @@ -35,10 +35,10 @@ public struct OAuthConfiguration: Configuration { return OAuthRouter.Authorize(self).URLRequest?.URL } - public func authorize(code: String, completion: (config: TokenConfiguration) -> Void) { + public func authorize(session: RequestKitURLSession = NSURLSession.sharedSession(), code: String, completion: (config: TokenConfiguration) -> Void) { let request = OAuthRouter.AccessToken(self, code).URLRequest if let request = request { - let task = NSURLSession.sharedSession().dataTaskWithRequest(request) { data, response, err in + let task = session.dataTaskWithRequest(request) { data, response, err in if let response = response as? NSHTTPURLResponse { if response.statusCode != 200 { return @@ -59,7 +59,7 @@ public struct OAuthConfiguration: Configuration { public func handleOpenURL(url: NSURL, completion: (config: TokenConfiguration) -> Void) { if let code = url.absoluteString.componentsSeparatedByString("=").last { - authorize(code) { (config) in + authorize(code: code) { (config) in completion(config: config) } } diff --git a/OctoKit/PublicKey.swift b/OctoKit/PublicKey.swift index fa6c1112..b1351adc 100644 --- a/OctoKit/PublicKey.swift +++ b/OctoKit/PublicKey.swift @@ -4,9 +4,9 @@ import RequestKit // MARK: request public extension Octokit { - public func postPublicKey(publicKey: String, title: String, completion: (response:Response) -> Void) { + public func postPublicKey(session: RequestKitURLSession = NSURLSession.sharedSession(), publicKey: String, title: String, completion: (response:Response) -> Void) { let router = PublicKeyRouter.PostPublicKey(publicKey, title, configuration) - router.postJSON(expectedResultType: [String: AnyObject].self) { json, error in + router.postJSON(session, expectedResultType: [String: AnyObject].self) { json, error in if let error = error { completion(response: Response.Failure(error)) } else { diff --git a/OctoKitTests/PublicKeyTests.swift b/OctoKitTests/PublicKeyTests.swift index 54872cec..6467b2ae 100644 --- a/OctoKitTests/PublicKeyTests.swift +++ b/OctoKitTests/PublicKeyTests.swift @@ -1,41 +1,40 @@ import XCTest +import RequestKit import OctoKit -import Nocilla class PublicKeyTests: XCTestCase { - override func setUp() { - super.setUp() - LSNocilla.sharedInstance().start() - } - - override func tearDown() { - super.tearDown() - LSNocilla.sharedInstance().clearStubs() - LSNocilla.sharedInstance().stop() - } - // MARK: Actual Request tests func testPostPublicKey() { let config = TokenConfiguration("12345") - if let json = Helper.stringFromFile("public_key") { - stubRequest("POST", "https://api.github.com/user/keys?access_token=12345").andReturn(201).withHeaders(["Content-Type": "application/json"]).withBody(json) - let expectation = expectationWithDescription("public_key") - Octokit(config).postPublicKey("test-key", title: "test title") { response in - switch response { - case .Success(let publicKey): - XCTAssertEqual(publicKey, "test-key") - expectation.fulfill() - case .Failure: - XCTAssert(false, "should not get an error") - expectation.fulfill() - } - } - waitForExpectationsWithTimeout(1) { (error) in - XCTAssertNil(error, "\(error)") + let session = PublicKeyTestsSession() + Octokit(config).postPublicKey(session, publicKey: "test-key", title: "test title") { response in + switch response { + case .Success(let publicKey): + XCTAssertEqual(publicKey, "test-key") + case .Failure: + XCTAssert(false, "should not get an error") } - } else { - XCTFail("json shouldn't be nil") } + XCTAssertTrue(session.wasCalled) + } +} + +class PublicKeyTestsSession: RequestKitURLSession { + var wasCalled: Bool = false + + func dataTaskWithRequest(request: NSURLRequest, completionHandler: (NSData?, NSURLResponse?, NSError?) -> Void) -> URLSessionDataTaskProtocol { + XCTFail("This should not be called") + return MockURLSessionDataTask() + } + + func uploadTaskWithRequest(request: NSURLRequest, fromData bodyData: NSData?, completionHandler: (NSData?, NSURLResponse?, NSError?) -> Void) -> URLSessionDataTaskProtocol { + XCTAssertEqual(request.URL?.absoluteString, "https://api.github.com/user/keys?access_token=12345") + XCTAssertEqual(request.HTTPMethod, "POST") + let data = Helper.stringFromFile("public_key")?.dataUsingEncoding(NSUTF8StringEncoding) + let response = NSHTTPURLResponse(URL: request.URL!, statusCode: 201, HTTPVersion: "http/1.1", headerFields: ["Content-Type": "application/json"]) + completionHandler(data, response, nil) + wasCalled = true + return MockURLSessionDataTask() } } From 4ead432eb7cd35932726ef9a7fe322f9bffd2f16 Mon Sep 17 00:00:00 2001 From: Piet Brauer Date: Mon, 28 Mar 2016 17:02:03 +0800 Subject: [PATCH 062/302] Refactor to add OctokitURLTestSession --- OctoKit.xcodeproj/project.pbxproj | 8 ++++ OctoKitTests/OctoKitURLTestSession.swift | 54 ++++++++++++++++++++++++ OctoKitTests/PublicKeyTests.swift | 21 +-------- 3 files changed, 63 insertions(+), 20 deletions(-) create mode 100644 OctoKitTests/OctoKitURLTestSession.swift diff --git a/OctoKit.xcodeproj/project.pbxproj b/OctoKit.xcodeproj/project.pbxproj index eafadbf5..487f738f 100644 --- a/OctoKit.xcodeproj/project.pbxproj +++ b/OctoKit.xcodeproj/project.pbxproj @@ -24,6 +24,9 @@ 234F4C3F1BDE0FE200A58EF7 /* RequestKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 234F4C3E1BDE0FE200A58EF7 /* RequestKit.framework */; }; 234F4C401BDE113800A58EF7 /* RequestKit.framework in Carthage embed */ = {isa = PBXBuildFile; fileRef = 234F4C3E1BDE0FE200A58EF7 /* RequestKit.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 239BE7CE1B8C47A100D2CE22 /* OctoKit.h in Headers */ = {isa = PBXBuildFile; fileRef = 239BE7CD1B8C47A100D2CE22 /* OctoKit.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 23A0521F1CA924950068BFF7 /* OctoKitURLTestSession.swift in Sources */ = {isa = PBXBuildFile; fileRef = 23A0521E1CA924950068BFF7 /* OctoKitURLTestSession.swift */; }; + 23A052201CA924950068BFF7 /* OctoKitURLTestSession.swift in Sources */ = {isa = PBXBuildFile; fileRef = 23A0521E1CA924950068BFF7 /* OctoKitURLTestSession.swift */; }; + 23A052211CA924950068BFF7 /* OctoKitURLTestSession.swift in Sources */ = {isa = PBXBuildFile; fileRef = 23A0521E1CA924950068BFF7 /* OctoKitURLTestSession.swift */; }; 23B2678A1BDDD756003887E3 /* Configuration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 23B267851BDDD756003887E3 /* Configuration.swift */; }; 23B2678B1BDDD756003887E3 /* Octokit.swift in Sources */ = {isa = PBXBuildFile; fileRef = 23B267861BDDD756003887E3 /* Octokit.swift */; }; 23B2678C1BDDD756003887E3 /* PublicKey.swift in Sources */ = {isa = PBXBuildFile; fileRef = 23B267871BDDD756003887E3 /* PublicKey.swift */; }; @@ -205,6 +208,7 @@ 239BE7C91B8C47A100D2CE22 /* OctoKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = OctoKit.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 239BE7CC1B8C47A100D2CE22 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 239BE7CD1B8C47A100D2CE22 /* OctoKit.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OctoKit.h; sourceTree = ""; }; + 23A0521E1CA924950068BFF7 /* OctoKitURLTestSession.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OctoKitURLTestSession.swift; sourceTree = ""; }; 23B267851BDDD756003887E3 /* Configuration.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Configuration.swift; sourceTree = ""; }; 23B267861BDDD756003887E3 /* Octokit.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Octokit.swift; sourceTree = ""; }; 23B267871BDDD756003887E3 /* PublicKey.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PublicKey.swift; sourceTree = ""; }; @@ -311,6 +315,7 @@ E7EE59D91BE10DA60012E3D2 /* StarsTests.swift */, 234F4BCE1BDDE3F900A58EF7 /* TestHelper.swift */, 234F4BCF1BDDE3F900A58EF7 /* UserTests.swift */, + 23A0521E1CA924950068BFF7 /* OctoKitURLTestSession.swift */, 234F4BAD1BDDE31A00A58EF7 /* Info.plist */, ); path = OctoKitTests; @@ -709,6 +714,7 @@ 234F4BD41BDDE3F900A58EF7 /* RepositoryTests.swift in Sources */, E7EE59DE1BE11C2A0012E3D2 /* FollowTests.swift in Sources */, 234F4BD51BDDE3F900A58EF7 /* TestHelper.swift in Sources */, + 23A0521F1CA924950068BFF7 /* OctoKitURLTestSession.swift in Sources */, 234F4BD01BDDE3F900A58EF7 /* ConfigurationTests.swift in Sources */, 234F4BD21BDDE3F900A58EF7 /* OctokitSwiftTests.swift in Sources */, E7EE59DA1BE10DA60012E3D2 /* StarsTests.swift in Sources */, @@ -761,6 +767,7 @@ 23CAF2C61C7AB70B005011C4 /* TestHelper.swift in Sources */, 23CAF2BE1C7AB6FE005011C4 /* OctokitSwiftTests.swift in Sources */, 23CAF2C01C7AB702005011C4 /* PublicKeyTests.swift in Sources */, + 23A052201CA924950068BFF7 /* OctoKitURLTestSession.swift in Sources */, 23CAF2CA1C7AB711005011C4 /* UserTests.swift in Sources */, 23CAF2C21C7AB705005011C4 /* RepositoryTests.swift in Sources */, 23CAF2BA1C7AB6F1005011C4 /* ConfigurationTests.swift in Sources */, @@ -795,6 +802,7 @@ 23CAF2C71C7AB70C005011C4 /* TestHelper.swift in Sources */, 23CAF2BF1C7AB6FF005011C4 /* OctokitSwiftTests.swift in Sources */, 23CAF2C11C7AB702005011C4 /* PublicKeyTests.swift in Sources */, + 23A052211CA924950068BFF7 /* OctoKitURLTestSession.swift in Sources */, 23CAF2CB1C7AB712005011C4 /* UserTests.swift in Sources */, 23CAF2C31C7AB706005011C4 /* RepositoryTests.swift in Sources */, 23CAF2BB1C7AB6F1005011C4 /* ConfigurationTests.swift in Sources */, diff --git a/OctoKitTests/OctoKitURLTestSession.swift b/OctoKitTests/OctoKitURLTestSession.swift new file mode 100644 index 00000000..6833360a --- /dev/null +++ b/OctoKitTests/OctoKitURLTestSession.swift @@ -0,0 +1,54 @@ +import RequestKit +import XCTest + +class MockURLSessionDataTask: URLSessionDataTaskProtocol { + private (set) var resumeWasCalled = false + + func resume() { + resumeWasCalled = true + } +} + +class OctoKitURLTestSession: RequestKitURLSession { + var wasCalled: Bool = false + let expectedURL: String + let expectedHTTPMethod: String + let jsonFile: String? + let statusCode: Int + + init(expectedURL: String, expectedHTTPMethod: String, jsonFile: String?, statusCode: Int) { + self.expectedURL = expectedURL + self.expectedHTTPMethod = expectedHTTPMethod + self.jsonFile = jsonFile + self.statusCode = statusCode + } + + func dataTaskWithRequest(request: NSURLRequest, completionHandler: (NSData?, NSURLResponse?, NSError?) -> Void) -> URLSessionDataTaskProtocol { + XCTAssertEqual(request.URL?.absoluteString, expectedURL) + XCTAssertEqual(request.HTTPMethod, expectedHTTPMethod) + var data: NSData? = nil + if let jsonFile = jsonFile { + data = Helper.stringFromFile(jsonFile)?.dataUsingEncoding(NSUTF8StringEncoding) + } + + let response = NSHTTPURLResponse(URL: request.URL!, statusCode: statusCode, HTTPVersion: "http/1.1", headerFields: ["Content-Type": "application/json"]) + completionHandler(data, response, nil) + wasCalled = true + return MockURLSessionDataTask() + } + + func uploadTaskWithRequest(request: NSURLRequest, fromData bodyData: NSData?, completionHandler: (NSData?, NSURLResponse?, NSError?) -> Void) -> URLSessionDataTaskProtocol { + XCTAssertEqual(request.URL?.absoluteString, expectedURL) + XCTAssertEqual(request.HTTPMethod, expectedHTTPMethod) + var data: NSData? = nil + if let jsonFile = jsonFile { + data = Helper.stringFromFile(jsonFile)?.dataUsingEncoding(NSUTF8StringEncoding) + } + + let response = NSHTTPURLResponse(URL: request.URL!, statusCode: statusCode, HTTPVersion: "http/1.1", headerFields: ["Content-Type": "application/json"]) + completionHandler(data, response, nil) + wasCalled = true + return MockURLSessionDataTask() + } +} + diff --git a/OctoKitTests/PublicKeyTests.swift b/OctoKitTests/PublicKeyTests.swift index 6467b2ae..fc663f49 100644 --- a/OctoKitTests/PublicKeyTests.swift +++ b/OctoKitTests/PublicKeyTests.swift @@ -7,7 +7,7 @@ class PublicKeyTests: XCTestCase { func testPostPublicKey() { let config = TokenConfiguration("12345") - let session = PublicKeyTestsSession() + let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/user/keys?access_token=12345", expectedHTTPMethod: "POST", jsonFile: "public_key", statusCode: 201) Octokit(config).postPublicKey(session, publicKey: "test-key", title: "test title") { response in switch response { case .Success(let publicKey): @@ -19,22 +19,3 @@ class PublicKeyTests: XCTestCase { XCTAssertTrue(session.wasCalled) } } - -class PublicKeyTestsSession: RequestKitURLSession { - var wasCalled: Bool = false - - func dataTaskWithRequest(request: NSURLRequest, completionHandler: (NSData?, NSURLResponse?, NSError?) -> Void) -> URLSessionDataTaskProtocol { - XCTFail("This should not be called") - return MockURLSessionDataTask() - } - - func uploadTaskWithRequest(request: NSURLRequest, fromData bodyData: NSData?, completionHandler: (NSData?, NSURLResponse?, NSError?) -> Void) -> URLSessionDataTaskProtocol { - XCTAssertEqual(request.URL?.absoluteString, "https://api.github.com/user/keys?access_token=12345") - XCTAssertEqual(request.HTTPMethod, "POST") - let data = Helper.stringFromFile("public_key")?.dataUsingEncoding(NSUTF8StringEncoding) - let response = NSHTTPURLResponse(URL: request.URL!, statusCode: 201, HTTPVersion: "http/1.1", headerFields: ["Content-Type": "application/json"]) - completionHandler(data, response, nil) - wasCalled = true - return MockURLSessionDataTask() - } -} From 7816c5cc61740a1c845c5c4968e952444ba4e844 Mon Sep 17 00:00:00 2001 From: Piet Brauer Date: Mon, 28 Mar 2016 17:02:27 +0800 Subject: [PATCH 063/302] Rewrite FollowTests to use OctoKitURLTestSession --- OctoKit/Follow.swift | 20 ++-- OctoKitTests/FollowTests.swift | 162 +++++++++------------------------ 2 files changed, 56 insertions(+), 126 deletions(-) diff --git a/OctoKit/Follow.swift b/OctoKit/Follow.swift index e6399d1b..cd2f8ef4 100644 --- a/OctoKit/Follow.swift +++ b/OctoKit/Follow.swift @@ -5,11 +5,12 @@ public extension Octokit { /** Fetches the followers of the authenticated user + - parameter session: RequestKitURLSession, defaults to NSURLSession.sharedSession() - parameter completion: Callback for the outcome of the fetch. */ - public func myFollowers(completion: (response: Response<[User]>) -> Void) { + public func myFollowers(session: RequestKitURLSession = NSURLSession.sharedSession(), completion: (response: Response<[User]>) -> Void) { let router = FollowRouter.ReadAuthenticatedFollowers(configuration) - router.loadJSON(expectedResultType: [[String: AnyObject]].self) { json, error in + router.loadJSON(session, expectedResultType: [[String: AnyObject]].self) { json, error in if let error = error { completion(response: Response.Failure(error)) } else { @@ -23,12 +24,13 @@ public extension Octokit { /** Fetches the followers of a user + - parameter session: RequestKitURLSession, defaults to NSURLSession.sharedSession() - parameter name: Name of the user - parameter completion: Callback for the outcome of the fetch. */ - public func followers(name: String, completion: (response: Response<[User]>) -> Void) { + public func followers(session: RequestKitURLSession = NSURLSession.sharedSession(), name: String, completion: (response: Response<[User]>) -> Void) { let router = FollowRouter.ReadFollowers(name, configuration) - router.loadJSON(expectedResultType: [[String: AnyObject]].self) { json, error in + router.loadJSON(session, expectedResultType: [[String: AnyObject]].self) { json, error in if let error = error { completion(response: Response.Failure(error)) } else { @@ -42,11 +44,12 @@ public extension Octokit { /** Fetches the users following the authenticated user + - parameter session: RequestKitURLSession, defaults to NSURLSession.sharedSession() - parameter completion: Callback for the outcome of the fetch. */ - public func myFollowing(completion: (response: Response<[User]>) -> Void) { + public func myFollowing(session: RequestKitURLSession = NSURLSession.sharedSession(), completion: (response: Response<[User]>) -> Void) { let router = FollowRouter.ReadAuthenticatedFollowing(configuration) - router.loadJSON(expectedResultType: [[String: AnyObject]].self) { json, error in + router.loadJSON(session, expectedResultType: [[String: AnyObject]].self) { json, error in if let error = error { completion(response: Response.Failure(error)) } else { @@ -60,12 +63,13 @@ public extension Octokit { /** Fetches the users following a user + - parameter session: RequestKitURLSession, defaults to NSURLSession.sharedSession() - parameter name: The name of the user - parameter completion: Callback for the outcome of the fetch. */ - public func following(name: String, completion: (response: Response<[User]>) -> Void) { + public func following(session: RequestKitURLSession = NSURLSession.sharedSession(), name: String, completion: (response: Response<[User]>) -> Void) { let router = FollowRouter.ReadFollowing(name, configuration) - router.loadJSON(expectedResultType: [[String: AnyObject]].self) { json, error in + router.loadJSON(session, expectedResultType: [[String: AnyObject]].self) { json, error in if let error = error { completion(response: Response.Failure(error)) } else { diff --git a/OctoKitTests/FollowTests.swift b/OctoKitTests/FollowTests.swift index f91b37dd..c9697d28 100644 --- a/OctoKitTests/FollowTests.swift +++ b/OctoKitTests/FollowTests.swift @@ -1,198 +1,124 @@ import XCTest import OctoKit -import Nocilla class FollowTests: XCTestCase { - override func setUp() { - super.setUp() - LSNocilla.sharedInstance().start() - } - - override func tearDown() { - super.tearDown() - LSNocilla.sharedInstance().clearStubs() - LSNocilla.sharedInstance().stop() - } - - // MARK: Actual Request tests - func testGetMyFollowers() { let config = TokenConfiguration("12345") - if let json = Helper.stringFromFile("users") { - stubRequest("GET", "https://api.github.com/user/followers?access_token=12345").andReturn(200).withHeaders(["Content-Type": "application/json"]).withBody(json) - let expectation = expectationWithDescription("user_followers") - Octokit(config).myFollowers() { response in - switch response { - case .Success(let users): - XCTAssertEqual(users.count, 1) - expectation.fulfill() - case .Failure: - XCTAssert(false, "should not get an error") - expectation.fulfill() - } - } - waitForExpectationsWithTimeout(1) { (error) in - XCTAssertNil(error, "\(error)") + let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/user/followers?access_token=12345", expectedHTTPMethod: "GET", jsonFile: "users", statusCode: 200) + Octokit(config).myFollowers(session) { response in + switch response { + case .Success(let users): + XCTAssertEqual(users.count, 1) + case .Failure: + XCTAssert(false, "should not get an error") } - } else { - XCTFail("json shouldn't be nil") } + XCTAssertTrue(session.wasCalled) } func testFailToGetMyFollowers() { let config = TokenConfiguration("12345") - stubRequest("GET", "https://api.github.com/user/followers?access_token=12345").andReturn(404) - let expectation = expectationWithDescription("failing_my_followers") - Octokit(config).myFollowers() { response in + let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/user/followers?access_token=12345", expectedHTTPMethod: "GET", jsonFile: nil, statusCode: 404) + Octokit(config).myFollowers(session) { response in switch response { case .Success: XCTAssert(false, "should not retrieve followers") - expectation.fulfill() case .Failure(let error as NSError): XCTAssertEqual(error.code, 404) XCTAssertEqual(error.domain, "com.octokit.swift") - expectation.fulfill() case .Failure: XCTAssertTrue(false) - expectation.fulfill() } } - waitForExpectationsWithTimeout(1) { error in - XCTAssertNil(error, "\(error)") - } + XCTAssertTrue(session.wasCalled) } func testGetUsersFollowers() { - if let json = Helper.stringFromFile("users") { - stubRequest("GET", "https://api.github.com/users/octocat/followers").andReturn(200).withHeaders(["Content-Type": "application/json"]).withBody(json) - let expectation = expectationWithDescription("users_followers") - Octokit().followers("octocat") { response in - switch response { - case .Success(let users): - XCTAssertEqual(users.count, 1) - expectation.fulfill() - case .Failure: - XCTAssert(false, "should not get an error") - expectation.fulfill() - } - } - waitForExpectationsWithTimeout(1) { (error) in - XCTAssertNil(error, "\(error)") + let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/users/octocat/followers", expectedHTTPMethod: "GET", jsonFile: "users", statusCode: 200) + Octokit().followers(session, name: "octocat") { response in + switch response { + case .Success(let users): + XCTAssertEqual(users.count, 1) + case .Failure: + XCTAssert(false, "should not get an error") } - } else { - XCTFail("json shouldn't be nil") } + XCTAssertTrue(session.wasCalled) } func testFailToGetUsersFollowers() { - stubRequest("GET", "https://api.github.com/users/octocat/followers").andReturn(404) - let expectation = expectationWithDescription("failing_users_followers") - Octokit().followers("octocat") { response in + let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/users/octocat/followers", expectedHTTPMethod: "GET", jsonFile: nil, statusCode: 404) + Octokit().followers(session, name: "octocat") { response in switch response { case .Success: XCTAssert(false, "should not retrieve followers") - expectation.fulfill() case .Failure(let error as NSError): XCTAssertEqual(error.code, 404) XCTAssertEqual(error.domain, "com.octokit.swift") - expectation.fulfill() case .Failure: XCTAssertTrue(false) - expectation.fulfill() } } - waitForExpectationsWithTimeout(1) { error in - XCTAssertNil(error, "\(error)") - } + XCTAssertTrue(session.wasCalled) } func testGetMyFollowing() { + let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/user/following?access_token=12345", expectedHTTPMethod: "GET", jsonFile: "users", statusCode: 200) let config = TokenConfiguration("12345") - if let json = Helper.stringFromFile("users") { - stubRequest("GET", "https://api.github.com/user/following?access_token=12345").andReturn(200).withHeaders(["Content-Type": "application/json"]).withBody(json) - let expectation = expectationWithDescription("user_following") - Octokit(config).myFollowing() { response in - switch response { - case .Success(let users): - XCTAssertEqual(users.count, 1) - expectation.fulfill() - case .Failure: - XCTAssert(false, "should not get an error") - expectation.fulfill() - } - } - waitForExpectationsWithTimeout(1) { (error) in - XCTAssertNil(error, "\(error)") + Octokit(config).myFollowing(session) { response in + switch response { + case .Success(let users): + XCTAssertEqual(users.count, 1) + case .Failure: + XCTAssert(false, "should not get an error") } - } else { - XCTFail("json shouldn't be nil") } + XCTAssertTrue(session.wasCalled) } func testFailToGetMyFollowing() { let config = TokenConfiguration("12345") - stubRequest("GET", "https://api.github.com/user/following?access_token=12345").andReturn(404) - let expectation = expectationWithDescription("failing_my_following") - Octokit(config).myFollowing() { response in + let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/user/following?access_token=12345", expectedHTTPMethod: "GET", jsonFile: nil, statusCode: 404) + Octokit(config).myFollowing(session) { response in switch response { case .Success: XCTAssert(false, "should not retrieve following") - expectation.fulfill() case .Failure(let error as NSError): XCTAssertEqual(error.code, 404) XCTAssertEqual(error.domain, "com.octokit.swift") - expectation.fulfill() case .Failure: XCTAssertTrue(false) - expectation.fulfill() } } - waitForExpectationsWithTimeout(1) { error in - XCTAssertNil(error, "\(error)") - } + XCTAssertTrue(session.wasCalled) } func testGetUsersFollowing() { - if let json = Helper.stringFromFile("users") { - stubRequest("GET", "https://api.github.com/users/octocat/following").andReturn(200).withHeaders(["Content-Type": "application/json"]).withBody(json) - let expectation = expectationWithDescription("users_following") - Octokit().following("octocat") { response in - switch response { - case .Success(let users): - XCTAssertEqual(users.count, 1) - expectation.fulfill() - case .Failure: - XCTAssert(false, "should not get an error") - expectation.fulfill() - } - } - waitForExpectationsWithTimeout(1) { (error) in - XCTAssertNil(error, "\(error)") + let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/users/octocat/following", expectedHTTPMethod: "GET", jsonFile: "users", statusCode: 200) + Octokit().following(session, name: "octocat") { response in + switch response { + case .Success(let users): + XCTAssertEqual(users.count, 1) + case .Failure: + XCTAssert(false, "should not get an error") } - } else { - XCTFail("json shouldn't be nil") } + XCTAssertTrue(session.wasCalled) } func testFailToGetUsersFollowing() { - stubRequest("GET", "https://api.github.com/users/octocat/following").andReturn(404) - let expectation = expectationWithDescription("failing_users_following") - Octokit().following("octocat") { response in + let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/users/octocat/following", expectedHTTPMethod: "GET", jsonFile: nil, statusCode: 404) + Octokit().following(session, name: "octocat") { response in switch response { case .Success: XCTAssert(false, "should not retrieve following") - expectation.fulfill() case .Failure(let error as NSError): XCTAssertEqual(error.code, 404) XCTAssertEqual(error.domain, "com.octokit.swift") - expectation.fulfill() case .Failure: XCTAssertTrue(false) - expectation.fulfill() } } - waitForExpectationsWithTimeout(1) { error in - XCTAssertNil(error, "\(error)") - } + XCTAssertTrue(session.wasCalled) } } From ce8f6d3413c3fd959e41f871811cf8f798d79541 Mon Sep 17 00:00:00 2001 From: Piet Brauer Date: Mon, 28 Mar 2016 17:13:46 +0800 Subject: [PATCH 064/302] Rewrite Configuration tests to use mocked session --- OctoKit/Configuration.swift | 4 ++-- OctoKitTests/ConfigurationTests.swift | 26 ++++++----------------- OctoKitTests/OctoKitURLTestSession.swift | 27 +++++++++++++----------- 3 files changed, 23 insertions(+), 34 deletions(-) diff --git a/OctoKit/Configuration.swift b/OctoKit/Configuration.swift index c7d6f2c6..da16d428 100644 --- a/OctoKit/Configuration.swift +++ b/OctoKit/Configuration.swift @@ -57,9 +57,9 @@ public struct OAuthConfiguration: Configuration { } } - public func handleOpenURL(url: NSURL, completion: (config: TokenConfiguration) -> Void) { + public func handleOpenURL(session: RequestKitURLSession = NSURLSession.sharedSession(), url: NSURL, completion: (config: TokenConfiguration) -> Void) { if let code = url.absoluteString.componentsSeparatedByString("=").last { - authorize(code: code) { (config) in + authorize(session, code: code) { (config) in completion(config: config) } } diff --git a/OctoKitTests/ConfigurationTests.swift b/OctoKitTests/ConfigurationTests.swift index 548da909..e31475df 100644 --- a/OctoKitTests/ConfigurationTests.swift +++ b/OctoKitTests/ConfigurationTests.swift @@ -1,20 +1,8 @@ import XCTest import Foundation import OctoKit -import Nocilla class ConfigurationTests: XCTestCase { - override func setUp() { - super.setUp() - LSNocilla.sharedInstance().start() - } - - override func tearDown() { - super.tearDown() - LSNocilla.sharedInstance().clearStubs() - LSNocilla.sharedInstance().stop() - } - func testTokenConfiguration() { let subject = TokenConfiguration("12345") XCTAssertEqual(subject.accessToken, "12345") @@ -51,15 +39,13 @@ class ConfigurationTests: XCTestCase { func testHandleOpenURL() { let config = OAuthConfiguration(token: "12345", secret: "6789", scopes: ["repo", "read:org"]) let response = "access_token=017ec60f4a182&scope=read%3Aorg%2Crepo&token_type=bearer" - stubRequest("POST", "https://github.com/login/oauth/access_token").andReturn(200).withBody(response) - let expectation = expectationWithDescription("access_token") + let session = OctoKitURLTestSession(expectedURL: "https://github.com/login/oauth/access_token", expectedHTTPMethod: "POST", response: response, statusCode: 200) let url = NSURL(string: "urlscheme://authorize?code=dhfjgh23493")! - config.handleOpenURL(url) { token in - XCTAssertEqual(token.accessToken, "017ec60f4a182") - expectation.fulfill() + var token: String? = nil + config.handleOpenURL(session, url: url) { accessToken in + token = accessToken.accessToken } - waitForExpectationsWithTimeout(10, handler: { error in - XCTAssertNil(error, "\(error)") - }) + XCTAssertEqual(token, "017ec60f4a182") + XCTAssertTrue(session.wasCalled) } } diff --git a/OctoKitTests/OctoKitURLTestSession.swift b/OctoKitTests/OctoKitURLTestSession.swift index 6833360a..a6134f28 100644 --- a/OctoKitTests/OctoKitURLTestSession.swift +++ b/OctoKitTests/OctoKitURLTestSession.swift @@ -13,24 +13,31 @@ class OctoKitURLTestSession: RequestKitURLSession { var wasCalled: Bool = false let expectedURL: String let expectedHTTPMethod: String - let jsonFile: String? + let responseString: String? let statusCode: Int + init(expectedURL: String, expectedHTTPMethod: String, response: String?, statusCode: Int) { + self.expectedURL = expectedURL + self.expectedHTTPMethod = expectedHTTPMethod + self.responseString = response + self.statusCode = statusCode + } + init(expectedURL: String, expectedHTTPMethod: String, jsonFile: String?, statusCode: Int) { self.expectedURL = expectedURL self.expectedHTTPMethod = expectedHTTPMethod - self.jsonFile = jsonFile + if let jsonFile = jsonFile { + self.responseString = Helper.stringFromFile(jsonFile) + } else { + self.responseString = nil + } self.statusCode = statusCode } func dataTaskWithRequest(request: NSURLRequest, completionHandler: (NSData?, NSURLResponse?, NSError?) -> Void) -> URLSessionDataTaskProtocol { XCTAssertEqual(request.URL?.absoluteString, expectedURL) XCTAssertEqual(request.HTTPMethod, expectedHTTPMethod) - var data: NSData? = nil - if let jsonFile = jsonFile { - data = Helper.stringFromFile(jsonFile)?.dataUsingEncoding(NSUTF8StringEncoding) - } - + let data = responseString?.dataUsingEncoding(NSUTF8StringEncoding) let response = NSHTTPURLResponse(URL: request.URL!, statusCode: statusCode, HTTPVersion: "http/1.1", headerFields: ["Content-Type": "application/json"]) completionHandler(data, response, nil) wasCalled = true @@ -40,11 +47,7 @@ class OctoKitURLTestSession: RequestKitURLSession { func uploadTaskWithRequest(request: NSURLRequest, fromData bodyData: NSData?, completionHandler: (NSData?, NSURLResponse?, NSError?) -> Void) -> URLSessionDataTaskProtocol { XCTAssertEqual(request.URL?.absoluteString, expectedURL) XCTAssertEqual(request.HTTPMethod, expectedHTTPMethod) - var data: NSData? = nil - if let jsonFile = jsonFile { - data = Helper.stringFromFile(jsonFile)?.dataUsingEncoding(NSUTF8StringEncoding) - } - + let data = responseString?.dataUsingEncoding(NSUTF8StringEncoding) let response = NSHTTPURLResponse(URL: request.URL!, statusCode: statusCode, HTTPVersion: "http/1.1", headerFields: ["Content-Type": "application/json"]) completionHandler(data, response, nil) wasCalled = true From a6783c351fb4cf256bbf9daaef3dde71556a827c Mon Sep 17 00:00:00 2001 From: Piet Brauer Date: Mon, 28 Mar 2016 17:19:21 +0800 Subject: [PATCH 065/302] Fix follow indentation --- OctoKit/Follow.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OctoKit/Follow.swift b/OctoKit/Follow.swift index cd2f8ef4..7fa75813 100644 --- a/OctoKit/Follow.swift +++ b/OctoKit/Follow.swift @@ -5,7 +5,7 @@ public extension Octokit { /** Fetches the followers of the authenticated user - - parameter session: RequestKitURLSession, defaults to NSURLSession.sharedSession() + - parameter session: RequestKitURLSession, defaults to NSURLSession.sharedSession() - parameter completion: Callback for the outcome of the fetch. */ public func myFollowers(session: RequestKitURLSession = NSURLSession.sharedSession(), completion: (response: Response<[User]>) -> Void) { From ef74202204ea6f4533473f3c9a4bddf5c80c0bb1 Mon Sep 17 00:00:00 2001 From: Piet Brauer Date: Mon, 28 Mar 2016 17:19:41 +0800 Subject: [PATCH 066/302] Rewrite Issue tests to use mocked session --- OctoKit/Issue.swift | 20 ++++++----- OctoKitTests/IssueTests.swift | 68 ++++++++++------------------------- 2 files changed, 30 insertions(+), 58 deletions(-) diff --git a/OctoKit/Issue.swift b/OctoKit/Issue.swift index e33d371c..8bfc3c0b 100644 --- a/OctoKit/Issue.swift +++ b/OctoKit/Issue.swift @@ -80,13 +80,14 @@ public extension Octokit { /** Fetches the issues of the authenticated user + - parameter session: RequestKitURLSession, defaults to NSURLSession.sharedSession() - parameter page: Current page for issue pagination. `1` by default. - parameter perPage: Number of issues per page. `100` by default. - parameter completion: Callback for the outcome of the fetch. */ - public func myIssues(page: String = "1", perPage: String = "100", completion: (response: Response<[Issue]>) -> Void) { + public func myIssues(session: RequestKitURLSession = NSURLSession.sharedSession(), page: String = "1", perPage: String = "100", completion: (response: Response<[Issue]>) -> Void) { let router = IssueRouter.ReadAuthenticatedIssues(configuration, page, perPage) - router.loadJSON(expectedResultType: [[String: AnyObject]].self) { json, error in + router.loadJSON(session, expectedResultType: [[String: AnyObject]].self) { json, error in if let error = error { completion(response: Response.Failure(error)) } else { @@ -100,14 +101,15 @@ public extension Octokit { /** Fetches an issue in a repository + - parameter session: RequestKitURLSession, defaults to NSURLSession.sharedSession() - parameter owner: The user or organization that owns the repository. - parameter repository: The name of the repository. - parameter number: The number of the issue. - parameter completion: Callback for the outcome of the fetch. */ - public func issue(owner: String, repository: String, number: Int, completion: (response: Response) -> Void) { + public func issue(session: RequestKitURLSession = NSURLSession.sharedSession(), owner: String, repository: String, number: Int, completion: (response: Response) -> Void) { let router = IssueRouter.ReadIssue(configuration, owner, repository, number) - router.loadJSON(expectedResultType: [String: AnyObject].self) { json, error in + router.loadJSON(session, expectedResultType: [String: AnyObject].self) { json, error in if let error = error { completion(response: Response.Failure(error)) } else { @@ -121,6 +123,7 @@ public extension Octokit { /** Creates an issue in a repository. + - parameter session: RequestKitURLSession, defaults to NSURLSession.sharedSession() - parameter owner: The user or organization that owns the repository. - parameter repository: The name of the repository. - parameter title: The title of the issue. @@ -128,9 +131,9 @@ public extension Octokit { - parameter assignee: The name of the user to assign the issue to. This parameter is ignored if the user lacks push access to the repository. - parameter completion: Callback for the issue that is created. */ - public func postIssue(owner: String, repository: String, title: String, body: String? = nil, assignee: String? = nil, completion: (response:Response) -> Void) { + public func postIssue(session: RequestKitURLSession = NSURLSession.sharedSession(), owner: String, repository: String, title: String, body: String? = nil, assignee: String? = nil, completion: (response:Response) -> Void) { let router = IssueRouter.PostIssue(configuration, owner, repository, title, body, assignee) - router.postJSON(expectedResultType: [String: AnyObject].self) { json, error in + router.postJSON(session, expectedResultType: [String: AnyObject].self) { json, error in if let error = error { completion(response: Response.Failure(error)) } else { @@ -144,6 +147,7 @@ public extension Octokit { /** Edits an issue in a repository. + - parameter session: RequestKitURLSession, defaults to NSURLSession.sharedSession() - parameter owner: The user or organization that owns the repository. - parameter repository: The name of the repository. - parameter number: The number of the issue. @@ -153,9 +157,9 @@ public extension Octokit { - parameter state: Whether the issue is open or closed. - parameter completion: Callback for the issue that is created. */ - public func patchIssue(owner: String, repository: String, number: Int, title: String? = nil, body: String? = nil, assignee: String? = nil, state: Openness? = nil, completion: (response:Response) -> Void) { + public func patchIssue(session: RequestKitURLSession = NSURLSession.sharedSession(), owner: String, repository: String, number: Int, title: String? = nil, body: String? = nil, assignee: String? = nil, state: Openness? = nil, completion: (response:Response) -> Void) { let router = IssueRouter.PatchIssue(configuration, owner, repository, number, title, body, assignee, state) - router.postJSON(expectedResultType: [String: AnyObject].self) { json, error in + router.postJSON(session, expectedResultType: [String: AnyObject].self) { json, error in if let error = error { completion(response: Response.Failure(error)) } else { diff --git a/OctoKitTests/IssueTests.swift b/OctoKitTests/IssueTests.swift index a7ac10f1..df4d2ac1 100644 --- a/OctoKitTests/IssueTests.swift +++ b/OctoKitTests/IssueTests.swift @@ -1,68 +1,36 @@ import XCTest import OctoKit -import Nocilla class IssueTests: XCTestCase { - override func setUp() { - super.setUp() - LSNocilla.sharedInstance().start() - } - - override func tearDown() { - super.tearDown() - LSNocilla.sharedInstance().clearStubs() - LSNocilla.sharedInstance().stop() - } - // MARK: Actual Request tests func testGetMyIssues() { let config = TokenConfiguration("12345") - if let json = Helper.stringFromFile("issues") { - stubRequest("GET", "https://api.github.com/issues?access_token=12345&page=1&per_page=100").andReturn(200).withHeaders(["Content-Type": "application/json"]).withBody(json) - let expectation = expectationWithDescription("issues") - Octokit(config).myIssues() { response in - switch response { - case .Success(let issues): - XCTAssertEqual(issues.count, 1) - expectation.fulfill() - case .Failure: - XCTAssert(false, "should not get an error") - expectation.fulfill() - } - } - waitForExpectationsWithTimeout(1) { (error) in - XCTAssertNil(error, "\(error)") + let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/issues?access_token=12345&page=1&per_page=100", expectedHTTPMethod: "GET", jsonFile: "issues", statusCode: 200) + Octokit(config).myIssues(session) { response in + switch response { + case .Success(let issues): + XCTAssertEqual(issues.count, 1) + case .Failure: + XCTAssert(false, "should not get an error") } - } else { - XCTFail("json shouldn't be nil") } + XCTAssertTrue(session.wasCalled) } - + func testGetIssue() { - let (owner, repo, number) = ("octocat", "Hello-World", 1347) - if let json = Helper.stringFromFile("issue") { - stubRequest("GET", "https://api.github.com/repos/octocat/Hello-World/issues/1347").andReturn(200) - .withHeaders(["Content-Type": "application/json"]).withBody(json) - let expectation = expectationWithDescription("issue") - Octokit().issue(owner, repository: repo, number: number) { response in - switch response { - case .Success(let issue): - XCTAssertEqual(issue.number, number) - expectation.fulfill() - case .Failure: - XCTAssert(false, "should not get an error") - expectation.fulfill() - } + let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/repos/octocat/Hello-World/issues/1347", expectedHTTPMethod: "GET", jsonFile: "issue", statusCode: 200) + Octokit().issue(session, owner: "octocat", repository: "Hello-World", number: 1347) { response in + switch response { + case .Success(let issue): + XCTAssertEqual(issue.number, 1347) + case .Failure: + XCTAssert(false, "should not get an error") } - } else { - XCTFail("json shouldn't be nil") - } - waitForExpectationsWithTimeout(1) { error in - XCTAssertNil(error, "\(error)") } + XCTAssertTrue(session.wasCalled) } - + // MARK: Model Tests func testParsingIssue() { From 474e2bfee0d37dba355352911e86f6651dc28b50 Mon Sep 17 00:00:00 2001 From: Piet Brauer Date: Mon, 28 Mar 2016 17:27:33 +0800 Subject: [PATCH 067/302] Rewrite repositories calls to use mocked sessions --- OctoKit/Repositories.swift | 10 ++- OctoKitTests/RepositoryTests.swift | 116 ++++++++--------------------- 2 files changed, 38 insertions(+), 88 deletions(-) diff --git a/OctoKit/Repositories.swift b/OctoKit/Repositories.swift index b0ce5be5..3e1d82f0 100644 --- a/OctoKit/Repositories.swift +++ b/OctoKit/Repositories.swift @@ -47,16 +47,17 @@ public extension Octokit { /** Fetches the Repositories for a user or organization + - parameter session: RequestKitURLSession, defaults to NSURLSession.sharedSession() - parameter owner: The user or organization that owns the repositories. If `nil`, fetches repositories for the authenticated user. - parameter page: Current page for repository pagination. `1` by default. - parameter perPage: Number of repositories per page. `100` by default. - parameter completion: Callback for the outcome of the fetch. */ - public func repositories(owner: String? = nil, page: String = "1", perPage: String = "100", completion: (response: Response<[Repository]>) -> Void) { + public func repositories(session: RequestKitURLSession = NSURLSession.sharedSession(), owner: String? = nil, page: String = "1", perPage: String = "100", completion: (response: Response<[Repository]>) -> Void) { let router = (owner != nil) ? RepositoryRouter.ReadRepositories(configuration, owner!, page, perPage) : RepositoryRouter.ReadAuthenticatedRepositories(configuration, page, perPage) - router.loadJSON(expectedResultType: [[String: AnyObject]].self) { json, error in + router.loadJSON(session, expectedResultType: [[String: AnyObject]].self) { json, error in if let error = error { completion(response: Response.Failure(error)) } @@ -70,13 +71,14 @@ public extension Octokit { /** Fetches a repository for a user or organization + - parameter session: RequestKitURLSession, defaults to NSURLSession.sharedSession() - parameter owner: The user or organization that owns the repositories. - parameter name: The name of the repository to fetch. - parameter completion: Callback for the outcome of the fetch. */ - public func repository(owner: String, name: String, completion: (response: Response) -> Void) { + public func repository(session: RequestKitURLSession = NSURLSession.sharedSession(), owner: String, name: String, completion: (response: Response) -> Void) { let router = RepositoryRouter.ReadRepository(configuration, owner, name) - router.loadJSON(expectedResultType: [String: AnyObject].self) { json, error in + router.loadJSON(session, expectedResultType: [String: AnyObject].self) { json, error in if let error = error { completion(response: Response.Failure(error)) } else { diff --git a/OctoKitTests/RepositoryTests.swift b/OctoKitTests/RepositoryTests.swift index 4247fe6e..5cd4e930 100644 --- a/OctoKitTests/RepositoryTests.swift +++ b/OctoKitTests/RepositoryTests.swift @@ -1,136 +1,84 @@ import XCTest import OctoKit -import Nocilla class RepositoryTests: XCTestCase { - override func setUp() { - super.setUp() - LSNocilla.sharedInstance().start() - } - - override func tearDown() { - super.tearDown() - LSNocilla.sharedInstance().clearStubs() - LSNocilla.sharedInstance().stop() - } - // MARK: Actual Request tests func testGetRepositories() { - if let json = Helper.stringFromFile("user_repos") { - stubRequest("GET", "https://api.github.com/users/octocat/repos?page=1&per_page=100").andReturn(200).withHeaders(["Content-Type": "application/json"]).withBody(json) - let expectation = expectationWithDescription("user_repos") - Octokit().repositories("octocat") { response in - switch response { - case .Success(let repositories): - XCTAssertEqual(repositories.count, 1) - expectation.fulfill() - case .Failure: - XCTAssert(false, "should not get an error") - expectation.fulfill() - } - } - waitForExpectationsWithTimeout(1) { (error) in - XCTAssertNil(error, "\(error)") + let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/users/octocat/repos?page=1&per_page=100", expectedHTTPMethod: "GET", jsonFile: "user_repos", statusCode: 200) + Octokit().repositories(session, owner: "octocat") { response in + switch response { + case .Success(let repositories): + XCTAssertEqual(repositories.count, 1) + case .Failure: + XCTAssert(false, "should not get an error") } - } else { - XCTFail("json shouldn't be nil") } + XCTAssertTrue(session.wasCalled) } func testGetAuthenticatedRepositories() { + let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/user/repos?access_token=12345&page=1&per_page=100", expectedHTTPMethod: "GET", jsonFile: "user_repos", statusCode: 200) let config = TokenConfiguration("12345") - if let json = Helper.stringFromFile("user_repos") { - stubRequest("GET", "https://api.github.com/user/repos?access_token=12345&page=1&per_page=100").andReturn(200).withHeaders(["Content-Type": "application/json"]).withBody(json) - let expectation = expectationWithDescription("user_repos") - Octokit(config).repositories() { response in - switch response { - case .Success(let repositories): - XCTAssertEqual(repositories.count, 1) - expectation.fulfill() - case .Failure: - XCTAssert(false, "should not get an error") - expectation.fulfill() - } - } - waitForExpectationsWithTimeout(1) { (error) in - XCTAssertNil(error, "\(error)") + Octokit(config).repositories(session) { response in + switch response { + case .Success(let repositories): + XCTAssertEqual(repositories.count, 1) + case .Failure: + XCTAssert(false, "should not get an error") } - } else { - XCTFail("json shouldn't be nil") } + XCTAssertTrue(session.wasCalled) } func testFailToGetRepositories() { - let config = TokenConfiguration("12345") let json = "{\"message\":\"Bad credentials\",\"documentation_url\":\"https://developer.github.com/v3\"}" - stubRequest("GET", "https://api.github.com/user/repos?access_token=12345&page=1&per_page=100").andReturn(401).withHeaders(["Content-Type": "application/json"]).withBody(json) - let expectation = expectationWithDescription("failing_repos") - Octokit(config).repositories() { response in + let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/user/repos?access_token=12345&page=1&per_page=100", expectedHTTPMethod: "GET", response: json, statusCode: 401) + let config = TokenConfiguration("12345") + Octokit(config).repositories(session) { response in switch response { case .Success: XCTAssert(false, "should not retrieve repositories") - expectation.fulfill() case .Failure(let error as NSError): XCTAssertEqual(error.code, 401) XCTAssertEqual(error.domain, "com.octokit.swift") - expectation.fulfill() case .Failure: XCTAssertTrue(false) - expectation.fulfill() } } - waitForExpectationsWithTimeout(1) { error in - XCTAssertNil(error, "\(error)") - } + XCTAssertTrue(session.wasCalled) } func testGetRepository() { let (owner, name) = ("mietzmithut", "Test") - if let json = Helper.stringFromFile("repo") { - stubRequest("GET", "https://api.github.com/repos/mietzmithut/Test").andReturn(200) - .withHeaders(["Content-Type": "application/json"]).withBody(json) - let expectation = expectationWithDescription("repo") - Octokit().repository(owner, name: name) { response in - switch response { - case .Success(let repo): - XCTAssertEqual(repo.name, name) - XCTAssertEqual(repo.owner.login, owner) - expectation.fulfill() - case .Failure: - XCTAssert(false, "should not get an error") - expectation.fulfill() - } + let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/repos/mietzmithut/Test", expectedHTTPMethod: "GET", jsonFile: "repo", statusCode: 200) + Octokit().repository(session, owner: owner, name: name) { response in + switch response { + case .Success(let repo): + XCTAssertEqual(repo.name, name) + XCTAssertEqual(repo.owner.login, owner) + case .Failure: + XCTAssert(false, "should not get an error") } - } else { - XCTFail("json shouldn't be nil") - } - waitForExpectationsWithTimeout(1) { error in - XCTAssertNil(error, "\(error)") } + XCTAssertTrue(session.wasCalled) } func testFailToGetRepository() { - stubRequest("GET", "https://api.github.com/repos/mietzmithut/Test").andReturn(404) - let expectation = expectationWithDescription("failing_repo") + let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/repos/mietzmithut/Test", expectedHTTPMethod: "GET", jsonFile: nil, statusCode: 404) let (owner, name) = ("mietzmithut", "Test") - Octokit().repository(owner, name: name) { response in + Octokit().repository(session, owner: owner, name: name) { response in switch response { case .Success: XCTAssert(false, "should not retrieve repositories") - expectation.fulfill() case .Failure(let error as NSError): XCTAssertEqual(error.code, 404) XCTAssertEqual(error.domain, "com.octokit.swift") - expectation.fulfill() case .Failure: XCTAssertTrue(false) - expectation.fulfill() } } - waitForExpectationsWithTimeout(1) { error in - XCTAssertNil(error, "\(error)") - } + XCTAssertTrue(session.wasCalled) } // MARK: Model Tests From 757f0b8b9c05be405143e35da86d1c1dc39e30cf Mon Sep 17 00:00:00 2001 From: Piet Brauer Date: Mon, 28 Mar 2016 17:33:18 +0800 Subject: [PATCH 068/302] Rewrite stars test to use mocked session --- OctoKit/Stars.swift | 10 ++-- OctoKitTests/StarsTests.swift | 87 +++++++++-------------------------- 2 files changed, 28 insertions(+), 69 deletions(-) diff --git a/OctoKit/Stars.swift b/OctoKit/Stars.swift index 65ddbaf8..37274ab4 100644 --- a/OctoKit/Stars.swift +++ b/OctoKit/Stars.swift @@ -5,12 +5,13 @@ public extension Octokit { /** Fetches all the starred repositories for a user + - parameter session: RequestKitURLSession, defaults to NSURLSession.sharedSession() - parameter name: The user who starred repositories. - parameter completion: Callback for the outcome of the fetch. */ - public func stars(name: String, completion: (response: Response<[Repository]>) -> Void) { + public func stars(session: RequestKitURLSession = NSURLSession.sharedSession(), name: String, completion: (response: Response<[Repository]>) -> Void) { let router = StarsRouter.ReadStars(name, configuration) - router.loadJSON(expectedResultType: [[String: AnyObject]].self) { json, error in + router.loadJSON(session, expectedResultType: [[String: AnyObject]].self) { json, error in if let error = error { completion(response: Response.Failure(error)) } else { @@ -24,11 +25,12 @@ public extension Octokit { /** Fetches all the starred repositories for the authenticated user + - parameter session: RequestKitURLSession, defaults to NSURLSession.sharedSession() - parameter completion: Callback for the outcome of the fetch. */ - public func myStars(completion: (response: Response<[Repository]>) -> Void) { + public func myStars(session: RequestKitURLSession = NSURLSession.sharedSession(), completion: (response: Response<[Repository]>) -> Void) { let router = StarsRouter.ReadAuthenticatedStars(configuration) - router.loadJSON(expectedResultType: [[String: AnyObject]].self) { json, error in + router.loadJSON(session, expectedResultType: [[String: AnyObject]].self) { json, error in if let error = error { completion(response: Response.Failure(error)) } else { diff --git a/OctoKitTests/StarsTests.swift b/OctoKitTests/StarsTests.swift index 5aeae96a..8b949e00 100644 --- a/OctoKitTests/StarsTests.swift +++ b/OctoKitTests/StarsTests.swift @@ -1,109 +1,66 @@ import XCTest import OctoKit -import Nocilla class StarsTests: XCTestCase { - - override func setUp() { - super.setUp() - LSNocilla.sharedInstance().start() - } - - override func tearDown() { - super.tearDown() - LSNocilla.sharedInstance().clearStubs() - LSNocilla.sharedInstance().stop() - } - // MARK: Actual Request tests func testGetStarredRepositories() { + let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/user/starred?access_token=12345", expectedHTTPMethod: "GET", jsonFile: "user_repos", statusCode: 200) let config = TokenConfiguration("12345") - if let json = Helper.stringFromFile("user_repos") { - stubRequest("GET", "https://api.github.com/user/starred?access_token=12345").andReturn(200).withHeaders(["Content-Type": "application/json"]).withBody(json) - let expectation = expectationWithDescription("user_starred") - Octokit(config).myStars() { response in - switch response { - case .Success(let repositories): - XCTAssertEqual(repositories.count, 1) - expectation.fulfill() - case .Failure: - XCTAssert(false, "should not get an error") - expectation.fulfill() - } - } - waitForExpectationsWithTimeout(1) { (error) in - XCTAssertNil(error, "\(error)") + Octokit(config).myStars(session) { response in + switch response { + case .Success(let repositories): + XCTAssertEqual(repositories.count, 1) + case .Failure: + XCTAssert(false, "should not get an error") } - } else { - XCTFail("json shouldn't be nil") } + XCTAssertTrue(session.wasCalled) } func testFailToGetStarredRepositories() { let config = TokenConfiguration("12345") - stubRequest("GET", "https://api.github.com/user/starred?access_token=12345").andReturn(404) - let expectation = expectationWithDescription("failing_starred") - Octokit(config).myStars() { response in + let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/user/starred?access_token=12345", expectedHTTPMethod: "GET", jsonFile: nil, statusCode: 404) + Octokit(config).myStars(session) { response in switch response { case .Success: XCTAssert(false, "should not retrieve repositories") - expectation.fulfill() case .Failure(let error as NSError): XCTAssertEqual(error.code, 404) XCTAssertEqual(error.domain, "com.octokit.swift") - expectation.fulfill() case .Failure: XCTAssertTrue(false) - expectation.fulfill() } } - waitForExpectationsWithTimeout(1) { error in - XCTAssertNil(error, "\(error)") - } + XCTAssertTrue(session.wasCalled) } func testGetUsersStarredRepositories() { - if let json = Helper.stringFromFile("user_repos") { - stubRequest("GET", "https://api.github.com/users/octocat/starred").andReturn(200).withHeaders(["Content-Type": "application/json"]).withBody(json) - let expectation = expectationWithDescription("users_starred") - Octokit().stars("octocat") { response in - switch response { - case .Success(let repositories): - XCTAssertEqual(repositories.count, 1) - expectation.fulfill() - case .Failure: - XCTAssert(false, "should not get an error") - expectation.fulfill() - } - } - waitForExpectationsWithTimeout(1) { (error) in - XCTAssertNil(error, "\(error)") + let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/users/octocat/starred", expectedHTTPMethod: "GET", jsonFile: "user_repos", statusCode: 200) + Octokit().stars(session, name: "octocat") { response in + switch response { + case .Success(let repositories): + XCTAssertEqual(repositories.count, 1) + case .Failure: + XCTAssert(false, "should not get an error") } - } else { - XCTFail("json shouldn't be nil") } + XCTAssertTrue(session.wasCalled) } func testFailToGetUsersStarredRepositories() { - stubRequest("GET", "https://api.github.com/users/octocat/starred").andReturn(404) - let expectation = expectationWithDescription("failing_starred") - Octokit().stars("octocat") { response in + let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/users/octocat/starred", expectedHTTPMethod: "GET", jsonFile: nil, statusCode: 404) + Octokit().stars(session, name: "octocat") { response in switch response { case .Success: XCTAssert(false, "should not retrieve repositories") - expectation.fulfill() case .Failure(let error as NSError): XCTAssertEqual(error.code, 404) XCTAssertEqual(error.domain, "com.octokit.swift") - expectation.fulfill() case .Failure: XCTAssertTrue(false) - expectation.fulfill() } } - waitForExpectationsWithTimeout(1) { error in - XCTAssertNil(error, "\(error)") - } + XCTAssertTrue(session.wasCalled) } } \ No newline at end of file From e97aab67cbdbfea075a62244e9b9c70bbef6ba6a Mon Sep 17 00:00:00 2001 From: Piet Brauer Date: Mon, 28 Mar 2016 17:38:38 +0800 Subject: [PATCH 069/302] Rewrite user tests to use mocked session --- OctoKit/User.swift | 10 +++-- OctoKitTests/UserTests.swift | 85 ++++++++++-------------------------- 2 files changed, 28 insertions(+), 67 deletions(-) diff --git a/OctoKit/User.swift b/OctoKit/User.swift index 99e66062..92ef5418 100644 --- a/OctoKit/User.swift +++ b/OctoKit/User.swift @@ -45,12 +45,13 @@ public extension Octokit { /** Fetches a user or organization + - parameter session: RequestKitURLSession, defaults to NSURLSession.sharedSession() - parameter name: The name of the user or organization. - parameter completion: Callback for the outcome of the fetch. */ - public func user(name: String, completion: (response: Response) -> Void) { + public func user(session: RequestKitURLSession = NSURLSession.sharedSession(), name: String, completion: (response: Response) -> Void) { let router = UserRouter.ReadUser(name, self.configuration) - router.loadJSON(expectedResultType: [String: AnyObject].self) { json, error in + router.loadJSON(session, expectedResultType: [String: AnyObject].self) { json, error in if let error = error { completion(response: Response.Failure(error)) } else { @@ -64,11 +65,12 @@ public extension Octokit { /** Fetches the authenticated user + - parameter session: RequestKitURLSession, defaults to NSURLSession.sharedSession() - parameter completion: Callback for the outcome of the fetch. */ - public func me(completion: (response: Response) -> Void) { + public func me(session: RequestKitURLSession = NSURLSession.sharedSession(), completion: (response: Response) -> Void) { let router = UserRouter.ReadAuthenticatedUser(self.configuration) - router.loadJSON(expectedResultType: [String: AnyObject].self) { json, error in + router.loadJSON(session, expectedResultType: [String: AnyObject].self) { json, error in if let error = error { completion(response: Response.Failure(error)) } else { diff --git a/OctoKitTests/UserTests.swift b/OctoKitTests/UserTests.swift index 5c157f19..231a9a46 100644 --- a/OctoKitTests/UserTests.swift +++ b/OctoKitTests/UserTests.swift @@ -1,109 +1,68 @@ import XCTest import OctoKit -import Nocilla class UserTests: XCTestCase { - override func setUp() { - super.setUp() - LSNocilla.sharedInstance().start() - } - - override func tearDown() { - super.tearDown() - LSNocilla.sharedInstance().clearStubs() - LSNocilla.sharedInstance().stop() - } - // MARK: Actual Request tests func testGetUser() { + let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/users/mietzmithut", expectedHTTPMethod: "GET", jsonFile: "user_mietzmithut", statusCode: 200) let username = "mietzmithut" - if let json = Helper.stringFromFile("user_mietzmithut") { - stubRequest("GET", "https://api.github.com/users/mietzmithut").andReturn(200).withHeaders(["Content-Type": "application/json"]).withBody(json) - let expectation = expectationWithDescription("\(username)") - Octokit().user(username) { response in - switch response { - case .Success(let user): - XCTAssertEqual(user.login, username) - expectation.fulfill() - case .Failure: - XCTAssert(false, "should not get an user") - expectation.fulfill() - } - } - waitForExpectationsWithTimeout(1) { (error) in - XCTAssertNil(error, "\(error)") + Octokit().user(session, name: username) { response in + switch response { + case .Success(let user): + XCTAssertEqual(user.login, username) + case .Failure: + XCTAssert(false, "should not get an user") } - } else { - XCTFail("json shouldn't be nil") } + XCTAssertTrue(session.wasCalled) } func testFailingToGetUser() { let username = "notexisting" - stubRequest("GET", "https://api.github.com/users/notexisting").andReturn(404) - let expectation = expectationWithDescription("\(username)") - Octokit().user(username) { response in + let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/users/notexisting", expectedHTTPMethod: "GET", jsonFile: nil, statusCode: 404) + Octokit().user(session, name: username) { response in switch response { case .Success: XCTAssert(false, "should not retrieve user") - expectation.fulfill() case .Failure(let error as NSError): XCTAssertEqual(error.code, 404) XCTAssertEqual(error.domain, "com.octokit.swift") - expectation.fulfill() case .Failure: XCTAssertTrue(false) - expectation.fulfill() } } - waitForExpectationsWithTimeout(1) { (error) in - XCTAssertNil(error, "\(error)") - } + XCTAssertTrue(session.wasCalled) } func testGettingAuthenticatedUser() { - if let json = Helper.stringFromFile("user_me") { - stubRequest("GET", "https://api.github.com/user?access_token=token").andReturn(200).withHeaders(["Content-Type": "application/json"]).withBody(json) - let expectation = expectationWithDescription("me") - Octokit(TokenConfiguration("token")).me() { response in - switch response { - case .Success(let user): - XCTAssertEqual(user.login, "pietbrauer") - expectation.fulfill() - case .Failure(let error): - XCTAssert(false, "should not retrieve an error \(error)") - } - } - waitForExpectationsWithTimeout(10) { (error) in - XCTAssertNil(error, "\(error)") + let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/user?access_token=token", expectedHTTPMethod: "GET", jsonFile: "user_me", statusCode: 200) + Octokit(TokenConfiguration("token")).me(session) { response in + switch response { + case .Success(let user): + XCTAssertEqual(user.login, "pietbrauer") + case .Failure(let error): + XCTAssert(false, "should not retrieve an error \(error)") } - } else { - XCTFail("json shouldn't be nil") } + XCTAssertTrue(session.wasCalled) } func testFailToGetAuthenticatedUser() { let json = "{\"message\":\"Bad credentials\",\"documentation_url\":\"https://developer.github.com/v3\"}" - stubRequest("GET", "https://api.github.com/user").andReturn(401).withHeaders(["Content-Type": "application/json"]).withBody(json) - let expectation = expectationWithDescription("failing_me") - Octokit().me() { response in + let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/user", expectedHTTPMethod: "GET", response: json, statusCode: 401) + Octokit().me(session) { response in switch response { case .Success: XCTAssert(false, "should not retrieve user") - expectation.fulfill() case .Failure(let error as NSError): XCTAssertEqual(error.code, 401) XCTAssertEqual(error.domain, "com.octokit.swift") - expectation.fulfill() case .Failure: XCTAssertTrue(false) - expectation.fulfill() } } - waitForExpectationsWithTimeout(1) { error in - XCTAssertNil(error, "\(error)") - } + XCTAssertTrue(session.wasCalled) } // MARK: Model Tests From 6f3a3f4009bd5aca95c65109d67d4bb42d9a955c Mon Sep 17 00:00:00 2001 From: Piet Brauer Date: Mon, 28 Mar 2016 17:41:11 +0800 Subject: [PATCH 070/302] Remove Nocilla --- Cartfile.private | 2 -- OctoKit.xcodeproj/project.pbxproj | 12 ------------ 2 files changed, 14 deletions(-) delete mode 100644 Cartfile.private diff --git a/Cartfile.private b/Cartfile.private deleted file mode 100644 index ab9c05b8..00000000 --- a/Cartfile.private +++ /dev/null @@ -1,2 +0,0 @@ -github "nerdishbynature/Nocilla" "all-platforms" - diff --git a/OctoKit.xcodeproj/project.pbxproj b/OctoKit.xcodeproj/project.pbxproj index 487f738f..88c4aec2 100644 --- a/OctoKit.xcodeproj/project.pbxproj +++ b/OctoKit.xcodeproj/project.pbxproj @@ -8,8 +8,6 @@ /* Begin PBXBuildFile section */ 234F4BAE1BDDE31A00A58EF7 /* OctoKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 239BE7C91B8C47A100D2CE22 /* OctoKit.framework */; }; - 234F4BC01BDDE35800A58EF7 /* Nocilla.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 23B2679C1BDDDBBE003887E3 /* Nocilla.framework */; }; - 234F4BC31BDDE37100A58EF7 /* Nocilla.framework in Carthage embed */ = {isa = PBXBuildFile; fileRef = 23B2679C1BDDDBBE003887E3 /* Nocilla.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 234F4BD01BDDE3F900A58EF7 /* ConfigurationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 234F4BC91BDDE3F900A58EF7 /* ConfigurationTests.swift */; }; 234F4BD21BDDE3F900A58EF7 /* OctokitSwiftTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 234F4BCB1BDDE3F900A58EF7 /* OctokitSwiftTests.swift */; }; 234F4BD31BDDE3F900A58EF7 /* PublicKeyTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 234F4BCC1BDDE3F900A58EF7 /* PublicKeyTests.swift */; }; @@ -80,11 +78,7 @@ 23CAF2D51C7AB9C0005011C4 /* RequestKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 23CAF2D41C7AB9C0005011C4 /* RequestKit.framework */; }; 23CAF2D91C7AB9DB005011C4 /* RequestKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 23CAF2D81C7AB9DB005011C4 /* RequestKit.framework */; }; 23CAF2DA1C7ABA67005011C4 /* RequestKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 23CAF2D61C7AB9CE005011C4 /* RequestKit.framework */; }; - 23F6433D1C7AEEB6000427B3 /* Nocilla.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 23F6433C1C7AEEB6000427B3 /* Nocilla.framework */; }; - 23F6433E1C7AEECE000427B3 /* Nocilla.framework in Carthage embed */ = {isa = PBXBuildFile; fileRef = 23F6433C1C7AEEB6000427B3 /* Nocilla.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 23F6433F1C7AEED7000427B3 /* RequestKit.framework in Carthage embed */ = {isa = PBXBuildFile; fileRef = 23CAF2D41C7AB9C0005011C4 /* RequestKit.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; - 23F643431C7AEF2F000427B3 /* Nocilla.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 23F643421C7AEF2F000427B3 /* Nocilla.framework */; }; - 23F643441C7AEF32000427B3 /* Nocilla.framework in Carthage embed */ = {isa = PBXBuildFile; fileRef = 23F643421C7AEF2F000427B3 /* Nocilla.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 23F643451C7AEF37000427B3 /* RequestKit.framework in Carthage embed */ = {isa = PBXBuildFile; fileRef = 23CAF2D61C7AB9CE005011C4 /* RequestKit.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 23F643461C7AEF63000427B3 /* public_key.json in Resources */ = {isa = PBXBuildFile; fileRef = 234F4BD81BDDE44600A58EF7 /* public_key.json */; }; 23F643471C7AEF63000427B3 /* public_key.json in Resources */ = {isa = PBXBuildFile; fileRef = 234F4BD81BDDE44600A58EF7 /* public_key.json */; }; @@ -159,7 +153,6 @@ dstSubfolderSpec = 10; files = ( 234F4C401BDE113800A58EF7 /* RequestKit.framework in Carthage embed */, - 234F4BC31BDDE37100A58EF7 /* Nocilla.framework in Carthage embed */, ); name = "Carthage embed"; runOnlyForDeploymentPostprocessing = 0; @@ -170,7 +163,6 @@ dstPath = ""; dstSubfolderSpec = 10; files = ( - 23F6433E1C7AEECE000427B3 /* Nocilla.framework in Carthage embed */, 23F6433F1C7AEED7000427B3 /* RequestKit.framework in Carthage embed */, ); name = "Carthage embed"; @@ -182,7 +174,6 @@ dstPath = ""; dstSubfolderSpec = 10; files = ( - 23F643441C7AEF32000427B3 /* Nocilla.framework in Carthage embed */, 23F643451C7AEF37000427B3 /* RequestKit.framework in Carthage embed */, ); name = "Carthage embed"; @@ -244,7 +235,6 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 234F4BC01BDDE35800A58EF7 /* Nocilla.framework in Frameworks */, 234F4BAE1BDDE31A00A58EF7 /* OctoKit.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -269,7 +259,6 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 23F6433D1C7AEEB6000427B3 /* Nocilla.framework in Frameworks */, 23CAF26C1C7AB5FC005011C4 /* OctoKit.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -286,7 +275,6 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 23F643431C7AEF2F000427B3 /* Nocilla.framework in Frameworks */, 23CAF2881C7AB60D005011C4 /* OctoKit.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; From c3a1e4c651296d5c0080276771bb6570b3cf83be Mon Sep 17 00:00:00 2001 From: Piet Brauer Date: Mon, 28 Mar 2016 17:46:14 +0800 Subject: [PATCH 071/302] Update dependencies --- Gemfile.lock | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 89cc279d..bd9bd0ec 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -58,7 +58,7 @@ GEM spaceship (>= 0.19.0, < 1.0.0) domain_name (0.5.20160310) unf (>= 0.0.5, < 1.0.0) - dotenv (2.1.0) + dotenv (2.1.1) escape (0.0.4) excon (0.45.4) faraday (0.9.2) @@ -95,7 +95,7 @@ GEM terminal-table (~> 1.4.5) xcodeproj (>= 0.20, < 2.0.0) xcpretty (>= 0.2.1) - fastlane_core (0.39.0) + fastlane_core (0.39.1) babosa colored commander (= 4.3.5) @@ -176,7 +176,7 @@ GEM mini_magick (4.0.4) mini_portile2 (2.0.0) minitest (5.8.4) - molinillo (0.4.3) + molinillo (0.4.4) multi_json (1.11.2) multi_xml (0.5.5) multipart-post (2.0.0) @@ -226,7 +226,7 @@ GEM jwt (~> 1.5) multi_json (~> 1.10) slack-notifier (1.5.1) - slather (2.0.0) + slather (2.0.1) clamp (~> 0.6) nokogiri (~> 1.6.3) xcodeproj (>= 0.28.2, < 1.1.0) @@ -235,7 +235,7 @@ GEM fastlane_core (>= 0.36.1, < 1.0.0) plist (~> 3.1.0) xcpretty (>= 0.2.1) - spaceship (0.24.0) + spaceship (0.24.1) colored credentials_manager (>= 0.9.0) faraday (~> 0.9) From 9833e205fe009ce929e84353dde087c45ee0c1b2 Mon Sep 17 00:00:00 2001 From: Piet Brauer Date: Tue, 7 Jun 2016 08:02:18 +0800 Subject: [PATCH 072/302] Adopt new params --- OctoKit/Configuration.swift | 2 +- OctoKit/Follow.swift | 2 +- OctoKit/Issue.swift | 2 +- OctoKit/PublicKey.swift | 2 +- OctoKit/Repositories.swift | 2 +- OctoKit/Stars.swift | 6 +----- OctoKit/User.swift | 2 +- 7 files changed, 7 insertions(+), 11 deletions(-) diff --git a/OctoKit/Configuration.swift b/OctoKit/Configuration.swift index da16d428..35d2e3fd 100644 --- a/OctoKit/Configuration.swift +++ b/OctoKit/Configuration.swift @@ -112,7 +112,7 @@ enum OAuthRouter: Router { } } - var params: [String: String] { + var params: [String: AnyObject] { switch self { case .Authorize(let config): let scope = (config.scopes as NSArray).componentsJoinedByString(",") diff --git a/OctoKit/Follow.swift b/OctoKit/Follow.swift index 7fa75813..2bd9d131 100644 --- a/OctoKit/Follow.swift +++ b/OctoKit/Follow.swift @@ -118,7 +118,7 @@ enum FollowRouter: Router { } } - var params: [String: String] { + var params: [String: AnyObject] { return [:] } } diff --git a/OctoKit/Issue.swift b/OctoKit/Issue.swift index 8bfc3c0b..69bd8a1b 100644 --- a/OctoKit/Issue.swift +++ b/OctoKit/Issue.swift @@ -207,7 +207,7 @@ enum IssueRouter: JSONPostRouter { } } - var params: [String: String] { + var params: [String: AnyObject] { switch self { case .ReadAuthenticatedIssues(_, let page, let perPage): return ["per_page": perPage, "page": page] diff --git a/OctoKit/PublicKey.swift b/OctoKit/PublicKey.swift index b1351adc..7fdefc3f 100644 --- a/OctoKit/PublicKey.swift +++ b/OctoKit/PublicKey.swift @@ -48,7 +48,7 @@ enum PublicKeyRouter: JSONPostRouter { } } - var params: [String: String] { + var params: [String: AnyObject] { switch self { case .PostPublicKey(let publicKey, let title, _): return ["title": title, "key": publicKey] diff --git a/OctoKit/Repositories.swift b/OctoKit/Repositories.swift index 3e1d82f0..6633d074 100644 --- a/OctoKit/Repositories.swift +++ b/OctoKit/Repositories.swift @@ -114,7 +114,7 @@ enum RepositoryRouter: Router { return .URL } - var params: [String: String] { + var params: [String: AnyObject] { switch self { case .ReadRepositories(_, _, let page, let perPage): return ["per_page": perPage, "page": page] diff --git a/OctoKit/Stars.swift b/OctoKit/Stars.swift index 37274ab4..683f71c7 100644 --- a/OctoKit/Stars.swift +++ b/OctoKit/Stars.swift @@ -70,11 +70,7 @@ enum StarsRouter: Router { } } - var params: [String: String] { + var params: [String: AnyObject] { return [:] } - - var URLRequest: NSURLRequest? { - return request() - } } diff --git a/OctoKit/User.swift b/OctoKit/User.swift index 92ef5418..89106300 100644 --- a/OctoKit/User.swift +++ b/OctoKit/User.swift @@ -113,7 +113,7 @@ enum UserRouter: Router { } } - var params: [String: String] { + var params: [String: AnyObject] { return [:] } } From 7f982e698ee7c4cc2fcc608dff17be23087a9294 Mon Sep 17 00:00:00 2001 From: Piet Brauer Date: Tue, 7 Jun 2016 09:26:29 +0800 Subject: [PATCH 073/302] Add custom error domain --- OctoKit/Configuration.swift | 14 ++++++++++---- OctoKitTests/FollowTests.swift | 8 ++++---- OctoKitTests/RepositoryTests.swift | 4 ++-- OctoKitTests/StarsTests.swift | 4 ++-- OctoKitTests/UserTests.swift | 4 ++-- 5 files changed, 20 insertions(+), 14 deletions(-) diff --git a/OctoKit/Configuration.swift b/OctoKit/Configuration.swift index 35d2e3fd..ecf53de9 100644 --- a/OctoKit/Configuration.swift +++ b/OctoKit/Configuration.swift @@ -4,9 +4,12 @@ import RequestKit let githubBaseURL = "https://api.github.com" let githubWebURL = "https://github.com" +public let OctoKitErrorDomain = "com.nerdishbynature.octokit" + public struct TokenConfiguration: Configuration { public var apiEndpoint: String public var accessToken: String? + public let errorDomain = OctoKitErrorDomain public init(_ token: String? = nil, url: String = githubBaseURL) { apiEndpoint = url @@ -21,6 +24,7 @@ public struct OAuthConfiguration: Configuration { public let secret: String public let scopes: [String] public let webEndpoint: String + public let errorDomain = OctoKitErrorDomain public init(_ url: String = githubBaseURL, webURL: String = githubWebURL, token: String, secret: String, scopes: [String]) { @@ -125,11 +129,13 @@ enum OAuthRouter: Router { var URLRequest: NSURLRequest? { switch self { case .Authorize(let config): - let URLString = config.webEndpoint.stringByAppendingURLPath(path) - return request(URLString, parameters: params) + let url = NSURL(string: path, relativeToURL: NSURL(string: config.webEndpoint)) + let components = NSURLComponents(URL: url!, resolvingAgainstBaseURL: true) + return request(components!, parameters: params) case .AccessToken(let config, _): - let URLString = config.webEndpoint.stringByAppendingURLPath(path) - return request(URLString, parameters: params) + let url = NSURL(string: path, relativeToURL: NSURL(string: config.webEndpoint)) + let components = NSURLComponents(URL: url!, resolvingAgainstBaseURL: true) + return request(components!, parameters: params) } } } diff --git a/OctoKitTests/FollowTests.swift b/OctoKitTests/FollowTests.swift index c9697d28..930b7508 100644 --- a/OctoKitTests/FollowTests.swift +++ b/OctoKitTests/FollowTests.swift @@ -25,7 +25,7 @@ class FollowTests: XCTestCase { XCTAssert(false, "should not retrieve followers") case .Failure(let error as NSError): XCTAssertEqual(error.code, 404) - XCTAssertEqual(error.domain, "com.octokit.swift") + XCTAssertEqual(error.domain, OctoKitErrorDomain) case .Failure: XCTAssertTrue(false) } @@ -54,7 +54,7 @@ class FollowTests: XCTestCase { XCTAssert(false, "should not retrieve followers") case .Failure(let error as NSError): XCTAssertEqual(error.code, 404) - XCTAssertEqual(error.domain, "com.octokit.swift") + XCTAssertEqual(error.domain, OctoKitErrorDomain) case .Failure: XCTAssertTrue(false) } @@ -85,7 +85,7 @@ class FollowTests: XCTestCase { XCTAssert(false, "should not retrieve following") case .Failure(let error as NSError): XCTAssertEqual(error.code, 404) - XCTAssertEqual(error.domain, "com.octokit.swift") + XCTAssertEqual(error.domain, OctoKitErrorDomain) case .Failure: XCTAssertTrue(false) } @@ -114,7 +114,7 @@ class FollowTests: XCTestCase { XCTAssert(false, "should not retrieve following") case .Failure(let error as NSError): XCTAssertEqual(error.code, 404) - XCTAssertEqual(error.domain, "com.octokit.swift") + XCTAssertEqual(error.domain, OctoKitErrorDomain) case .Failure: XCTAssertTrue(false) } diff --git a/OctoKitTests/RepositoryTests.swift b/OctoKitTests/RepositoryTests.swift index 5cd4e930..86d47e4f 100644 --- a/OctoKitTests/RepositoryTests.swift +++ b/OctoKitTests/RepositoryTests.swift @@ -41,7 +41,7 @@ class RepositoryTests: XCTestCase { XCTAssert(false, "should not retrieve repositories") case .Failure(let error as NSError): XCTAssertEqual(error.code, 401) - XCTAssertEqual(error.domain, "com.octokit.swift") + XCTAssertEqual(error.domain, OctoKitErrorDomain) case .Failure: XCTAssertTrue(false) } @@ -73,7 +73,7 @@ class RepositoryTests: XCTestCase { XCTAssert(false, "should not retrieve repositories") case .Failure(let error as NSError): XCTAssertEqual(error.code, 404) - XCTAssertEqual(error.domain, "com.octokit.swift") + XCTAssertEqual(error.domain, OctoKitErrorDomain) case .Failure: XCTAssertTrue(false) } diff --git a/OctoKitTests/StarsTests.swift b/OctoKitTests/StarsTests.swift index 8b949e00..6bd5ff65 100644 --- a/OctoKitTests/StarsTests.swift +++ b/OctoKitTests/StarsTests.swift @@ -27,7 +27,7 @@ class StarsTests: XCTestCase { XCTAssert(false, "should not retrieve repositories") case .Failure(let error as NSError): XCTAssertEqual(error.code, 404) - XCTAssertEqual(error.domain, "com.octokit.swift") + XCTAssertEqual(error.domain, OctoKitErrorDomain) case .Failure: XCTAssertTrue(false) } @@ -56,7 +56,7 @@ class StarsTests: XCTestCase { XCTAssert(false, "should not retrieve repositories") case .Failure(let error as NSError): XCTAssertEqual(error.code, 404) - XCTAssertEqual(error.domain, "com.octokit.swift") + XCTAssertEqual(error.domain, OctoKitErrorDomain) case .Failure: XCTAssertTrue(false) } diff --git a/OctoKitTests/UserTests.swift b/OctoKitTests/UserTests.swift index 231a9a46..91215cda 100644 --- a/OctoKitTests/UserTests.swift +++ b/OctoKitTests/UserTests.swift @@ -27,7 +27,7 @@ class UserTests: XCTestCase { XCTAssert(false, "should not retrieve user") case .Failure(let error as NSError): XCTAssertEqual(error.code, 404) - XCTAssertEqual(error.domain, "com.octokit.swift") + XCTAssertEqual(error.domain, OctoKitErrorDomain) case .Failure: XCTAssertTrue(false) } @@ -57,7 +57,7 @@ class UserTests: XCTestCase { XCTAssert(false, "should not retrieve user") case .Failure(let error as NSError): XCTAssertEqual(error.code, 401) - XCTAssertEqual(error.domain, "com.octokit.swift") + XCTAssertEqual(error.domain, OctoKitErrorDomain) case .Failure: XCTAssertTrue(false) } From 78166478ddcb6e199d28b772981782e3e33f20c2 Mon Sep 17 00:00:00 2001 From: Piet Brauer Date: Thu, 23 Jun 2016 08:44:29 +0200 Subject: [PATCH 074/302] Return URLSessionDataTaskProtocol for each call --- OctoKit/Follow.swift | 16 ++++++++-------- OctoKit/Issue.swift | 16 ++++++++-------- OctoKit/PublicKey.swift | 4 ++-- OctoKit/Repositories.swift | 8 ++++---- OctoKit/Stars.swift | 8 ++++---- OctoKit/User.swift | 8 ++++---- OctoKitTests/FollowTests.swift | 9 ++++++--- OctoKitTests/IssueTests.swift | 6 ++++-- OctoKitTests/PublicKeyTests.swift | 3 ++- OctoKitTests/RepositoryTests.swift | 15 ++++++++++----- OctoKitTests/StarsTests.swift | 12 ++++++++---- OctoKitTests/UserTests.swift | 12 ++++++++---- 12 files changed, 68 insertions(+), 49 deletions(-) diff --git a/OctoKit/Follow.swift b/OctoKit/Follow.swift index 2bd9d131..5ec7f2bd 100644 --- a/OctoKit/Follow.swift +++ b/OctoKit/Follow.swift @@ -8,9 +8,9 @@ public extension Octokit { - parameter session: RequestKitURLSession, defaults to NSURLSession.sharedSession() - parameter completion: Callback for the outcome of the fetch. */ - public func myFollowers(session: RequestKitURLSession = NSURLSession.sharedSession(), completion: (response: Response<[User]>) -> Void) { + public func myFollowers(session: RequestKitURLSession = NSURLSession.sharedSession(), completion: (response: Response<[User]>) -> Void) -> URLSessionDataTaskProtocol? { let router = FollowRouter.ReadAuthenticatedFollowers(configuration) - router.loadJSON(session, expectedResultType: [[String: AnyObject]].self) { json, error in + return router.loadJSON(session, expectedResultType: [[String: AnyObject]].self) { json, error in if let error = error { completion(response: Response.Failure(error)) } else { @@ -28,9 +28,9 @@ public extension Octokit { - parameter name: Name of the user - parameter completion: Callback for the outcome of the fetch. */ - public func followers(session: RequestKitURLSession = NSURLSession.sharedSession(), name: String, completion: (response: Response<[User]>) -> Void) { + public func followers(session: RequestKitURLSession = NSURLSession.sharedSession(), name: String, completion: (response: Response<[User]>) -> Void) -> URLSessionDataTaskProtocol? { let router = FollowRouter.ReadFollowers(name, configuration) - router.loadJSON(session, expectedResultType: [[String: AnyObject]].self) { json, error in + return router.loadJSON(session, expectedResultType: [[String: AnyObject]].self) { json, error in if let error = error { completion(response: Response.Failure(error)) } else { @@ -47,9 +47,9 @@ public extension Octokit { - parameter session: RequestKitURLSession, defaults to NSURLSession.sharedSession() - parameter completion: Callback for the outcome of the fetch. */ - public func myFollowing(session: RequestKitURLSession = NSURLSession.sharedSession(), completion: (response: Response<[User]>) -> Void) { + public func myFollowing(session: RequestKitURLSession = NSURLSession.sharedSession(), completion: (response: Response<[User]>) -> Void) -> URLSessionDataTaskProtocol? { let router = FollowRouter.ReadAuthenticatedFollowing(configuration) - router.loadJSON(session, expectedResultType: [[String: AnyObject]].self) { json, error in + return router.loadJSON(session, expectedResultType: [[String: AnyObject]].self) { json, error in if let error = error { completion(response: Response.Failure(error)) } else { @@ -67,9 +67,9 @@ public extension Octokit { - parameter name: The name of the user - parameter completion: Callback for the outcome of the fetch. */ - public func following(session: RequestKitURLSession = NSURLSession.sharedSession(), name: String, completion: (response: Response<[User]>) -> Void) { + public func following(session: RequestKitURLSession = NSURLSession.sharedSession(), name: String, completion: (response: Response<[User]>) -> Void) -> URLSessionDataTaskProtocol? { let router = FollowRouter.ReadFollowing(name, configuration) - router.loadJSON(session, expectedResultType: [[String: AnyObject]].self) { json, error in + return router.loadJSON(session, expectedResultType: [[String: AnyObject]].self) { json, error in if let error = error { completion(response: Response.Failure(error)) } else { diff --git a/OctoKit/Issue.swift b/OctoKit/Issue.swift index 69bd8a1b..14549449 100644 --- a/OctoKit/Issue.swift +++ b/OctoKit/Issue.swift @@ -85,9 +85,9 @@ public extension Octokit { - parameter perPage: Number of issues per page. `100` by default. - parameter completion: Callback for the outcome of the fetch. */ - public func myIssues(session: RequestKitURLSession = NSURLSession.sharedSession(), page: String = "1", perPage: String = "100", completion: (response: Response<[Issue]>) -> Void) { + public func myIssues(session: RequestKitURLSession = NSURLSession.sharedSession(), page: String = "1", perPage: String = "100", completion: (response: Response<[Issue]>) -> Void) -> URLSessionDataTaskProtocol? { let router = IssueRouter.ReadAuthenticatedIssues(configuration, page, perPage) - router.loadJSON(session, expectedResultType: [[String: AnyObject]].self) { json, error in + return router.loadJSON(session, expectedResultType: [[String: AnyObject]].self) { json, error in if let error = error { completion(response: Response.Failure(error)) } else { @@ -107,9 +107,9 @@ public extension Octokit { - parameter number: The number of the issue. - parameter completion: Callback for the outcome of the fetch. */ - public func issue(session: RequestKitURLSession = NSURLSession.sharedSession(), owner: String, repository: String, number: Int, completion: (response: Response) -> Void) { + public func issue(session: RequestKitURLSession = NSURLSession.sharedSession(), owner: String, repository: String, number: Int, completion: (response: Response) -> Void) -> URLSessionDataTaskProtocol? { let router = IssueRouter.ReadIssue(configuration, owner, repository, number) - router.loadJSON(session, expectedResultType: [String: AnyObject].self) { json, error in + return router.loadJSON(session, expectedResultType: [String: AnyObject].self) { json, error in if let error = error { completion(response: Response.Failure(error)) } else { @@ -131,9 +131,9 @@ public extension Octokit { - parameter assignee: The name of the user to assign the issue to. This parameter is ignored if the user lacks push access to the repository. - parameter completion: Callback for the issue that is created. */ - public func postIssue(session: RequestKitURLSession = NSURLSession.sharedSession(), owner: String, repository: String, title: String, body: String? = nil, assignee: String? = nil, completion: (response:Response) -> Void) { + public func postIssue(session: RequestKitURLSession = NSURLSession.sharedSession(), owner: String, repository: String, title: String, body: String? = nil, assignee: String? = nil, completion: (response:Response) -> Void) -> URLSessionDataTaskProtocol? { let router = IssueRouter.PostIssue(configuration, owner, repository, title, body, assignee) - router.postJSON(session, expectedResultType: [String: AnyObject].self) { json, error in + return router.postJSON(session, expectedResultType: [String: AnyObject].self) { json, error in if let error = error { completion(response: Response.Failure(error)) } else { @@ -157,9 +157,9 @@ public extension Octokit { - parameter state: Whether the issue is open or closed. - parameter completion: Callback for the issue that is created. */ - public func patchIssue(session: RequestKitURLSession = NSURLSession.sharedSession(), owner: String, repository: String, number: Int, title: String? = nil, body: String? = nil, assignee: String? = nil, state: Openness? = nil, completion: (response:Response) -> Void) { + public func patchIssue(session: RequestKitURLSession = NSURLSession.sharedSession(), owner: String, repository: String, number: Int, title: String? = nil, body: String? = nil, assignee: String? = nil, state: Openness? = nil, completion: (response:Response) -> Void) -> URLSessionDataTaskProtocol? { let router = IssueRouter.PatchIssue(configuration, owner, repository, number, title, body, assignee, state) - router.postJSON(session, expectedResultType: [String: AnyObject].self) { json, error in + return router.postJSON(session, expectedResultType: [String: AnyObject].self) { json, error in if let error = error { completion(response: Response.Failure(error)) } else { diff --git a/OctoKit/PublicKey.swift b/OctoKit/PublicKey.swift index 7fdefc3f..c6ca6bf0 100644 --- a/OctoKit/PublicKey.swift +++ b/OctoKit/PublicKey.swift @@ -4,9 +4,9 @@ import RequestKit // MARK: request public extension Octokit { - public func postPublicKey(session: RequestKitURLSession = NSURLSession.sharedSession(), publicKey: String, title: String, completion: (response:Response) -> Void) { + public func postPublicKey(session: RequestKitURLSession = NSURLSession.sharedSession(), publicKey: String, title: String, completion: (response:Response) -> Void) -> URLSessionDataTaskProtocol? { let router = PublicKeyRouter.PostPublicKey(publicKey, title, configuration) - router.postJSON(session, expectedResultType: [String: AnyObject].self) { json, error in + return router.postJSON(session, expectedResultType: [String: AnyObject].self) { json, error in if let error = error { completion(response: Response.Failure(error)) } else { diff --git a/OctoKit/Repositories.swift b/OctoKit/Repositories.swift index 6633d074..6a2e1bd7 100644 --- a/OctoKit/Repositories.swift +++ b/OctoKit/Repositories.swift @@ -53,11 +53,11 @@ public extension Octokit { - parameter perPage: Number of repositories per page. `100` by default. - parameter completion: Callback for the outcome of the fetch. */ - public func repositories(session: RequestKitURLSession = NSURLSession.sharedSession(), owner: String? = nil, page: String = "1", perPage: String = "100", completion: (response: Response<[Repository]>) -> Void) { + public func repositories(session: RequestKitURLSession = NSURLSession.sharedSession(), owner: String? = nil, page: String = "1", perPage: String = "100", completion: (response: Response<[Repository]>) -> Void) -> URLSessionDataTaskProtocol? { let router = (owner != nil) ? RepositoryRouter.ReadRepositories(configuration, owner!, page, perPage) : RepositoryRouter.ReadAuthenticatedRepositories(configuration, page, perPage) - router.loadJSON(session, expectedResultType: [[String: AnyObject]].self) { json, error in + return router.loadJSON(session, expectedResultType: [[String: AnyObject]].self) { json, error in if let error = error { completion(response: Response.Failure(error)) } @@ -76,9 +76,9 @@ public extension Octokit { - parameter name: The name of the repository to fetch. - parameter completion: Callback for the outcome of the fetch. */ - public func repository(session: RequestKitURLSession = NSURLSession.sharedSession(), owner: String, name: String, completion: (response: Response) -> Void) { + public func repository(session: RequestKitURLSession = NSURLSession.sharedSession(), owner: String, name: String, completion: (response: Response) -> Void) -> URLSessionDataTaskProtocol? { let router = RepositoryRouter.ReadRepository(configuration, owner, name) - router.loadJSON(session, expectedResultType: [String: AnyObject].self) { json, error in + return router.loadJSON(session, expectedResultType: [String: AnyObject].self) { json, error in if let error = error { completion(response: Response.Failure(error)) } else { diff --git a/OctoKit/Stars.swift b/OctoKit/Stars.swift index 683f71c7..ca24d0e3 100644 --- a/OctoKit/Stars.swift +++ b/OctoKit/Stars.swift @@ -9,9 +9,9 @@ public extension Octokit { - parameter name: The user who starred repositories. - parameter completion: Callback for the outcome of the fetch. */ - public func stars(session: RequestKitURLSession = NSURLSession.sharedSession(), name: String, completion: (response: Response<[Repository]>) -> Void) { + public func stars(session: RequestKitURLSession = NSURLSession.sharedSession(), name: String, completion: (response: Response<[Repository]>) -> Void) -> URLSessionDataTaskProtocol? { let router = StarsRouter.ReadStars(name, configuration) - router.loadJSON(session, expectedResultType: [[String: AnyObject]].self) { json, error in + return router.loadJSON(session, expectedResultType: [[String: AnyObject]].self) { json, error in if let error = error { completion(response: Response.Failure(error)) } else { @@ -28,9 +28,9 @@ public extension Octokit { - parameter session: RequestKitURLSession, defaults to NSURLSession.sharedSession() - parameter completion: Callback for the outcome of the fetch. */ - public func myStars(session: RequestKitURLSession = NSURLSession.sharedSession(), completion: (response: Response<[Repository]>) -> Void) { + public func myStars(session: RequestKitURLSession = NSURLSession.sharedSession(), completion: (response: Response<[Repository]>) -> Void) -> URLSessionDataTaskProtocol? { let router = StarsRouter.ReadAuthenticatedStars(configuration) - router.loadJSON(session, expectedResultType: [[String: AnyObject]].self) { json, error in + return router.loadJSON(session, expectedResultType: [[String: AnyObject]].self) { json, error in if let error = error { completion(response: Response.Failure(error)) } else { diff --git a/OctoKit/User.swift b/OctoKit/User.swift index 89106300..5227b1af 100644 --- a/OctoKit/User.swift +++ b/OctoKit/User.swift @@ -49,9 +49,9 @@ public extension Octokit { - parameter name: The name of the user or organization. - parameter completion: Callback for the outcome of the fetch. */ - public func user(session: RequestKitURLSession = NSURLSession.sharedSession(), name: String, completion: (response: Response) -> Void) { + public func user(session: RequestKitURLSession = NSURLSession.sharedSession(), name: String, completion: (response: Response) -> Void) -> URLSessionDataTaskProtocol? { let router = UserRouter.ReadUser(name, self.configuration) - router.loadJSON(session, expectedResultType: [String: AnyObject].self) { json, error in + return router.loadJSON(session, expectedResultType: [String: AnyObject].self) { json, error in if let error = error { completion(response: Response.Failure(error)) } else { @@ -68,9 +68,9 @@ public extension Octokit { - parameter session: RequestKitURLSession, defaults to NSURLSession.sharedSession() - parameter completion: Callback for the outcome of the fetch. */ - public func me(session: RequestKitURLSession = NSURLSession.sharedSession(), completion: (response: Response) -> Void) { + public func me(session: RequestKitURLSession = NSURLSession.sharedSession(), completion: (response: Response) -> Void) -> URLSessionDataTaskProtocol? { let router = UserRouter.ReadAuthenticatedUser(self.configuration) - router.loadJSON(session, expectedResultType: [String: AnyObject].self) { json, error in + return router.loadJSON(session, expectedResultType: [String: AnyObject].self) { json, error in if let error = error { completion(response: Response.Failure(error)) } else { diff --git a/OctoKitTests/FollowTests.swift b/OctoKitTests/FollowTests.swift index 930b7508..4b6f3a13 100644 --- a/OctoKitTests/FollowTests.swift +++ b/OctoKitTests/FollowTests.swift @@ -79,7 +79,7 @@ class FollowTests: XCTestCase { func testFailToGetMyFollowing() { let config = TokenConfiguration("12345") let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/user/following?access_token=12345", expectedHTTPMethod: "GET", jsonFile: nil, statusCode: 404) - Octokit(config).myFollowing(session) { response in + let task = Octokit(config).myFollowing(session) { response in switch response { case .Success: XCTAssert(false, "should not retrieve following") @@ -90,12 +90,13 @@ class FollowTests: XCTestCase { XCTAssertTrue(false) } } + XCTAssertNotNil(task) XCTAssertTrue(session.wasCalled) } func testGetUsersFollowing() { let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/users/octocat/following", expectedHTTPMethod: "GET", jsonFile: "users", statusCode: 200) - Octokit().following(session, name: "octocat") { response in + let task = Octokit().following(session, name: "octocat") { response in switch response { case .Success(let users): XCTAssertEqual(users.count, 1) @@ -103,12 +104,13 @@ class FollowTests: XCTestCase { XCTAssert(false, "should not get an error") } } + XCTAssertNotNil(task) XCTAssertTrue(session.wasCalled) } func testFailToGetUsersFollowing() { let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/users/octocat/following", expectedHTTPMethod: "GET", jsonFile: nil, statusCode: 404) - Octokit().following(session, name: "octocat") { response in + let task = Octokit().following(session, name: "octocat") { response in switch response { case .Success: XCTAssert(false, "should not retrieve following") @@ -119,6 +121,7 @@ class FollowTests: XCTestCase { XCTAssertTrue(false) } } + XCTAssertNotNil(task) XCTAssertTrue(session.wasCalled) } } diff --git a/OctoKitTests/IssueTests.swift b/OctoKitTests/IssueTests.swift index df4d2ac1..19f8a47e 100644 --- a/OctoKitTests/IssueTests.swift +++ b/OctoKitTests/IssueTests.swift @@ -7,7 +7,7 @@ class IssueTests: XCTestCase { func testGetMyIssues() { let config = TokenConfiguration("12345") let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/issues?access_token=12345&page=1&per_page=100", expectedHTTPMethod: "GET", jsonFile: "issues", statusCode: 200) - Octokit(config).myIssues(session) { response in + let task = Octokit(config).myIssues(session) { response in switch response { case .Success(let issues): XCTAssertEqual(issues.count, 1) @@ -15,12 +15,13 @@ class IssueTests: XCTestCase { XCTAssert(false, "should not get an error") } } + XCTAssertNotNil(task) XCTAssertTrue(session.wasCalled) } func testGetIssue() { let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/repos/octocat/Hello-World/issues/1347", expectedHTTPMethod: "GET", jsonFile: "issue", statusCode: 200) - Octokit().issue(session, owner: "octocat", repository: "Hello-World", number: 1347) { response in + let task = Octokit().issue(session, owner: "octocat", repository: "Hello-World", number: 1347) { response in switch response { case .Success(let issue): XCTAssertEqual(issue.number, 1347) @@ -28,6 +29,7 @@ class IssueTests: XCTestCase { XCTAssert(false, "should not get an error") } } + XCTAssertNotNil(task) XCTAssertTrue(session.wasCalled) } diff --git a/OctoKitTests/PublicKeyTests.swift b/OctoKitTests/PublicKeyTests.swift index fc663f49..e2fbfb84 100644 --- a/OctoKitTests/PublicKeyTests.swift +++ b/OctoKitTests/PublicKeyTests.swift @@ -8,7 +8,7 @@ class PublicKeyTests: XCTestCase { func testPostPublicKey() { let config = TokenConfiguration("12345") let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/user/keys?access_token=12345", expectedHTTPMethod: "POST", jsonFile: "public_key", statusCode: 201) - Octokit(config).postPublicKey(session, publicKey: "test-key", title: "test title") { response in + let task = Octokit(config).postPublicKey(session, publicKey: "test-key", title: "test title") { response in switch response { case .Success(let publicKey): XCTAssertEqual(publicKey, "test-key") @@ -16,6 +16,7 @@ class PublicKeyTests: XCTestCase { XCTAssert(false, "should not get an error") } } + XCTAssertNotNil(task) XCTAssertTrue(session.wasCalled) } } diff --git a/OctoKitTests/RepositoryTests.swift b/OctoKitTests/RepositoryTests.swift index 86d47e4f..f044bcb1 100644 --- a/OctoKitTests/RepositoryTests.swift +++ b/OctoKitTests/RepositoryTests.swift @@ -6,7 +6,7 @@ class RepositoryTests: XCTestCase { func testGetRepositories() { let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/users/octocat/repos?page=1&per_page=100", expectedHTTPMethod: "GET", jsonFile: "user_repos", statusCode: 200) - Octokit().repositories(session, owner: "octocat") { response in + let task = Octokit().repositories(session, owner: "octocat") { response in switch response { case .Success(let repositories): XCTAssertEqual(repositories.count, 1) @@ -14,13 +14,14 @@ class RepositoryTests: XCTestCase { XCTAssert(false, "should not get an error") } } + XCTAssertNotNil(task) XCTAssertTrue(session.wasCalled) } func testGetAuthenticatedRepositories() { let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/user/repos?access_token=12345&page=1&per_page=100", expectedHTTPMethod: "GET", jsonFile: "user_repos", statusCode: 200) let config = TokenConfiguration("12345") - Octokit(config).repositories(session) { response in + let task = Octokit(config).repositories(session) { response in switch response { case .Success(let repositories): XCTAssertEqual(repositories.count, 1) @@ -28,6 +29,7 @@ class RepositoryTests: XCTestCase { XCTAssert(false, "should not get an error") } } + XCTAssertNotNil(task) XCTAssertTrue(session.wasCalled) } @@ -35,7 +37,7 @@ class RepositoryTests: XCTestCase { let json = "{\"message\":\"Bad credentials\",\"documentation_url\":\"https://developer.github.com/v3\"}" let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/user/repos?access_token=12345&page=1&per_page=100", expectedHTTPMethod: "GET", response: json, statusCode: 401) let config = TokenConfiguration("12345") - Octokit(config).repositories(session) { response in + let task = Octokit(config).repositories(session) { response in switch response { case .Success: XCTAssert(false, "should not retrieve repositories") @@ -46,13 +48,14 @@ class RepositoryTests: XCTestCase { XCTAssertTrue(false) } } + XCTAssertNotNil(task) XCTAssertTrue(session.wasCalled) } func testGetRepository() { let (owner, name) = ("mietzmithut", "Test") let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/repos/mietzmithut/Test", expectedHTTPMethod: "GET", jsonFile: "repo", statusCode: 200) - Octokit().repository(session, owner: owner, name: name) { response in + let task = Octokit().repository(session, owner: owner, name: name) { response in switch response { case .Success(let repo): XCTAssertEqual(repo.name, name) @@ -61,13 +64,14 @@ class RepositoryTests: XCTestCase { XCTAssert(false, "should not get an error") } } + XCTAssertNotNil(task) XCTAssertTrue(session.wasCalled) } func testFailToGetRepository() { let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/repos/mietzmithut/Test", expectedHTTPMethod: "GET", jsonFile: nil, statusCode: 404) let (owner, name) = ("mietzmithut", "Test") - Octokit().repository(session, owner: owner, name: name) { response in + let task = Octokit().repository(session, owner: owner, name: name) { response in switch response { case .Success: XCTAssert(false, "should not retrieve repositories") @@ -78,6 +82,7 @@ class RepositoryTests: XCTestCase { XCTAssertTrue(false) } } + XCTAssertNotNil(task) XCTAssertTrue(session.wasCalled) } diff --git a/OctoKitTests/StarsTests.swift b/OctoKitTests/StarsTests.swift index 6bd5ff65..09604bbc 100644 --- a/OctoKitTests/StarsTests.swift +++ b/OctoKitTests/StarsTests.swift @@ -7,7 +7,7 @@ class StarsTests: XCTestCase { func testGetStarredRepositories() { let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/user/starred?access_token=12345", expectedHTTPMethod: "GET", jsonFile: "user_repos", statusCode: 200) let config = TokenConfiguration("12345") - Octokit(config).myStars(session) { response in + let task = Octokit(config).myStars(session) { response in switch response { case .Success(let repositories): XCTAssertEqual(repositories.count, 1) @@ -15,13 +15,14 @@ class StarsTests: XCTestCase { XCTAssert(false, "should not get an error") } } + XCTAssertNotNil(task) XCTAssertTrue(session.wasCalled) } func testFailToGetStarredRepositories() { let config = TokenConfiguration("12345") let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/user/starred?access_token=12345", expectedHTTPMethod: "GET", jsonFile: nil, statusCode: 404) - Octokit(config).myStars(session) { response in + let task = Octokit(config).myStars(session) { response in switch response { case .Success: XCTAssert(false, "should not retrieve repositories") @@ -32,12 +33,13 @@ class StarsTests: XCTestCase { XCTAssertTrue(false) } } + XCTAssertNotNil(task) XCTAssertTrue(session.wasCalled) } func testGetUsersStarredRepositories() { let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/users/octocat/starred", expectedHTTPMethod: "GET", jsonFile: "user_repos", statusCode: 200) - Octokit().stars(session, name: "octocat") { response in + let task = Octokit().stars(session, name: "octocat") { response in switch response { case .Success(let repositories): XCTAssertEqual(repositories.count, 1) @@ -45,12 +47,13 @@ class StarsTests: XCTestCase { XCTAssert(false, "should not get an error") } } + XCTAssertNotNil(task) XCTAssertTrue(session.wasCalled) } func testFailToGetUsersStarredRepositories() { let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/users/octocat/starred", expectedHTTPMethod: "GET", jsonFile: nil, statusCode: 404) - Octokit().stars(session, name: "octocat") { response in + let task = Octokit().stars(session, name: "octocat") { response in switch response { case .Success: XCTAssert(false, "should not retrieve repositories") @@ -61,6 +64,7 @@ class StarsTests: XCTestCase { XCTAssertTrue(false) } } + XCTAssertNotNil(task) XCTAssertTrue(session.wasCalled) } } \ No newline at end of file diff --git a/OctoKitTests/UserTests.swift b/OctoKitTests/UserTests.swift index 91215cda..3fceacb6 100644 --- a/OctoKitTests/UserTests.swift +++ b/OctoKitTests/UserTests.swift @@ -7,7 +7,7 @@ class UserTests: XCTestCase { func testGetUser() { let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/users/mietzmithut", expectedHTTPMethod: "GET", jsonFile: "user_mietzmithut", statusCode: 200) let username = "mietzmithut" - Octokit().user(session, name: username) { response in + let task = Octokit().user(session, name: username) { response in switch response { case .Success(let user): XCTAssertEqual(user.login, username) @@ -15,13 +15,14 @@ class UserTests: XCTestCase { XCTAssert(false, "should not get an user") } } + XCTAssertNotNil(task) XCTAssertTrue(session.wasCalled) } func testFailingToGetUser() { let username = "notexisting" let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/users/notexisting", expectedHTTPMethod: "GET", jsonFile: nil, statusCode: 404) - Octokit().user(session, name: username) { response in + let task = Octokit().user(session, name: username) { response in switch response { case .Success: XCTAssert(false, "should not retrieve user") @@ -32,12 +33,13 @@ class UserTests: XCTestCase { XCTAssertTrue(false) } } + XCTAssertNotNil(task) XCTAssertTrue(session.wasCalled) } func testGettingAuthenticatedUser() { let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/user?access_token=token", expectedHTTPMethod: "GET", jsonFile: "user_me", statusCode: 200) - Octokit(TokenConfiguration("token")).me(session) { response in + let task = Octokit(TokenConfiguration("token")).me(session) { response in switch response { case .Success(let user): XCTAssertEqual(user.login, "pietbrauer") @@ -45,13 +47,14 @@ class UserTests: XCTestCase { XCTAssert(false, "should not retrieve an error \(error)") } } + XCTAssertNotNil(task) XCTAssertTrue(session.wasCalled) } func testFailToGetAuthenticatedUser() { let json = "{\"message\":\"Bad credentials\",\"documentation_url\":\"https://developer.github.com/v3\"}" let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/user", expectedHTTPMethod: "GET", response: json, statusCode: 401) - Octokit().me(session) { response in + let task = Octokit().me(session) { response in switch response { case .Success: XCTAssert(false, "should not retrieve user") @@ -62,6 +65,7 @@ class UserTests: XCTestCase { XCTAssertTrue(false) } } + XCTAssertNotNil(task) XCTAssertTrue(session.wasCalled) } From 5f9817a88cc1a1d6fe1163f45beac2bf8a6207b3 Mon Sep 17 00:00:00 2001 From: Piet Brauer Date: Tue, 20 Sep 2016 09:11:52 +0200 Subject: [PATCH 075/302] Fix Carthage installation issue on Travis --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 49840e5e..d8c000a4 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ SHA=$(shell git rev-parse HEAD) BRANCH=$(shell git name-rev --name-only HEAD) install: - brew install carthage + brew outdated carthage || brew upgrade carthage || brew install carthage carthage bootstrap test: From 2f22c56cdbcff1f726907cf264a6c4ef815f2a8b Mon Sep 17 00:00:00 2001 From: Piet Brauer Date: Tue, 20 Sep 2016 09:22:56 +0200 Subject: [PATCH 076/302] Update bundle --- Gemfile.lock | 186 +++++++++++++++++++++++++++------------------------ 1 file changed, 97 insertions(+), 89 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index bd9bd0ec..d0ac2ac9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,17 +1,17 @@ GEM remote: https://rubygems.org/ specs: - activesupport (4.2.6) + activesupport (4.2.7.1) i18n (~> 0.7) json (~> 1.7, >= 1.7.7) minitest (~> 5.1) thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) - addressable (2.3.8) + addressable (2.4.0) babosa (1.0.2) - cert (1.4.0) - fastlane_core (>= 0.29.1, < 1.0.0) - spaceship (>= 0.22.0, < 1.0.0) + cert (1.4.2) + fastlane_core (>= 0.50.3, < 1.0.0) + spaceship (>= 0.32.0, < 1.0.0) claide (0.9.1) clamp (0.6.5) cocoapods (0.39.0) @@ -43,20 +43,20 @@ GEM netrc (= 0.7.8) cocoapods-try (0.5.1) colored (1.2) - commander (4.3.5) + commander (4.4.0) highline (~> 1.7.2) - credentials_manager (0.15.0) + credentials_manager (0.16.0) colored commander (>= 4.3.5) highline (>= 1.7.1) security - deliver (1.10.5) - credentials_manager (>= 0.12.0, < 1.0.0) + deliver (1.13.3) + credentials_manager (>= 0.16.0, < 1.0.0) fastimage (~> 1.6) - fastlane_core (>= 0.37.0, < 1.0.0) + fastlane_core (>= 0.50.3, < 1.0.0) plist (~> 3.1.0) - spaceship (>= 0.19.0, < 1.0.0) - domain_name (0.5.20160310) + spaceship (>= 0.31.6, < 1.0.0) + domain_name (0.5.20160826) unf (>= 0.0.5, < 1.0.0) dotenv (2.1.1) escape (0.0.4) @@ -70,51 +70,57 @@ GEM faraday (>= 0.7.4, < 0.10) fastimage (1.6.8) addressable (~> 2.3, >= 2.3.5) - fastlane (1.68.0) - addressable (~> 2.3.8) - cert (>= 1.4.0, < 2.0.0) - credentials_manager (>= 0.15.0, < 1.0.0) - deliver (>= 1.10.5, < 2.0.0) - fastlane_core (>= 0.37.0, < 1.0.0) - frameit (>= 2.5.1, < 3.0.0) - gym (>= 1.6.2, < 2.0.0) - krausefx-shenzhen (>= 0.14.7) - match (>= 0.4.0, < 1.0.0) - pem (>= 1.3.0, < 2.0.0) - pilot (>= 1.4.1, < 2.0.0) + fastlane (1.103.0) + activesupport (< 5) + addressable (~> 2.3) + bundler (~> 1.12) + cert (>= 1.4.1, < 2.0.0) + credentials_manager (>= 0.16.0, < 1.0.0) + deliver (>= 1.13.3, < 2.0.0) + fastlane_core (>= 0.52.0, < 1.0.0) + frameit (>= 2.7.0, < 3.0.0) + gym (>= 1.7.0, < 2.0.0) + krausefx-shenzhen (>= 0.14.10) + match (>= 0.6.3, < 1.0.0) + multipart-post (~> 2.0.0) + pem (>= 1.3.2, < 2.0.0) + pilot (>= 1.10.0, < 2.0.0) plist (~> 3.1.0) - produce (>= 1.1.1, < 2.0.0) - scan (>= 0.5.2, < 1.0.0) - screengrab (>= 0.3.1, < 1.0.0) - sigh (>= 1.6.0, < 2.0.0) + produce (>= 1.2.0, < 2.0.0) + scan (>= 0.11.3, < 2.0.0) + screengrab (>= 0.5.0, < 1.0.0) + sigh (>= 1.10.2, < 2.0.0) slack-notifier (~> 1.3) - snapshot (>= 1.12.0, < 2.0.0) - spaceship (>= 0.24.0, < 1.0.0) - supply (>= 0.4.0, < 1.0.0) + snapshot (>= 1.14.0, < 2.0.0) + spaceship (>= 0.32.1, < 1.0.0) + supply (>= 0.7.0, < 1.0.0) terminal-notifier (~> 1.6.2) terminal-table (~> 1.4.5) + word_wrap (~> 1.0.0) + xcode-install (~> 2.0.0) xcodeproj (>= 0.20, < 2.0.0) xcpretty (>= 0.2.1) - fastlane_core (0.39.1) + fastlane_core (0.52.0) babosa colored - commander (= 4.3.5) - credentials_manager (>= 0.11.0, < 1.0.0) + commander (>= 4.4.0, <= 5.0.0) + credentials_manager (>= 0.16.0, < 1.0.0) excon (~> 0.45.0) + gh_inspector (>= 1.0.1, < 2.0.0) highline (>= 1.7.2) json multi_json plist (~> 3.1) rubyzip (~> 1.1.6) - sentry-raven (~> 0.15) terminal-table (~> 1.4.5) - frameit (2.5.1) + frameit (2.7.0) deliver (> 0.3) fastimage (~> 1.6.3) fastlane_core (>= 0.36.1, < 1.0.0) - mini_magick (~> 4.0.2) + mini_magick (~> 4.5.1) fuzzy_match (2.0.4) - google-api-client (0.9.4) + gh_inspector (1.0.2) + google-api-client (0.9.14) addressable (~> 2.3) googleauth (~> 0.5) httpclient (~> 2.7) @@ -123,7 +129,6 @@ GEM mime-types (>= 1.6) representable (~> 2.3.0) retriable (~> 2.0) - thor (~> 0.19) googleauth (0.5.1) faraday (~> 0.9) jwt (~> 1.4) @@ -132,8 +137,8 @@ GEM multi_json (~> 1.11) os (~> 0.9) signet (~> 0.7) - gym (1.6.2) - fastlane_core (>= 0.36.1, < 1.0.0) + gym (1.9.0) + fastlane_core (>= 0.51.0, < 1.0.0) plist rubyzip (>= 1.1.7) terminal-table @@ -141,13 +146,13 @@ GEM highline (1.7.8) http-cookie (1.0.2) domain_name (~> 0.5) - httpclient (2.7.1) + httpclient (2.8.2.4) hurley (0.2) i18n (0.7.0) json (1.8.3) - jwt (1.5.4) - krausefx-shenzhen (0.14.7) - commander (~> 4.3) + jwt (1.5.6) + krausefx-shenzhen (0.14.10) + commander (>= 4.3, < 5.0) dotenv (>= 0.7) faraday (~> 0.9) faraday_middleware (~> 0.9) @@ -162,95 +167,94 @@ GEM logging (2.1.0) little-plugger (~> 1.1) multi_json (~> 1.10) - match (0.4.0) - cert (>= 1.2.8, < 2.0.0) - credentials_manager (>= 0.13.0, < 1.0.0) - fastlane_core (>= 0.39.0, < 1.0.0) + match (0.6.4) + cert (>= 1.4.1, < 2.0.0) + credentials_manager (>= 0.16.0, < 1.0.0) + fastlane_core (>= 0.50.3, < 1.0.0) security - sigh (>= 1.2.2, < 2.0.0) - spaceship (>= 0.24.0, < 1.0.0) - memoist (0.14.0) - mime-types (3.0) + sigh (>= 1.10.2, < 2.0.0) + spaceship (>= 0.31.10, < 1.0.0) + memoist (0.15.0) + mime-types (3.1) mime-types-data (~> 3.2015) - mime-types-data (3.2016.0221) - mini_magick (4.0.4) - mini_portile2 (2.0.0) - minitest (5.8.4) + mime-types-data (3.2016.0521) + mini_magick (4.5.1) + mini_portile2 (2.1.0) + minitest (5.9.0) molinillo (0.4.4) - multi_json (1.11.2) + multi_json (1.12.1) multi_xml (0.5.5) multipart-post (2.0.0) nap (1.1.0) net-sftp (2.1.2) net-ssh (>= 2.6.5) - net-ssh (3.1.1) + net-ssh (3.2.0) netrc (0.7.8) - nokogiri (1.6.7.2) - mini_portile2 (~> 2.0.0.rc2) + nokogiri (1.6.8) + mini_portile2 (~> 2.1.0) + pkg-config (~> 1.1.7) os (0.9.6) - pem (1.3.0) - fastlane_core (>= 0.36.1, < 1.0.0) - spaceship (>= 0.22.0, < 1.0.0) - pilot (1.4.1) + pem (1.3.2) + fastlane_core (>= 0.43.1, < 1.0.0) + spaceship (>= 0.26.2, < 1.0.0) + pilot (1.10.0) credentials_manager (>= 0.3.0) - fastlane_core (>= 0.36.5, < 1.0.0) - spaceship (>= 0.20.0, < 1.0.0) + fastlane_core (>= 0.46.2, < 1.0.0) + spaceship (>= 0.29.0, < 1.0.0) terminal-table (~> 1.4.5) + pkg-config (1.1.7) plist (3.1.0) - produce (1.1.1) + produce (1.2.0) fastlane_core (>= 0.30.0, < 1.0.0) - spaceship (>= 0.16.0) + spaceship (>= 0.31.1, < 1.0.0) representable (2.3.0) uber (~> 0.0.7) retriable (2.1.0) - rouge (1.10.1) + rouge (1.11.1) rubyzip (1.1.7) - scan (0.5.2) - fastlane_core (>= 0.36.1, < 1.0.0) + scan (0.12.1) + fastlane_core (>= 0.51.0, < 1.0.0) slack-notifier (~> 1.3) terminal-table xcpretty (>= 0.2.1) xcpretty-travis-formatter (>= 0.0.3) - screengrab (0.3.1) - fastlane_core (>= 0.38.0, < 1.0.0) + screengrab (0.5.2) + fastlane_core (>= 0.50.3, < 1.0.0) security (0.1.3) - sentry-raven (0.15.6) - faraday (>= 0.7.6) - sigh (1.6.0) - fastlane_core (>= 0.36.1, < 1.0.0) + sigh (1.10.4) + fastlane_core (>= 0.52.0, < 1.0.0) plist (~> 3.1) - spaceship (>= 0.22.0, < 1.0.0) - signet (0.7.2) + spaceship (>= 0.32.4, < 1.0.0) + signet (0.7.3) addressable (~> 2.3) faraday (~> 0.9) jwt (~> 1.5) multi_json (~> 1.10) slack-notifier (1.5.1) - slather (2.0.1) + slather (2.2.0) clamp (~> 0.6) nokogiri (~> 1.6.3) xcodeproj (>= 0.28.2, < 1.1.0) - snapshot (1.12.1) + snapshot (1.14.0) fastimage (~> 1.6.3) - fastlane_core (>= 0.36.1, < 1.0.0) + fastlane_core (>= 0.50.3, < 1.0.0) plist (~> 3.1.0) xcpretty (>= 0.2.1) - spaceship (0.24.1) + spaceship (0.32.4) colored - credentials_manager (>= 0.9.0) + credentials_manager (>= 0.16.0) faraday (~> 0.9) faraday-cookie_jar (~> 0.0.6) faraday_middleware (~> 0.9) fastimage (~> 1.6) multi_xml (~> 0.5) plist (~> 3.1) - supply (0.5.2) + supply (0.7.1) credentials_manager (>= 0.15.0) - fastlane_core (>= 0.35.0) + fastlane_core (>= 0.43.4) google-api-client (~> 0.9.1) terminal-notifier (1.6.3) terminal-table (1.4.5) - thor (0.19.1) thread_safe (0.3.5) tzinfo (1.2.2) thread_safe (~> 0.1) @@ -258,6 +262,10 @@ GEM unf (0.1.4) unf_ext unf_ext (0.0.7.2) + word_wrap (1.0.0) + xcode-install (2.0.6) + claide (>= 0.9.1, < 1.1.0) + spaceship (>= 0.25.1, < 1.0.0) xcodeproj (0.28.2) activesupport (>= 3) claide (~> 0.9.1) @@ -276,4 +284,4 @@ DEPENDENCIES slather (~> 2.0) BUNDLED WITH - 1.11.2 + 1.13.1 From b3615db50ff4c57ba7014662dde391e0a079ca68 Mon Sep 17 00:00:00 2001 From: Piet Brauer Date: Thu, 16 Jun 2016 17:51:36 -0700 Subject: [PATCH 077/302] Update to Swift 2.3 --- Cartfile | 2 +- Cartfile.resolved | 2 +- OctoKit.xcodeproj/project.pbxproj | 19 ++++++++++++++++++- .../xcschemes/OctoKit Mac.xcscheme | 2 +- .../xcschemes/OctoKit tvOS.xcscheme | 2 +- .../xcschemes/OctoKit watchOS.xcscheme | 2 +- .../xcshareddata/xcschemes/OctoKit.xcscheme | 2 +- OctoKit/Configuration.swift | 2 +- 8 files changed, 25 insertions(+), 8 deletions(-) diff --git a/Cartfile b/Cartfile index d7f1ac68..1245cdd6 100644 --- a/Cartfile +++ b/Cartfile @@ -1 +1 @@ -github "nerdishbynature/RequestKit" ~> 1.0 +github "nerdishbynature/RequestKit" "swift-2.3" diff --git a/Cartfile.resolved b/Cartfile.resolved index fd2994fb..1925d958 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1 +1 @@ -github "nerdishbynature/RequestKit" "1.0.0" +github "nerdishbynature/RequestKit" "e484086ddf3744b31d77101dbb4b8ab760c5d6df" diff --git a/OctoKit.xcodeproj/project.pbxproj b/OctoKit.xcodeproj/project.pbxproj index 88c4aec2..e503df12 100644 --- a/OctoKit.xcodeproj/project.pbxproj +++ b/OctoKit.xcodeproj/project.pbxproj @@ -565,14 +565,18 @@ attributes = { LastSwiftMigration = 0700; LastSwiftUpdateCheck = 0720; - LastUpgradeCheck = 0700; + LastUpgradeCheck = 0800; ORGANIZATIONNAME = "nerdish by nature"; TargetAttributes = { 234F4BA81BDDE31A00A58EF7 = { CreatedOnToolsVersion = 7.1; + LastSwiftMigration = 0800; }; 239BE7C81B8C47A100D2CE22 = { CreatedOnToolsVersion = 6.4; + DevelopmentTeam = 3NPZ2HXWU8; + DevelopmentTeamName = "Piet Brauer"; + LastSwiftMigration = 0800; }; 23CAF2611C7AB5FB005011C4 = { CreatedOnToolsVersion = 7.2.1; @@ -850,6 +854,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.nerdishbynature.OctoKitTests; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 2.3; }; name = Debug; }; @@ -868,6 +873,8 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.nerdishbynature.OctoKitTests; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + SWIFT_VERSION = 2.3; }; name = Release; }; @@ -921,6 +928,7 @@ IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; SKIP_INSTALL = YES; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -971,6 +979,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; SDKROOT = appletvos; SKIP_INSTALL = YES; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; TARGETED_DEVICE_FAMILY = 3; TVOS_DEPLOYMENT_TARGET = 9.0; VERSIONING_SYSTEM = "apple-generic"; @@ -1011,6 +1020,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "com.nerdishbynature.OctoKit-tvOSTests"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = appletvos; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; TVOS_DEPLOYMENT_TARGET = 9.1; }; name = Release; @@ -1065,6 +1075,7 @@ MACOSX_DEPLOYMENT_TARGET = 10.10; SDKROOT = macosx; SKIP_INSTALL = YES; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; }; @@ -1108,6 +1119,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "com.nerdishbynature.OctoKit-MacTests"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = macosx; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; }; name = Release; }; @@ -1157,6 +1169,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; SDKROOT = watchos; SKIP_INSTALL = YES; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; TARGETED_DEVICE_FAMILY = 4; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -1187,6 +1200,7 @@ ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; GCC_OPTIMIZATION_LEVEL = 0; GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", @@ -1207,6 +1221,7 @@ PRODUCT_NAME = OctoKit; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 2.3; }; name = Debug; }; @@ -1232,6 +1247,7 @@ ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; GCC_WARN_UNDECLARED_SELECTOR = YES; @@ -1244,6 +1260,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.nerdishbynature.OctoKit; PRODUCT_NAME = OctoKit; SDKROOT = iphoneos; + SWIFT_VERSION = 2.3; VALIDATE_PRODUCT = YES; }; name = Release; diff --git a/OctoKit.xcodeproj/xcshareddata/xcschemes/OctoKit Mac.xcscheme b/OctoKit.xcodeproj/xcshareddata/xcschemes/OctoKit Mac.xcscheme index 84724b78..3e6f1e88 100644 --- a/OctoKit.xcodeproj/xcshareddata/xcschemes/OctoKit Mac.xcscheme +++ b/OctoKit.xcodeproj/xcshareddata/xcschemes/OctoKit Mac.xcscheme @@ -1,6 +1,6 @@ Void) { - if let code = url.absoluteString.componentsSeparatedByString("=").last { + if let code = url.absoluteString?.componentsSeparatedByString("=").last { authorize(session, code: code) { (config) in completion(config: config) } From c73235b955486ea064c699815a2dfb94d9fa017c Mon Sep 17 00:00:00 2001 From: Piet Brauer Date: Wed, 22 Jun 2016 21:44:17 +0200 Subject: [PATCH 078/302] Build on Xcode 8 --- .travis.yml | 10 +++++----- fastlane/.env.default | 8 ++++---- fastlane/.env.ios93 | 2 +- fastlane/.env.osx | 2 +- fastlane/.env.tvos92 | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.travis.yml b/.travis.yml index 86f463d2..7f041133 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ language: objective-c -osx_image: xcode7.3 +osx_image: xcode8 sudo: false env: global: @@ -8,13 +8,13 @@ env: - FASTLANE_LANE=ci_commit matrix: include: - - osx_image: xcode7.3 + - osx_image: xcode8 env: FASTLANE_LANE=code_coverage FASTLANE_ENV=default - - osx_image: xcode7.3 + - osx_image: xcode8 env: FASTLANE_ENV=ios93 - - osx_image: xcode7.3 + - osx_image: xcode8 env: FASTLANE_ENV=tvos92 - - osx_image: xcode7.3 + - osx_image: xcode8 env: FASTLANE_ENV=osx before_install: - make install diff --git a/fastlane/.env.default b/fastlane/.env.default index 4ddc8573..ea6fe911 100644 --- a/fastlane/.env.default +++ b/fastlane/.env.default @@ -1,11 +1,11 @@ -AF_IOS_SDK=iphonesimulator9.3 -AF_MAC_SDK=macosx10.11 -AF_TVOS_SDK=appletvsimulator9.2 +AF_IOS_SDK=iphonesimulator10.0 +AF_MAC_SDK=macosx10.12 +AF_TVOS_SDK=appletvsimulator10.0 AF_CONFIGURATION=Release SCAN_SCHEME=$AF_IOS_FRAMEWORK_SCHEME -SCAN_DESTINATION="OS=9.3,name=iPhone 6s" +SCAN_DESTINATION="OS=10.0,name=iPhone 6s" SCAN_SDK=$AF_IOS_SDK SCAN_OUTPUT_DIRECTORY=fastlane/test-output DEPLOY_PODSPEC=OctoKit.swift.podspec diff --git a/fastlane/.env.ios93 b/fastlane/.env.ios93 index de22ac58..61555b8d 100644 --- a/fastlane/.env.ios93 +++ b/fastlane/.env.ios93 @@ -1,2 +1,2 @@ -SCAN_DESTINATION="OS=9.3,name=iPhone 6s" +SCAN_DESTINATION="OS=10.0,name=iPhone 6s" EXAMPLE_DESTINATION=$SCAN_DESTINATION diff --git a/fastlane/.env.osx b/fastlane/.env.osx index d56e363c..de1d9324 100644 --- a/fastlane/.env.osx +++ b/fastlane/.env.osx @@ -3,4 +3,4 @@ SCAN_DESTINATION="arch=x86_64" SCAN_SDK=$AF_OSX_SDK EXAMPLE_SCHEME=$AF_OSX_EXAMPLE_SCHEME -EXAMPLE_DESTINATION=$SCAN_DESTINATION \ No newline at end of file +EXAMPLE_DESTINATION=$SCAN_DESTINATION diff --git a/fastlane/.env.tvos92 b/fastlane/.env.tvos92 index 7220bc3a..128f8be5 100644 --- a/fastlane/.env.tvos92 +++ b/fastlane/.env.tvos92 @@ -1,5 +1,5 @@ SCAN_SCHEME=$AF_TVOS_FRAMEWORK_SCHEME -SCAN_DESTINATION="OS=9.2,name=Apple TV 1080p" +SCAN_DESTINATION="OS=10.0,name=Apple TV 1080p" SCAN_SDK=$AF_TVOS_SDK EXAMPLE_SCHEME=$AF_TVOS_EXAMPLE_SCHEME From d4c35d8f1d66ce05b93ccdf0c66d34986117029b Mon Sep 17 00:00:00 2001 From: Piet Brauer Date: Tue, 20 Sep 2016 10:43:17 +0200 Subject: [PATCH 079/302] Bump RequestKit version --- OctoKit.swift.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OctoKit.swift.podspec b/OctoKit.swift.podspec index a79d78b6..d2e66a16 100644 --- a/OctoKit.swift.podspec +++ b/OctoKit.swift.podspec @@ -12,7 +12,7 @@ Pod::Spec.new do |s| s.source = { :git => "https://github.com/nerdishbynature/octokit.swift.git", :tag => s.version.to_s } s.social_media_url = "https://twitter.com/pietbrauer" s.module_name = "Octokit" - s.dependency "NBNRequestKit", "~> 0.3.0" + s.dependency "NBNRequestKit", "~> 1.0.0" s.requires_arc = true s.source_files = "OctoKit/*.swift" s.ios.deployment_target = '8.0' From 7e17485a8da6fbbf267b7a53892543ebfb6e601c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguy=E1=BB=85n?= Date: Thu, 11 Aug 2016 21:48:13 -0700 Subject: [PATCH 080/302] Swift 2.2 compatibility Conditionally compile for both Swift 2.2 and Swift 2.3. --- OctoKit/Configuration.swift | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/OctoKit/Configuration.swift b/OctoKit/Configuration.swift index cdc0e24c..c30f809e 100644 --- a/OctoKit/Configuration.swift +++ b/OctoKit/Configuration.swift @@ -62,7 +62,13 @@ public struct OAuthConfiguration: Configuration { } public func handleOpenURL(session: RequestKitURLSession = NSURLSession.sharedSession(), url: NSURL, completion: (config: TokenConfiguration) -> Void) { - if let code = url.absoluteString?.componentsSeparatedByString("=").last { + let urlString: String? + #if swift(>=2.3) + urlString = url.absoluteString + #else + urlString = url.absoluteString + #endif + if let code = urlString?.componentsSeparatedByString("=").last { authorize(session, code: code) { (config) in completion(config: config) } From 0054ea2c2f2ba187269f37a7fb7147286d3a8bf4 Mon Sep 17 00:00:00 2001 From: Piet Brauer Date: Tue, 20 Sep 2016 11:52:44 +0200 Subject: [PATCH 081/302] Update RequestKit dependency --- Cartfile | 2 +- Cartfile.resolved | 2 +- OctoKit.swift.podspec | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cartfile b/Cartfile index 1245cdd6..172426cb 100644 --- a/Cartfile +++ b/Cartfile @@ -1 +1 @@ -github "nerdishbynature/RequestKit" "swift-2.3" +github "nerdishbynature/RequestKit" ~>1.1 diff --git a/Cartfile.resolved b/Cartfile.resolved index 1925d958..92cd4848 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1 +1 @@ -github "nerdishbynature/RequestKit" "e484086ddf3744b31d77101dbb4b8ab760c5d6df" +github "nerdishbynature/RequestKit" "1.1.0" diff --git a/OctoKit.swift.podspec b/OctoKit.swift.podspec index d2e66a16..4414fd64 100644 --- a/OctoKit.swift.podspec +++ b/OctoKit.swift.podspec @@ -12,7 +12,7 @@ Pod::Spec.new do |s| s.source = { :git => "https://github.com/nerdishbynature/octokit.swift.git", :tag => s.version.to_s } s.social_media_url = "https://twitter.com/pietbrauer" s.module_name = "Octokit" - s.dependency "NBNRequestKit", "~> 1.0.0" + s.dependency "NBNRequestKit", "~> 1.1.0" s.requires_arc = true s.source_files = "OctoKit/*.swift" s.ios.deployment_target = '8.0' From 83f7e86513887022ed3501382047d8f9893f2dcd Mon Sep 17 00:00:00 2001 From: Piet Brauer Date: Tue, 20 Sep 2016 11:52:51 +0200 Subject: [PATCH 082/302] Bump version --- OctoKit.swift.podspec | 2 +- OctoKit/Info.plist | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/OctoKit.swift.podspec b/OctoKit.swift.podspec index 4414fd64..ef7deb53 100644 --- a/OctoKit.swift.podspec +++ b/OctoKit.swift.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "OctoKit.swift" - s.version = "0.6.1" + s.version = "0.6.2" s.summary = "A Swift API Client for GitHub and GitHub Enterprise" s.description = <<-DESC You are looking at the A Swift API Client for GitHub and GitHub Enterprise. diff --git a/OctoKit/Info.plist b/OctoKit/Info.plist index 5b6037da..6f21e11d 100644 --- a/OctoKit/Info.plist +++ b/OctoKit/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 0.6.1 + 0.6.2 CFBundleSignature ???? CFBundleVersion From 5d430e5f0950c1e71cb8a4521d7ae7eccd68e018 Mon Sep 17 00:00:00 2001 From: Piet Brauer Date: Thu, 23 Jun 2016 08:33:17 +0200 Subject: [PATCH 083/302] Migrate to Swift 3.0 --- Cartfile | 2 +- Cartfile.resolved | 2 +- OctoKit.xcodeproj/project.pbxproj | 4 +- OctoKit/Configuration.swift | 73 ++++++++-------- OctoKit/Follow.swift | 58 ++++++------- OctoKit/Issue.swift | 102 +++++++++++------------ OctoKit/Label.swift | 4 +- OctoKit/Milestone.swift | 18 ++-- OctoKit/PublicKey.swift | 22 ++--- OctoKit/Repositories.swift | 46 +++++----- OctoKit/Stars.swift | 30 +++---- OctoKit/Time.swift | 12 +-- OctoKit/User.swift | 30 +++---- OctoKitTests/ConfigurationTests.swift | 2 +- OctoKitTests/FollowTests.swift | 55 ++++++------ OctoKitTests/IssueTests.swift | 10 +-- OctoKitTests/OctoKitURLTestSession.swift | 20 ++--- OctoKitTests/PublicKeyTests.swift | 4 +- OctoKitTests/RepositoryTests.swift | 24 +++--- OctoKitTests/StarsTests.swift | 22 ++--- OctoKitTests/TestHelper.swift | 16 ++-- OctoKitTests/UserTests.swift | 20 ++--- 22 files changed, 288 insertions(+), 288 deletions(-) diff --git a/Cartfile b/Cartfile index 172426cb..9cbb48a8 100644 --- a/Cartfile +++ b/Cartfile @@ -1 +1 @@ -github "nerdishbynature/RequestKit" ~>1.1 +github "nerdishbynature/RequestKit" "swift-3.0" diff --git a/Cartfile.resolved b/Cartfile.resolved index 92cd4848..2a50ace7 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1 +1 @@ -github "nerdishbynature/RequestKit" "1.1.0" +github "nerdishbynature/RequestKit" "0e745cee26410c6ea89cc3534b77dc1027648ec3" diff --git a/OctoKit.xcodeproj/project.pbxproj b/OctoKit.xcodeproj/project.pbxproj index e503df12..bd4592cc 100644 --- a/OctoKit.xcodeproj/project.pbxproj +++ b/OctoKit.xcodeproj/project.pbxproj @@ -854,7 +854,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.nerdishbynature.OctoKitTests; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 2.3; + SWIFT_VERSION = 3.0; }; name = Debug; }; @@ -874,7 +874,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.nerdishbynature.OctoKitTests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 2.3; + SWIFT_VERSION = 3.0; }; name = Release; }; diff --git a/OctoKit/Configuration.swift b/OctoKit/Configuration.swift index c30f809e..e8aa2e5d 100644 --- a/OctoKit/Configuration.swift +++ b/OctoKit/Configuration.swift @@ -35,19 +35,19 @@ public struct OAuthConfiguration: Configuration { self.scopes = scopes } - public func authenticate() -> NSURL? { - return OAuthRouter.Authorize(self).URLRequest?.URL + public func authenticate() -> URL? { + return OAuthRouter.authorize(self).URLRequest?.url } - public func authorize(session: RequestKitURLSession = NSURLSession.sharedSession(), code: String, completion: (config: TokenConfiguration) -> Void) { - let request = OAuthRouter.AccessToken(self, code).URLRequest + public func authorize(_ session: RequestKitURLSession = URLSession.shared(), code: String, completion: (config: TokenConfiguration) -> Void) { + let request = OAuthRouter.accessToken(self, code).URLRequest if let request = request { let task = session.dataTaskWithRequest(request) { data, response, err in - if let response = response as? NSHTTPURLResponse { + if let response = response as? HTTPURLResponse { if response.statusCode != 200 { return } else { - if let data = data, string = NSString(data: data, encoding: NSUTF8StringEncoding) as? String { + if let data = data, string = NSString(data: data, encoding: String.Encoding.utf8.rawValue) as? String { let accessToken = self.accessTokenFromResponse(string) if let accessToken = accessToken { let config = TokenConfiguration(accessToken, url: self.apiEndpoint) @@ -61,86 +61,81 @@ public struct OAuthConfiguration: Configuration { } } - public func handleOpenURL(session: RequestKitURLSession = NSURLSession.sharedSession(), url: NSURL, completion: (config: TokenConfiguration) -> Void) { - let urlString: String? - #if swift(>=2.3) - urlString = url.absoluteString - #else - urlString = url.absoluteString - #endif - if let code = urlString?.componentsSeparatedByString("=").last { + public func handleOpenURL(_ session: RequestKitURLSession = URLSession.shared(), url: URL, completion: (config: TokenConfiguration) -> Void) { + let urlString: String? = url.absoluteString + if let code = urlString?.components(separatedBy: "=").last { authorize(session, code: code) { (config) in completion(config: config) } } } - public func accessTokenFromResponse(response: String) -> String? { - let accessTokenParam = response.componentsSeparatedByString("&").first + public func accessTokenFromResponse(_ response: String) -> String? { + let accessTokenParam = response.components(separatedBy: "&").first if let accessTokenParam = accessTokenParam { - return accessTokenParam.componentsSeparatedByString("=").last + return accessTokenParam.components(separatedBy: "=").last } return nil } } enum OAuthRouter: Router { - case Authorize(OAuthConfiguration) - case AccessToken(OAuthConfiguration, String) + case authorize(OAuthConfiguration) + case accessToken(OAuthConfiguration, String) var configuration: Configuration { switch self { - case .Authorize(let config): return config - case .AccessToken(let config, _): return config + case .authorize(let config): return config + case .accessToken(let config, _): return config } } var method: HTTPMethod { switch self { - case .Authorize: + case .authorize: return .GET - case .AccessToken: + case .accessToken: return .POST } } var encoding: HTTPEncoding { switch self { - case .Authorize: - return .URL - case .AccessToken: - return .FORM + case .authorize: + return .url + case .accessToken: + return .form } } var path: String { switch self { - case .Authorize: + case .authorize: return "login/oauth/authorize" - case .AccessToken: + case .accessToken: return "login/oauth/access_token" } } var params: [String: AnyObject] { switch self { - case .Authorize(let config): - let scope = (config.scopes as NSArray).componentsJoinedByString(",") + case .authorize(let config): + let scope = (config.scopes as NSArray).componentsJoined(by: ",") return ["scope": scope, "client_id": config.token, "allow_signup": "false"] - case .AccessToken(let config, let code): + case .accessToken(let config, let code): return ["client_id": config.token, "client_secret": config.secret, "code": code] } } - var URLRequest: NSURLRequest? { + var URLRequest: Foundation.URLRequest? { switch self { - case .Authorize(let config): - let url = NSURL(string: path, relativeToURL: NSURL(string: config.webEndpoint)) - let components = NSURLComponents(URL: url!, resolvingAgainstBaseURL: true) + case .authorize(let config): + let url = URL(string: path, relativeTo: URL(string: config.webEndpoint)!) + let components = URLComponents(url: url!, resolvingAgainstBaseURL: true) return request(components!, parameters: params) - case .AccessToken(let config, _): - let url = NSURL(string: path, relativeToURL: NSURL(string: config.webEndpoint)) - let components = NSURLComponents(URL: url!, resolvingAgainstBaseURL: true) + case .accessToken(let config, _): + let url = URL(string: path, relativeTo: URL(string: config.webEndpoint)!) + let components = URLComponents(url: url!, resolvingAgainstBaseURL: true) return request(components!, parameters: params) } } diff --git a/OctoKit/Follow.swift b/OctoKit/Follow.swift index 5ec7f2bd..ba477fcc 100644 --- a/OctoKit/Follow.swift +++ b/OctoKit/Follow.swift @@ -8,15 +8,15 @@ public extension Octokit { - parameter session: RequestKitURLSession, defaults to NSURLSession.sharedSession() - parameter completion: Callback for the outcome of the fetch. */ - public func myFollowers(session: RequestKitURLSession = NSURLSession.sharedSession(), completion: (response: Response<[User]>) -> Void) -> URLSessionDataTaskProtocol? { - let router = FollowRouter.ReadAuthenticatedFollowers(configuration) + public func myFollowers(_ session: RequestKitURLSession = URLSession.shared(), completion: (response: Response<[User]>) -> Void) -> URLSessionDataTaskProtocol? { + let router = FollowRouter.readAuthenticatedFollowers(configuration) return router.loadJSON(session, expectedResultType: [[String: AnyObject]].self) { json, error in if let error = error { - completion(response: Response.Failure(error)) + completion(response: Response.failure(error)) } else { if let json = json { let parsedUsers = json.map { User($0) } - completion(response: Response.Success(parsedUsers)) + completion(response: Response.success(parsedUsers)) } } } @@ -28,15 +28,15 @@ public extension Octokit { - parameter name: Name of the user - parameter completion: Callback for the outcome of the fetch. */ - public func followers(session: RequestKitURLSession = NSURLSession.sharedSession(), name: String, completion: (response: Response<[User]>) -> Void) -> URLSessionDataTaskProtocol? { - let router = FollowRouter.ReadFollowers(name, configuration) + public func followers(_ session: RequestKitURLSession = URLSession.shared(), name: String, completion: (response: Response<[User]>) -> Void) -> URLSessionDataTaskProtocol? { + let router = FollowRouter.readFollowers(name, configuration) return router.loadJSON(session, expectedResultType: [[String: AnyObject]].self) { json, error in if let error = error { - completion(response: Response.Failure(error)) + completion(response: Response.failure(error)) } else { if let json = json { let parsedUsers = json.map { User($0) } - completion(response: Response.Success(parsedUsers)) + completion(response: Response.success(parsedUsers)) } } } @@ -47,15 +47,15 @@ public extension Octokit { - parameter session: RequestKitURLSession, defaults to NSURLSession.sharedSession() - parameter completion: Callback for the outcome of the fetch. */ - public func myFollowing(session: RequestKitURLSession = NSURLSession.sharedSession(), completion: (response: Response<[User]>) -> Void) -> URLSessionDataTaskProtocol? { - let router = FollowRouter.ReadAuthenticatedFollowing(configuration) + public func myFollowing(_ session: RequestKitURLSession = URLSession.shared(), completion: (response: Response<[User]>) -> Void) -> URLSessionDataTaskProtocol? { + let router = FollowRouter.readAuthenticatedFollowing(configuration) return router.loadJSON(session, expectedResultType: [[String: AnyObject]].self) { json, error in if let error = error { - completion(response: Response.Failure(error)) + completion(response: Response.failure(error)) } else { if let json = json { let parsedUsers = json.map { User($0) } - completion(response: Response.Success(parsedUsers)) + completion(response: .success(parsedUsers)) } } } @@ -67,15 +67,15 @@ public extension Octokit { - parameter name: The name of the user - parameter completion: Callback for the outcome of the fetch. */ - public func following(session: RequestKitURLSession = NSURLSession.sharedSession(), name: String, completion: (response: Response<[User]>) -> Void) -> URLSessionDataTaskProtocol? { - let router = FollowRouter.ReadFollowing(name, configuration) + public func following(_ session: RequestKitURLSession = URLSession.shared(), name: String, completion: (response: Response<[User]>) -> Void) -> URLSessionDataTaskProtocol? { + let router = FollowRouter.readFollowing(name, configuration) return router.loadJSON(session, expectedResultType: [[String: AnyObject]].self) { json, error in if let error = error { - completion(response: Response.Failure(error)) + completion(response: Response.failure(error)) } else { if let json = json { let parsedUsers = json.map { User($0) } - completion(response: Response.Success(parsedUsers)) + completion(response: Response.success(parsedUsers)) } } } @@ -83,37 +83,37 @@ public extension Octokit { } enum FollowRouter: Router { - case ReadAuthenticatedFollowers(Configuration) - case ReadFollowers(String, Configuration) - case ReadAuthenticatedFollowing(Configuration) - case ReadFollowing(String, Configuration) + case readAuthenticatedFollowers(Configuration) + case readFollowers(String, Configuration) + case readAuthenticatedFollowing(Configuration) + case readFollowing(String, Configuration) var method: HTTPMethod { return .GET } var encoding: HTTPEncoding { - return .URL + return .url } var configuration: Configuration { switch self { - case .ReadAuthenticatedFollowers(let config): return config - case .ReadFollowers(_, let config): return config - case .ReadAuthenticatedFollowing(let config): return config - case .ReadFollowing(_, let config): return config + case .readAuthenticatedFollowers(let config): return config + case .readFollowers(_, let config): return config + case .readAuthenticatedFollowing(let config): return config + case .readFollowing(_, let config): return config } } var path: String { switch self { - case .ReadAuthenticatedFollowers: + case .readAuthenticatedFollowers: return "user/followers" - case .ReadFollowers(let username, _): + case .readFollowers(let username, _): return "users/\(username)/followers" - case .ReadAuthenticatedFollowing: + case .readAuthenticatedFollowing: return "user/following" - case .ReadFollowing(let username, _): + case .readFollowing(let username, _): return "users/\(username)/following" } } diff --git a/OctoKit/Issue.swift b/OctoKit/Issue.swift index 14549449..2c67d9f8 100644 --- a/OctoKit/Issue.swift +++ b/OctoKit/Issue.swift @@ -10,12 +10,12 @@ public enum Openness: String { @objc public class Issue: NSObject { public var id: Int - public var url: NSURL? - public var repositoryURL: NSURL? - public var labelsURL: NSURL? - public var commentsURL: NSURL? - public var eventsURL: NSURL? - public var htmlURL: NSURL? + public var url: URL? + public var repositoryURL: URL? + public var labelsURL: URL? + public var commentsURL: URL? + public var eventsURL: URL? + public var htmlURL: URL? public var number: Int? public var state: Openness? public var title: String? @@ -26,30 +26,30 @@ public enum Openness: String { public var milestone: Milestone? public var locked: Bool? public var comments: Int? - public var closedAt: NSDate? - public var createdAt: NSDate? - public var updatedAt: NSDate? + public var closedAt: Date? + public var createdAt: Date? + public var updatedAt: Date? public var closedBy: User? public init(_ json: [String: AnyObject]) { if let id = json["id"] as? Int { self.id = id - if let urlString = json["url"] as? String, url = NSURL(string: urlString) { + if let urlString = json["url"] as? String, url = URL(string: urlString) { self.url = url } - if let urlString = json["repository_url"] as? String, url = NSURL(string: urlString) { + if let urlString = json["repository_url"] as? String, url = URL(string: urlString) { repositoryURL = url } - if let urlString = json["labels_url"] as? String, url = NSURL(string: urlString) { + if let urlString = json["labels_url"] as? String, url = URL(string: urlString) { labelsURL = url } - if let urlString = json["comments_url"] as? String, url = NSURL(string: urlString) { + if let urlString = json["comments_url"] as? String, url = URL(string: urlString) { commentsURL = url } - if let urlString = json["events_url"] as? String, url = NSURL(string: urlString) { + if let urlString = json["events_url"] as? String, url = URL(string: urlString) { eventsURL = url } - if let urlString = json["html_url"] as? String, url = NSURL(string: urlString) { + if let urlString = json["html_url"] as? String, url = URL(string: urlString) { htmlURL = url } number = json["number"] as? Int @@ -85,15 +85,15 @@ public extension Octokit { - parameter perPage: Number of issues per page. `100` by default. - parameter completion: Callback for the outcome of the fetch. */ - public func myIssues(session: RequestKitURLSession = NSURLSession.sharedSession(), page: String = "1", perPage: String = "100", completion: (response: Response<[Issue]>) -> Void) -> URLSessionDataTaskProtocol? { - let router = IssueRouter.ReadAuthenticatedIssues(configuration, page, perPage) + public func myIssues(_ session: RequestKitURLSession = URLSession.shared(), page: String = "1", perPage: String = "100", completion: (response: Response<[Issue]>) -> Void) -> URLSessionDataTaskProtocol? { + let router = IssueRouter.readAuthenticatedIssues(configuration, page, perPage) return router.loadJSON(session, expectedResultType: [[String: AnyObject]].self) { json, error in if let error = error { - completion(response: Response.Failure(error)) + completion(response: Response.failure(error)) } else { if let json = json { let parsedIssues = json.map { Issue($0) } - completion(response: Response.Success(parsedIssues)) + completion(response: Response.success(parsedIssues)) } } } @@ -107,15 +107,15 @@ public extension Octokit { - parameter number: The number of the issue. - parameter completion: Callback for the outcome of the fetch. */ - public func issue(session: RequestKitURLSession = NSURLSession.sharedSession(), owner: String, repository: String, number: Int, completion: (response: Response) -> Void) -> URLSessionDataTaskProtocol? { - let router = IssueRouter.ReadIssue(configuration, owner, repository, number) + public func issue(_ session: RequestKitURLSession = URLSession.shared(), owner: String, repository: String, number: Int, completion: (response: Response) -> Void) -> URLSessionDataTaskProtocol? { + let router = IssueRouter.readIssue(configuration, owner, repository, number) return router.loadJSON(session, expectedResultType: [String: AnyObject].self) { json, error in if let error = error { - completion(response: Response.Failure(error)) + completion(response: Response.failure(error)) } else { if let json = json { let issue = Issue(json) - completion(response: Response.Success(issue)) + completion(response: Response.success(issue)) } } } @@ -131,15 +131,15 @@ public extension Octokit { - parameter assignee: The name of the user to assign the issue to. This parameter is ignored if the user lacks push access to the repository. - parameter completion: Callback for the issue that is created. */ - public func postIssue(session: RequestKitURLSession = NSURLSession.sharedSession(), owner: String, repository: String, title: String, body: String? = nil, assignee: String? = nil, completion: (response:Response) -> Void) -> URLSessionDataTaskProtocol? { - let router = IssueRouter.PostIssue(configuration, owner, repository, title, body, assignee) + public func postIssue(_ session: RequestKitURLSession = URLSession.shared(), owner: String, repository: String, title: String, body: String? = nil, assignee: String? = nil, completion: (response:Response) -> Void) -> URLSessionDataTaskProtocol? { + let router = IssueRouter.postIssue(configuration, owner, repository, title, body, assignee) return router.postJSON(session, expectedResultType: [String: AnyObject].self) { json, error in if let error = error { - completion(response: Response.Failure(error)) + completion(response: Response.failure(error)) } else { if let json = json { let issue = Issue(json) - completion(response: Response.Success(issue)) + completion(response: Response.success(issue)) } } } @@ -157,15 +157,15 @@ public extension Octokit { - parameter state: Whether the issue is open or closed. - parameter completion: Callback for the issue that is created. */ - public func patchIssue(session: RequestKitURLSession = NSURLSession.sharedSession(), owner: String, repository: String, number: Int, title: String? = nil, body: String? = nil, assignee: String? = nil, state: Openness? = nil, completion: (response:Response) -> Void) -> URLSessionDataTaskProtocol? { - let router = IssueRouter.PatchIssue(configuration, owner, repository, number, title, body, assignee, state) + public func patchIssue(_ session: RequestKitURLSession = URLSession.shared(), owner: String, repository: String, number: Int, title: String? = nil, body: String? = nil, assignee: String? = nil, state: Openness? = nil, completion: (response:Response) -> Void) -> URLSessionDataTaskProtocol? { + let router = IssueRouter.patchIssue(configuration, owner, repository, number, title, body, assignee, state) return router.postJSON(session, expectedResultType: [String: AnyObject].self) { json, error in if let error = error { - completion(response: Response.Failure(error)) + completion(response: Response.failure(error)) } else { if let json = json { let issue = Issue(json) - completion(response: Response.Success(issue)) + completion(response: Response.success(issue)) } } } @@ -175,14 +175,14 @@ public extension Octokit { // MARK: Router enum IssueRouter: JSONPostRouter { - case ReadAuthenticatedIssues(Configuration, String, String) - case ReadIssue(Configuration, String, String, Int) - case PostIssue(Configuration, String, String, String, String?, String?) - case PatchIssue(Configuration, String, String, Int, String?, String?, String?, Openness?) + case readAuthenticatedIssues(Configuration, String, String) + case readIssue(Configuration, String, String, Int) + case postIssue(Configuration, String, String, String, String?, String?) + case patchIssue(Configuration, String, String, Int, String?, String?, String?, Openness?) var method: HTTPMethod { switch self { - case .PostIssue, .PatchIssue: + case .postIssue, .patchIssue: return .POST default: return .GET @@ -191,29 +191,29 @@ enum IssueRouter: JSONPostRouter { var encoding: HTTPEncoding { switch self { - case .PostIssue, .PatchIssue: - return .JSON + case .postIssue, .patchIssue: + return .json default: - return .URL + return .url } } var configuration: Configuration { switch self { - case .ReadAuthenticatedIssues(let config, _, _): return config - case .ReadIssue(let config, _, _, _): return config - case .PostIssue(let config, _, _, _, _, _): return config - case .PatchIssue(let config, _, _, _, _, _, _, _): return config + case .readAuthenticatedIssues(let config, _, _): return config + case .readIssue(let config, _, _, _): return config + case .postIssue(let config, _, _, _, _, _): return config + case .patchIssue(let config, _, _, _, _, _, _, _): return config } } var params: [String: AnyObject] { switch self { - case .ReadAuthenticatedIssues(_, let page, let perPage): + case .readAuthenticatedIssues(_, let page, let perPage): return ["per_page": perPage, "page": page] - case .ReadIssue: + case .readIssue: return [:] - case .PostIssue(_, _, _, let title, let body, let assignee): + case .postIssue(_, _, _, let title, let body, let assignee): var params = ["title": title] if let body = body { params["body"] = body @@ -222,7 +222,7 @@ enum IssueRouter: JSONPostRouter { params["assignee"] = assignee } return params - case .PatchIssue(_, _, _, _, let title, let body, let assignee, let state): + case .patchIssue(_, _, _, _, let title, let body, let assignee, let state): var params: [String: String] = [:] if let title = title { params["title"] = title @@ -242,13 +242,13 @@ enum IssueRouter: JSONPostRouter { var path: String { switch self { - case .ReadAuthenticatedIssues: + case .readAuthenticatedIssues: return "issues" - case .ReadIssue(_, let owner, let repository, let number): + case .readIssue(_, let owner, let repository, let number): return "repos/\(owner)/\(repository)/issues/\(number)" - case .PostIssue(_, let owner, let repository, _, _, _): + case .postIssue(_, let owner, let repository, _, _, _): return "repos/\(owner)/\(repository)/issues" - case .PatchIssue(_, let owner, let repository, let number, _, _, _, _): + case .patchIssue(_, let owner, let repository, let number, _, _, _, _): return "repos/\(owner)/\(repository)/issues/\(number)" } } diff --git a/OctoKit/Label.swift b/OctoKit/Label.swift index 3181d7d3..aaee234e 100644 --- a/OctoKit/Label.swift +++ b/OctoKit/Label.swift @@ -23,7 +23,7 @@ extension Color { } @objc public class Label: NSObject { - public var url: NSURL? + public var url: URL? public var name: String? #if os(OSX) public var color: NSColor? @@ -32,7 +32,7 @@ extension Color { #endif public init(_ json: [String: AnyObject]) { - if let urlString = json["url"] as? String, url = NSURL(string: urlString) { + if let urlString = json["url"] as? String, url = URL(string: urlString) { self.url = url } name = json["name"] as? String diff --git a/OctoKit/Milestone.swift b/OctoKit/Milestone.swift index 3a2a4e06..2b7c6c36 100644 --- a/OctoKit/Milestone.swift +++ b/OctoKit/Milestone.swift @@ -1,9 +1,9 @@ import Foundation @objc public class Milestone: NSObject { - public var url: NSURL? - public var htmlURL: NSURL? - public var labelsURL: NSURL? + public var url: URL? + public var htmlURL: URL? + public var labelsURL: URL? public var id: Int public var number: Int? public var state: Openness? @@ -12,17 +12,17 @@ import Foundation public var creator: User? public var openIssues: Int? public var closedIssues: Int? - public var createdAt: NSDate? - public var updatedAt: NSDate? - public var closedAt: NSDate? - public var dueOn: NSDate? + public var createdAt: Date? + public var updatedAt: Date? + public var closedAt: Date? + public var dueOn: Date? public init?(_ json: [String: AnyObject]) { if let id = json["id"] as? Int { - if let urlString = json["html_url"] as? String, url = NSURL(string: urlString) { + if let urlString = json["html_url"] as? String, url = URL(string: urlString) { htmlURL = url } - if let urlString = json["labels_url"] as? String, url = NSURL(string: urlString) { + if let urlString = json["labels_url"] as? String, url = URL(string: urlString) { labelsURL = url } self.id = id diff --git a/OctoKit/PublicKey.swift b/OctoKit/PublicKey.swift index c6ca6bf0..22f1d3af 100644 --- a/OctoKit/PublicKey.swift +++ b/OctoKit/PublicKey.swift @@ -4,14 +4,14 @@ import RequestKit // MARK: request public extension Octokit { - public func postPublicKey(session: RequestKitURLSession = NSURLSession.sharedSession(), publicKey: String, title: String, completion: (response:Response) -> Void) -> URLSessionDataTaskProtocol? { - let router = PublicKeyRouter.PostPublicKey(publicKey, title, configuration) + public func postPublicKey(_ session: RequestKitURLSession = URLSession.shared(), publicKey: String, title: String, completion: (response:Response) -> Void) -> URLSessionDataTaskProtocol? { + let router = PublicKeyRouter.postPublicKey(publicKey, title, configuration) return router.postJSON(session, expectedResultType: [String: AnyObject].self) { json, error in if let error = error { - completion(response: Response.Failure(error)) + completion(response: Response.failure(error)) } else { if let _ = json { - completion(response: Response.Success(publicKey)) + completion(response: Response.success(publicKey)) } } } @@ -19,38 +19,38 @@ public extension Octokit { } enum PublicKeyRouter: JSONPostRouter { - case PostPublicKey(String, String, Configuration) + case postPublicKey(String, String, Configuration) var configuration: Configuration { switch self { - case .PostPublicKey(_, _, let config): return config + case .postPublicKey(_, _, let config): return config } } var method: HTTPMethod { switch self { - case .PostPublicKey: + case .postPublicKey: return .POST } } var encoding: HTTPEncoding { switch self { - case .PostPublicKey: - return .JSON + case .postPublicKey: + return .json } } var path: String { switch self { - case .PostPublicKey: + case .postPublicKey: return "user/keys" } } var params: [String: AnyObject] { switch self { - case .PostPublicKey(let publicKey, let title, _): + case .postPublicKey(let publicKey, let title, _): return ["title": title, "key": publicKey] } } diff --git a/OctoKit/Repositories.swift b/OctoKit/Repositories.swift index 6a2e1bd7..8ecb2289 100644 --- a/OctoKit/Repositories.swift +++ b/OctoKit/Repositories.swift @@ -16,7 +16,7 @@ import RequestKit public var cloneURL: String? public var htmlURL: String? public var size: Int - public var lastPush: NSDate? + public var lastPush: Date? public init(_ json: [String: AnyObject]) { owner = User(json["owner"] as? [String: AnyObject] ?? [:]) @@ -53,18 +53,18 @@ public extension Octokit { - parameter perPage: Number of repositories per page. `100` by default. - parameter completion: Callback for the outcome of the fetch. */ - public func repositories(session: RequestKitURLSession = NSURLSession.sharedSession(), owner: String? = nil, page: String = "1", perPage: String = "100", completion: (response: Response<[Repository]>) -> Void) -> URLSessionDataTaskProtocol? { + public func repositories(_ session: RequestKitURLSession = URLSession.shared(), owner: String? = nil, page: String = "1", perPage: String = "100", completion: (response: Response<[Repository]>) -> Void) -> URLSessionDataTaskProtocol? { let router = (owner != nil) - ? RepositoryRouter.ReadRepositories(configuration, owner!, page, perPage) - : RepositoryRouter.ReadAuthenticatedRepositories(configuration, page, perPage) + ? RepositoryRouter.readRepositories(configuration, owner!, page, perPage) + : RepositoryRouter.readAuthenticatedRepositories(configuration, page, perPage) return router.loadJSON(session, expectedResultType: [[String: AnyObject]].self) { json, error in if let error = error { - completion(response: Response.Failure(error)) + completion(response: Response.failure(error)) } if let json = json { let repos = json.map { Repository($0) } - completion(response: Response.Success(repos)) + completion(response: Response.success(repos)) } } } @@ -76,15 +76,15 @@ public extension Octokit { - parameter name: The name of the repository to fetch. - parameter completion: Callback for the outcome of the fetch. */ - public func repository(session: RequestKitURLSession = NSURLSession.sharedSession(), owner: String, name: String, completion: (response: Response) -> Void) -> URLSessionDataTaskProtocol? { - let router = RepositoryRouter.ReadRepository(configuration, owner, name) + public func repository(_ session: RequestKitURLSession = URLSession.shared(), owner: String, name: String, completion: (response: Response) -> Void) -> URLSessionDataTaskProtocol? { + let router = RepositoryRouter.readRepository(configuration, owner, name) return router.loadJSON(session, expectedResultType: [String: AnyObject].self) { json, error in if let error = error { - completion(response: Response.Failure(error)) + completion(response: Response.failure(error)) } else { if let json = json { let repo = Repository(json) - completion(response: Response.Success(repo)) + completion(response: Response.success(repo)) } } } @@ -94,15 +94,15 @@ public extension Octokit { // MARK: Router enum RepositoryRouter: Router { - case ReadRepositories(Configuration, String, String, String) - case ReadAuthenticatedRepositories(Configuration, String, String) - case ReadRepository(Configuration, String, String) + case readRepositories(Configuration, String, String, String) + case readAuthenticatedRepositories(Configuration, String, String) + case readRepository(Configuration, String, String) var configuration: Configuration { switch self { - case .ReadRepositories(let config, _, _, _): return config - case .ReadAuthenticatedRepositories(let config, _, _): return config - case .ReadRepository(let config, _, _): return config + case .readRepositories(let config, _, _, _): return config + case .readAuthenticatedRepositories(let config, _, _): return config + case .readRepository(let config, _, _): return config } } @@ -111,27 +111,27 @@ enum RepositoryRouter: Router { } var encoding: HTTPEncoding { - return .URL + return .url } var params: [String: AnyObject] { switch self { - case .ReadRepositories(_, _, let page, let perPage): + case .readRepositories(_, _, let page, let perPage): return ["per_page": perPage, "page": page] - case .ReadAuthenticatedRepositories(_, let page, let perPage): + case .readAuthenticatedRepositories(_, let page, let perPage): return ["per_page": perPage, "page": page] - case .ReadRepository: + case .readRepository: return [:] } } var path: String { switch self { - case ReadRepositories(_, let owner, _, _): + case .readRepositories(_, let owner, _, _): return "/users/\(owner)/repos" - case .ReadAuthenticatedRepositories: + case .readAuthenticatedRepositories: return "/user/repos" - case .ReadRepository(_, let owner, let name): + case .readRepository(_, let owner, let name): return "/repos/\(owner)/\(name)" } } diff --git a/OctoKit/Stars.swift b/OctoKit/Stars.swift index ca24d0e3..85559d28 100644 --- a/OctoKit/Stars.swift +++ b/OctoKit/Stars.swift @@ -9,15 +9,15 @@ public extension Octokit { - parameter name: The user who starred repositories. - parameter completion: Callback for the outcome of the fetch. */ - public func stars(session: RequestKitURLSession = NSURLSession.sharedSession(), name: String, completion: (response: Response<[Repository]>) -> Void) -> URLSessionDataTaskProtocol? { - let router = StarsRouter.ReadStars(name, configuration) + public func stars(_ session: RequestKitURLSession = URLSession.shared(), name: String, completion: (response: Response<[Repository]>) -> Void) -> URLSessionDataTaskProtocol? { + let router = StarsRouter.readStars(name, configuration) return router.loadJSON(session, expectedResultType: [[String: AnyObject]].self) { json, error in if let error = error { - completion(response: Response.Failure(error)) + completion(response: Response.failure(error)) } else { if let json = json { let parsedStars = json.map { Repository($0) } - completion(response: Response.Success(parsedStars)) + completion(response: Response.success(parsedStars)) } } } @@ -28,15 +28,15 @@ public extension Octokit { - parameter session: RequestKitURLSession, defaults to NSURLSession.sharedSession() - parameter completion: Callback for the outcome of the fetch. */ - public func myStars(session: RequestKitURLSession = NSURLSession.sharedSession(), completion: (response: Response<[Repository]>) -> Void) -> URLSessionDataTaskProtocol? { - let router = StarsRouter.ReadAuthenticatedStars(configuration) + public func myStars(_ session: RequestKitURLSession = URLSession.shared(), completion: (response: Response<[Repository]>) -> Void) -> URLSessionDataTaskProtocol? { + let router = StarsRouter.readAuthenticatedStars(configuration) return router.loadJSON(session, expectedResultType: [[String: AnyObject]].self) { json, error in if let error = error { - completion(response: Response.Failure(error)) + completion(response: Response.failure(error)) } else { if let json = json { let parsedStars = json.map { Repository($0) } - completion(response: Response.Success(parsedStars)) + completion(response: Response.success(parsedStars)) } } } @@ -44,28 +44,28 @@ public extension Octokit { } enum StarsRouter: Router { - case ReadAuthenticatedStars(Configuration) - case ReadStars(String, Configuration) + case readAuthenticatedStars(Configuration) + case readStars(String, Configuration) var method: HTTPMethod { return .GET } var configuration: Configuration { switch self { - case .ReadAuthenticatedStars(let config): return config - case .ReadStars(_, let config): return config + case .readAuthenticatedStars(let config): return config + case .readStars(_, let config): return config } } var encoding: HTTPEncoding { - return .URL + return .url } var path: String { switch self { - case .ReadAuthenticatedStars: + case .readAuthenticatedStars: return "user/starred" - case .ReadStars(let username, _): + case .readStars(let username, _): return "users/\(username)/starred" } } diff --git a/OctoKit/Time.swift b/OctoKit/Time.swift index 6220f7e7..6b249cb5 100644 --- a/OctoKit/Time.swift +++ b/OctoKit/Time.swift @@ -8,11 +8,11 @@ struct Time { - [https://developer.apple.com/library/mac/qa/qa1480/_index.html](https://developer.apple.com/library/mac/qa/qa1480/_index.html) - [https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/DataFormatting/Articles/dfDateFormatting10_4.html](https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/DataFormatting/Articles/dfDateFormatting10_4.html) */ - private static var rfc3339DateFormatter: NSDateFormatter = { - let formatter = NSDateFormatter() + private static var rfc3339DateFormatter: DateFormatter = { + let formatter = DateFormatter() formatter.dateFormat = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'" - formatter.locale = NSLocale(localeIdentifier: "en_US_POSIX") - formatter.timeZone = NSTimeZone(forSecondsFromGMT: 0) + formatter.locale = Locale(localeIdentifier: "en_US_POSIX") + formatter.timeZone = TimeZone(forSecondsFromGMT: 0) return formatter }() @@ -21,8 +21,8 @@ struct Time { - parameter string: The string representation of the date - returns: An `NSDate` with a successful parse, otherwise `nil` */ - static func rfc3339Date(string: String?) -> NSDate? { + static func rfc3339Date(_ string: String?) -> Date? { guard let string = string else { return nil } - return Time.rfc3339DateFormatter.dateFromString(string) + return Time.rfc3339DateFormatter.date(from: string) } } diff --git a/OctoKit/User.swift b/OctoKit/User.swift index 5227b1af..6a3ccf33 100644 --- a/OctoKit/User.swift +++ b/OctoKit/User.swift @@ -49,15 +49,15 @@ public extension Octokit { - parameter name: The name of the user or organization. - parameter completion: Callback for the outcome of the fetch. */ - public func user(session: RequestKitURLSession = NSURLSession.sharedSession(), name: String, completion: (response: Response) -> Void) -> URLSessionDataTaskProtocol? { - let router = UserRouter.ReadUser(name, self.configuration) + public func user(_ session: RequestKitURLSession = URLSession.shared(), name: String, completion: (response: Response) -> Void) -> URLSessionDataTaskProtocol? { + let router = UserRouter.readUser(name, self.configuration) return router.loadJSON(session, expectedResultType: [String: AnyObject].self) { json, error in if let error = error { - completion(response: Response.Failure(error)) + completion(response: Response.failure(error)) } else { if let json = json { let parsedUser = User(json) - completion(response: Response.Success(parsedUser)) + completion(response: Response.success(parsedUser)) } } } @@ -68,15 +68,15 @@ public extension Octokit { - parameter session: RequestKitURLSession, defaults to NSURLSession.sharedSession() - parameter completion: Callback for the outcome of the fetch. */ - public func me(session: RequestKitURLSession = NSURLSession.sharedSession(), completion: (response: Response) -> Void) -> URLSessionDataTaskProtocol? { - let router = UserRouter.ReadAuthenticatedUser(self.configuration) + public func me(_ session: RequestKitURLSession = URLSession.shared(), completion: (response: Response) -> Void) -> URLSessionDataTaskProtocol? { + let router = UserRouter.readAuthenticatedUser(self.configuration) return router.loadJSON(session, expectedResultType: [String: AnyObject].self) { json, error in if let error = error { - completion(response: Response.Failure(error)) + completion(response: Response.failure(error)) } else { if let json = json { let parsedUser = User(json) - completion(response: Response.Success(parsedUser)) + completion(response: Response.success(parsedUser)) } } } @@ -86,13 +86,13 @@ public extension Octokit { // MARK: Router enum UserRouter: Router { - case ReadAuthenticatedUser(Configuration) - case ReadUser(String, Configuration) + case readAuthenticatedUser(Configuration) + case readUser(String, Configuration) var configuration: Configuration { switch self { - case .ReadAuthenticatedUser(let config): return config - case .ReadUser(_, let config): return config + case .readAuthenticatedUser(let config): return config + case .readUser(_, let config): return config } } @@ -101,14 +101,14 @@ enum UserRouter: Router { } var encoding: HTTPEncoding { - return .URL + return .url } var path: String { switch self { - case .ReadAuthenticatedUser: + case .readAuthenticatedUser: return "user" - case .ReadUser(let username, _): + case .readUser(let username, _): return "users/\(username)" } } diff --git a/OctoKitTests/ConfigurationTests.swift b/OctoKitTests/ConfigurationTests.swift index e31475df..2a7b845c 100644 --- a/OctoKitTests/ConfigurationTests.swift +++ b/OctoKitTests/ConfigurationTests.swift @@ -40,7 +40,7 @@ class ConfigurationTests: XCTestCase { let config = OAuthConfiguration(token: "12345", secret: "6789", scopes: ["repo", "read:org"]) let response = "access_token=017ec60f4a182&scope=read%3Aorg%2Crepo&token_type=bearer" let session = OctoKitURLTestSession(expectedURL: "https://github.com/login/oauth/access_token", expectedHTTPMethod: "POST", response: response, statusCode: 200) - let url = NSURL(string: "urlscheme://authorize?code=dhfjgh23493")! + let url = URL(string: "urlscheme://authorize?code=dhfjgh23493")! var token: String? = nil config.handleOpenURL(session, url: url) { accessToken in token = accessToken.accessToken diff --git a/OctoKitTests/FollowTests.swift b/OctoKitTests/FollowTests.swift index 4b6f3a13..71c8790f 100644 --- a/OctoKitTests/FollowTests.swift +++ b/OctoKitTests/FollowTests.swift @@ -5,74 +5,79 @@ class FollowTests: XCTestCase { func testGetMyFollowers() { let config = TokenConfiguration("12345") let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/user/followers?access_token=12345", expectedHTTPMethod: "GET", jsonFile: "users", statusCode: 200) - Octokit(config).myFollowers(session) { response in + let task = Octokit(config).myFollowers(session) { response in switch response { - case .Success(let users): + case .success(let users): XCTAssertEqual(users.count, 1) - case .Failure: + case .failure: XCTAssert(false, "should not get an error") } } + XCTAssertNotNil(task) XCTAssertTrue(session.wasCalled) } func testFailToGetMyFollowers() { let config = TokenConfiguration("12345") let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/user/followers?access_token=12345", expectedHTTPMethod: "GET", jsonFile: nil, statusCode: 404) - Octokit(config).myFollowers(session) { response in + let task = Octokit(config).myFollowers(session) { response in switch response { - case .Success: + case .success: XCTAssert(false, "should not retrieve followers") - case .Failure(let error as NSError): + case .failure(let error as NSError): XCTAssertEqual(error.code, 404) XCTAssertEqual(error.domain, OctoKitErrorDomain) - case .Failure: + case .failure: XCTAssertTrue(false) } } + XCTAssertNotNil(task) XCTAssertTrue(session.wasCalled) } func testGetUsersFollowers() { let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/users/octocat/followers", expectedHTTPMethod: "GET", jsonFile: "users", statusCode: 200) - Octokit().followers(session, name: "octocat") { response in + let task = Octokit().followers(session, name: "octocat") { response in switch response { - case .Success(let users): + case .success(let users): XCTAssertEqual(users.count, 1) - case .Failure: + case .failure: XCTAssert(false, "should not get an error") } } + XCTAssertNotNil(task) XCTAssertTrue(session.wasCalled) } func testFailToGetUsersFollowers() { let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/users/octocat/followers", expectedHTTPMethod: "GET", jsonFile: nil, statusCode: 404) - Octokit().followers(session, name: "octocat") { response in + let task = Octokit().followers(session, name: "octocat") { response in switch response { - case .Success: + case .success: XCTAssert(false, "should not retrieve followers") - case .Failure(let error as NSError): + case .failure(let error as NSError): XCTAssertEqual(error.code, 404) XCTAssertEqual(error.domain, OctoKitErrorDomain) - case .Failure: + case .failure: XCTAssertTrue(false) } } + XCTAssertNotNil(task) XCTAssertTrue(session.wasCalled) } func testGetMyFollowing() { let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/user/following?access_token=12345", expectedHTTPMethod: "GET", jsonFile: "users", statusCode: 200) let config = TokenConfiguration("12345") - Octokit(config).myFollowing(session) { response in + let task = Octokit(config).myFollowing(session) { response in switch response { - case .Success(let users): + case .success(let users): XCTAssertEqual(users.count, 1) - case .Failure: + case .failure: XCTAssert(false, "should not get an error") } } + XCTAssertNotNil(task) XCTAssertTrue(session.wasCalled) } @@ -81,12 +86,12 @@ class FollowTests: XCTestCase { let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/user/following?access_token=12345", expectedHTTPMethod: "GET", jsonFile: nil, statusCode: 404) let task = Octokit(config).myFollowing(session) { response in switch response { - case .Success: + case .success: XCTAssert(false, "should not retrieve following") - case .Failure(let error as NSError): + case .failure(let error as NSError): XCTAssertEqual(error.code, 404) XCTAssertEqual(error.domain, OctoKitErrorDomain) - case .Failure: + case .failure: XCTAssertTrue(false) } } @@ -98,9 +103,9 @@ class FollowTests: XCTestCase { let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/users/octocat/following", expectedHTTPMethod: "GET", jsonFile: "users", statusCode: 200) let task = Octokit().following(session, name: "octocat") { response in switch response { - case .Success(let users): + case .success(let users): XCTAssertEqual(users.count, 1) - case .Failure: + case .failure: XCTAssert(false, "should not get an error") } } @@ -112,12 +117,12 @@ class FollowTests: XCTestCase { let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/users/octocat/following", expectedHTTPMethod: "GET", jsonFile: nil, statusCode: 404) let task = Octokit().following(session, name: "octocat") { response in switch response { - case .Success: + case .success: XCTAssert(false, "should not retrieve following") - case .Failure(let error as NSError): + case .failure(let error as NSError): XCTAssertEqual(error.code, 404) XCTAssertEqual(error.domain, OctoKitErrorDomain) - case .Failure: + case .failure: XCTAssertTrue(false) } } diff --git a/OctoKitTests/IssueTests.swift b/OctoKitTests/IssueTests.swift index 19f8a47e..2a5923ae 100644 --- a/OctoKitTests/IssueTests.swift +++ b/OctoKitTests/IssueTests.swift @@ -9,9 +9,9 @@ class IssueTests: XCTestCase { let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/issues?access_token=12345&page=1&per_page=100", expectedHTTPMethod: "GET", jsonFile: "issues", statusCode: 200) let task = Octokit(config).myIssues(session) { response in switch response { - case .Success(let issues): + case .success(let issues): XCTAssertEqual(issues.count, 1) - case .Failure: + case .failure: XCTAssert(false, "should not get an error") } } @@ -23,9 +23,9 @@ class IssueTests: XCTestCase { let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/repos/octocat/Hello-World/issues/1347", expectedHTTPMethod: "GET", jsonFile: "issue", statusCode: 200) let task = Octokit().issue(session, owner: "octocat", repository: "Hello-World", number: 1347) { response in switch response { - case .Success(let issue): + case .success(let issue): XCTAssertEqual(issue.number, 1347) - case .Failure: + case .failure: XCTAssert(false, "should not get an error") } } @@ -43,7 +43,7 @@ class IssueTests: XCTestCase { XCTAssertEqual(subject.id, 1) XCTAssertEqual(subject.number, 1347) XCTAssertEqual(subject.title, "Found a bug") - XCTAssertEqual(subject.htmlURL, NSURL(string: "https://github.com/octocat/Hello-World/issues/1347")) + XCTAssertEqual(subject.htmlURL, URL(string: "https://github.com/octocat/Hello-World/issues/1347")) XCTAssertEqual(subject.state, Openness.Open) XCTAssertEqual(subject.locked, false) } diff --git a/OctoKitTests/OctoKitURLTestSession.swift b/OctoKitTests/OctoKitURLTestSession.swift index a6134f28..eaa2b77d 100644 --- a/OctoKitTests/OctoKitURLTestSession.swift +++ b/OctoKitTests/OctoKitURLTestSession.swift @@ -34,21 +34,21 @@ class OctoKitURLTestSession: RequestKitURLSession { self.statusCode = statusCode } - func dataTaskWithRequest(request: NSURLRequest, completionHandler: (NSData?, NSURLResponse?, NSError?) -> Void) -> URLSessionDataTaskProtocol { - XCTAssertEqual(request.URL?.absoluteString, expectedURL) - XCTAssertEqual(request.HTTPMethod, expectedHTTPMethod) - let data = responseString?.dataUsingEncoding(NSUTF8StringEncoding) - let response = NSHTTPURLResponse(URL: request.URL!, statusCode: statusCode, HTTPVersion: "http/1.1", headerFields: ["Content-Type": "application/json"]) + func dataTaskWithRequest(_ request: URLRequest, completionHandler: (Data?, URLResponse?, NSError?) -> Void) -> URLSessionDataTaskProtocol { + XCTAssertEqual(request.url?.absoluteString, expectedURL) + XCTAssertEqual(request.httpMethod, expectedHTTPMethod) + let data = responseString?.data(using: String.Encoding.utf8) + let response = HTTPURLResponse(url: request.url!, statusCode: statusCode, httpVersion: "http/1.1", headerFields: ["Content-Type": "application/json"]) completionHandler(data, response, nil) wasCalled = true return MockURLSessionDataTask() } - func uploadTaskWithRequest(request: NSURLRequest, fromData bodyData: NSData?, completionHandler: (NSData?, NSURLResponse?, NSError?) -> Void) -> URLSessionDataTaskProtocol { - XCTAssertEqual(request.URL?.absoluteString, expectedURL) - XCTAssertEqual(request.HTTPMethod, expectedHTTPMethod) - let data = responseString?.dataUsingEncoding(NSUTF8StringEncoding) - let response = NSHTTPURLResponse(URL: request.URL!, statusCode: statusCode, HTTPVersion: "http/1.1", headerFields: ["Content-Type": "application/json"]) + func uploadTaskWithRequest(_ request: URLRequest, fromData bodyData: Data?, completionHandler: (Data?, URLResponse?, NSError?) -> Void) -> URLSessionDataTaskProtocol { + XCTAssertEqual(request.url?.absoluteString, expectedURL) + XCTAssertEqual(request.httpMethod, expectedHTTPMethod) + let data = responseString?.data(using: String.Encoding.utf8) + let response = HTTPURLResponse(url: request.url!, statusCode: statusCode, httpVersion: "http/1.1", headerFields: ["Content-Type": "application/json"]) completionHandler(data, response, nil) wasCalled = true return MockURLSessionDataTask() diff --git a/OctoKitTests/PublicKeyTests.swift b/OctoKitTests/PublicKeyTests.swift index e2fbfb84..d88e9a51 100644 --- a/OctoKitTests/PublicKeyTests.swift +++ b/OctoKitTests/PublicKeyTests.swift @@ -10,9 +10,9 @@ class PublicKeyTests: XCTestCase { let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/user/keys?access_token=12345", expectedHTTPMethod: "POST", jsonFile: "public_key", statusCode: 201) let task = Octokit(config).postPublicKey(session, publicKey: "test-key", title: "test title") { response in switch response { - case .Success(let publicKey): + case .success(let publicKey): XCTAssertEqual(publicKey, "test-key") - case .Failure: + case .failure: XCTAssert(false, "should not get an error") } } diff --git a/OctoKitTests/RepositoryTests.swift b/OctoKitTests/RepositoryTests.swift index f044bcb1..bcee0d82 100644 --- a/OctoKitTests/RepositoryTests.swift +++ b/OctoKitTests/RepositoryTests.swift @@ -8,9 +8,9 @@ class RepositoryTests: XCTestCase { let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/users/octocat/repos?page=1&per_page=100", expectedHTTPMethod: "GET", jsonFile: "user_repos", statusCode: 200) let task = Octokit().repositories(session, owner: "octocat") { response in switch response { - case .Success(let repositories): + case .success(let repositories): XCTAssertEqual(repositories.count, 1) - case .Failure: + case .failure: XCTAssert(false, "should not get an error") } } @@ -23,9 +23,9 @@ class RepositoryTests: XCTestCase { let config = TokenConfiguration("12345") let task = Octokit(config).repositories(session) { response in switch response { - case .Success(let repositories): + case .success(let repositories): XCTAssertEqual(repositories.count, 1) - case .Failure: + case .failure: XCTAssert(false, "should not get an error") } } @@ -39,12 +39,12 @@ class RepositoryTests: XCTestCase { let config = TokenConfiguration("12345") let task = Octokit(config).repositories(session) { response in switch response { - case .Success: + case .success: XCTAssert(false, "should not retrieve repositories") - case .Failure(let error as NSError): + case .failure(let error as NSError): XCTAssertEqual(error.code, 401) XCTAssertEqual(error.domain, OctoKitErrorDomain) - case .Failure: + case .failure: XCTAssertTrue(false) } } @@ -57,10 +57,10 @@ class RepositoryTests: XCTestCase { let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/repos/mietzmithut/Test", expectedHTTPMethod: "GET", jsonFile: "repo", statusCode: 200) let task = Octokit().repository(session, owner: owner, name: name) { response in switch response { - case .Success(let repo): + case .success(let repo): XCTAssertEqual(repo.name, name) XCTAssertEqual(repo.owner.login, owner) - case .Failure: + case .failure: XCTAssert(false, "should not get an error") } } @@ -73,12 +73,12 @@ class RepositoryTests: XCTestCase { let (owner, name) = ("mietzmithut", "Test") let task = Octokit().repository(session, owner: owner, name: name) { response in switch response { - case .Success: + case .success: XCTAssert(false, "should not retrieve repositories") - case .Failure(let error as NSError): + case .failure(let error as NSError): XCTAssertEqual(error.code, 404) XCTAssertEqual(error.domain, OctoKitErrorDomain) - case .Failure: + case .failure: XCTAssertTrue(false) } } diff --git a/OctoKitTests/StarsTests.swift b/OctoKitTests/StarsTests.swift index 09604bbc..56724eba 100644 --- a/OctoKitTests/StarsTests.swift +++ b/OctoKitTests/StarsTests.swift @@ -9,9 +9,9 @@ class StarsTests: XCTestCase { let config = TokenConfiguration("12345") let task = Octokit(config).myStars(session) { response in switch response { - case .Success(let repositories): + case .success(let repositories): XCTAssertEqual(repositories.count, 1) - case .Failure: + case .failure: XCTAssert(false, "should not get an error") } } @@ -24,12 +24,12 @@ class StarsTests: XCTestCase { let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/user/starred?access_token=12345", expectedHTTPMethod: "GET", jsonFile: nil, statusCode: 404) let task = Octokit(config).myStars(session) { response in switch response { - case .Success: + case .success: XCTAssert(false, "should not retrieve repositories") - case .Failure(let error as NSError): + case .failure(let error as NSError): XCTAssertEqual(error.code, 404) XCTAssertEqual(error.domain, OctoKitErrorDomain) - case .Failure: + case .failure: XCTAssertTrue(false) } } @@ -41,9 +41,9 @@ class StarsTests: XCTestCase { let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/users/octocat/starred", expectedHTTPMethod: "GET", jsonFile: "user_repos", statusCode: 200) let task = Octokit().stars(session, name: "octocat") { response in switch response { - case .Success(let repositories): + case .success(let repositories): XCTAssertEqual(repositories.count, 1) - case .Failure: + case .failure: XCTAssert(false, "should not get an error") } } @@ -55,16 +55,16 @@ class StarsTests: XCTestCase { let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/users/octocat/starred", expectedHTTPMethod: "GET", jsonFile: nil, statusCode: 404) let task = Octokit().stars(session, name: "octocat") { response in switch response { - case .Success: + case .success: XCTAssert(false, "should not retrieve repositories") - case .Failure(let error as NSError): + case .failure(let error as NSError): XCTAssertEqual(error.code, 404) XCTAssertEqual(error.domain, OctoKitErrorDomain) - case .Failure: + case .failure: XCTAssertTrue(false) } } XCTAssertNotNil(task) XCTAssertTrue(session.wasCalled) } -} \ No newline at end of file +} diff --git a/OctoKitTests/TestHelper.swift b/OctoKitTests/TestHelper.swift index 13aea7ee..8df7db39 100644 --- a/OctoKitTests/TestHelper.swift +++ b/OctoKitTests/TestHelper.swift @@ -1,22 +1,22 @@ import Foundation internal class Helper { - internal class func stringFromFile(name: String) -> String? { - let bundle = NSBundle(forClass: self) + internal class func stringFromFile(_ name: String) -> String? { + let bundle = Bundle(for: self) let path = bundle.pathForResource(name, ofType: "json") if let path = path { - let string = try? String(contentsOfFile: path, encoding: NSUTF8StringEncoding) + let string = try? String(contentsOfFile: path, encoding: String.Encoding.utf8) return string } return nil } - internal class func JSONFromFile(name: String) -> AnyObject { - let bundle = NSBundle(forClass: self) + internal class func JSONFromFile(_ name: String) -> AnyObject { + let bundle = Bundle(for: self) let path = bundle.pathForResource(name, ofType: "json")! - let data = NSData(contentsOfFile: path)! - let dict: AnyObject? = try? NSJSONSerialization.JSONObjectWithData(data, - options: NSJSONReadingOptions.MutableContainers) + let data = try! Data(contentsOf: URL(fileURLWithPath: path)) + let dict: AnyObject? = try? JSONSerialization.jsonObject(with: data, + options: JSONSerialization.ReadingOptions.mutableContainers) return dict! } } diff --git a/OctoKitTests/UserTests.swift b/OctoKitTests/UserTests.swift index 3fceacb6..569cfdc7 100644 --- a/OctoKitTests/UserTests.swift +++ b/OctoKitTests/UserTests.swift @@ -9,9 +9,9 @@ class UserTests: XCTestCase { let username = "mietzmithut" let task = Octokit().user(session, name: username) { response in switch response { - case .Success(let user): + case .success(let user): XCTAssertEqual(user.login, username) - case .Failure: + case .failure: XCTAssert(false, "should not get an user") } } @@ -24,12 +24,12 @@ class UserTests: XCTestCase { let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/users/notexisting", expectedHTTPMethod: "GET", jsonFile: nil, statusCode: 404) let task = Octokit().user(session, name: username) { response in switch response { - case .Success: + case .success: XCTAssert(false, "should not retrieve user") - case .Failure(let error as NSError): + case .failure(let error as NSError): XCTAssertEqual(error.code, 404) XCTAssertEqual(error.domain, OctoKitErrorDomain) - case .Failure: + case .failure: XCTAssertTrue(false) } } @@ -41,9 +41,9 @@ class UserTests: XCTestCase { let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/user?access_token=token", expectedHTTPMethod: "GET", jsonFile: "user_me", statusCode: 200) let task = Octokit(TokenConfiguration("token")).me(session) { response in switch response { - case .Success(let user): + case .success(let user): XCTAssertEqual(user.login, "pietbrauer") - case .Failure(let error): + case .failure(let error): XCTAssert(false, "should not retrieve an error \(error)") } } @@ -56,12 +56,12 @@ class UserTests: XCTestCase { let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/user", expectedHTTPMethod: "GET", response: json, statusCode: 401) let task = Octokit().me(session) { response in switch response { - case .Success: + case .success: XCTAssert(false, "should not retrieve user") - case .Failure(let error as NSError): + case .failure(let error as NSError): XCTAssertEqual(error.code, 401) XCTAssertEqual(error.domain, OctoKitErrorDomain) - case .Failure: + case .failure: XCTAssertTrue(false) } } From 6b52571e446ff2ab05db3a4ec0dd072e8ebf20a5 Mon Sep 17 00:00:00 2001 From: Ben Chatelain Date: Wed, 6 Jul 2016 13:38:18 -0600 Subject: [PATCH 084/302] Update URLSession.shared API --- OctoKit/Configuration.swift | 4 ++-- OctoKit/Follow.swift | 8 ++++---- OctoKit/Issue.swift | 8 ++++---- OctoKit/PublicKey.swift | 2 +- OctoKit/Repositories.swift | 4 ++-- OctoKit/Stars.swift | 4 ++-- OctoKit/User.swift | 4 ++-- 7 files changed, 17 insertions(+), 17 deletions(-) diff --git a/OctoKit/Configuration.swift b/OctoKit/Configuration.swift index e8aa2e5d..d7096d48 100644 --- a/OctoKit/Configuration.swift +++ b/OctoKit/Configuration.swift @@ -39,7 +39,7 @@ public struct OAuthConfiguration: Configuration { return OAuthRouter.authorize(self).URLRequest?.url } - public func authorize(_ session: RequestKitURLSession = URLSession.shared(), code: String, completion: (config: TokenConfiguration) -> Void) { + public func authorize(_ session: RequestKitURLSession = URLSession.shared, code: String, completion: (config: TokenConfiguration) -> Void) { let request = OAuthRouter.accessToken(self, code).URLRequest if let request = request { let task = session.dataTaskWithRequest(request) { data, response, err in @@ -61,7 +61,7 @@ public struct OAuthConfiguration: Configuration { } } - public func handleOpenURL(_ session: RequestKitURLSession = URLSession.shared(), url: URL, completion: (config: TokenConfiguration) -> Void) { + public func handleOpenURL(_ session: RequestKitURLSession = URLSession.shared, url: URL, completion: (config: TokenConfiguration) -> Void) { let urlString: String? = url.absoluteString if let code = urlString?.components(separatedBy: "=").last { authorize(session, code: code) { (config) in diff --git a/OctoKit/Follow.swift b/OctoKit/Follow.swift index ba477fcc..8da1f66f 100644 --- a/OctoKit/Follow.swift +++ b/OctoKit/Follow.swift @@ -8,7 +8,7 @@ public extension Octokit { - parameter session: RequestKitURLSession, defaults to NSURLSession.sharedSession() - parameter completion: Callback for the outcome of the fetch. */ - public func myFollowers(_ session: RequestKitURLSession = URLSession.shared(), completion: (response: Response<[User]>) -> Void) -> URLSessionDataTaskProtocol? { + public func myFollowers(_ session: RequestKitURLSession = URLSession.shared, completion: (response: Response<[User]>) -> Void) -> URLSessionDataTaskProtocol? { let router = FollowRouter.readAuthenticatedFollowers(configuration) return router.loadJSON(session, expectedResultType: [[String: AnyObject]].self) { json, error in if let error = error { @@ -28,7 +28,7 @@ public extension Octokit { - parameter name: Name of the user - parameter completion: Callback for the outcome of the fetch. */ - public func followers(_ session: RequestKitURLSession = URLSession.shared(), name: String, completion: (response: Response<[User]>) -> Void) -> URLSessionDataTaskProtocol? { + public func followers(_ session: RequestKitURLSession = URLSession.shared, name: String, completion: (response: Response<[User]>) -> Void) -> URLSessionDataTaskProtocol? { let router = FollowRouter.readFollowers(name, configuration) return router.loadJSON(session, expectedResultType: [[String: AnyObject]].self) { json, error in if let error = error { @@ -47,7 +47,7 @@ public extension Octokit { - parameter session: RequestKitURLSession, defaults to NSURLSession.sharedSession() - parameter completion: Callback for the outcome of the fetch. */ - public func myFollowing(_ session: RequestKitURLSession = URLSession.shared(), completion: (response: Response<[User]>) -> Void) -> URLSessionDataTaskProtocol? { + public func myFollowing(_ session: RequestKitURLSession = URLSession.shared, completion: (response: Response<[User]>) -> Void) -> URLSessionDataTaskProtocol? { let router = FollowRouter.readAuthenticatedFollowing(configuration) return router.loadJSON(session, expectedResultType: [[String: AnyObject]].self) { json, error in if let error = error { @@ -67,7 +67,7 @@ public extension Octokit { - parameter name: The name of the user - parameter completion: Callback for the outcome of the fetch. */ - public func following(_ session: RequestKitURLSession = URLSession.shared(), name: String, completion: (response: Response<[User]>) -> Void) -> URLSessionDataTaskProtocol? { + public func following(_ session: RequestKitURLSession = URLSession.shared, name: String, completion: (response: Response<[User]>) -> Void) -> URLSessionDataTaskProtocol? { let router = FollowRouter.readFollowing(name, configuration) return router.loadJSON(session, expectedResultType: [[String: AnyObject]].self) { json, error in if let error = error { diff --git a/OctoKit/Issue.swift b/OctoKit/Issue.swift index 2c67d9f8..ed2fc35a 100644 --- a/OctoKit/Issue.swift +++ b/OctoKit/Issue.swift @@ -85,7 +85,7 @@ public extension Octokit { - parameter perPage: Number of issues per page. `100` by default. - parameter completion: Callback for the outcome of the fetch. */ - public func myIssues(_ session: RequestKitURLSession = URLSession.shared(), page: String = "1", perPage: String = "100", completion: (response: Response<[Issue]>) -> Void) -> URLSessionDataTaskProtocol? { + public func myIssues(_ session: RequestKitURLSession = URLSession.shared, page: String = "1", perPage: String = "100", completion: (response: Response<[Issue]>) -> Void) -> URLSessionDataTaskProtocol? { let router = IssueRouter.readAuthenticatedIssues(configuration, page, perPage) return router.loadJSON(session, expectedResultType: [[String: AnyObject]].self) { json, error in if let error = error { @@ -107,7 +107,7 @@ public extension Octokit { - parameter number: The number of the issue. - parameter completion: Callback for the outcome of the fetch. */ - public func issue(_ session: RequestKitURLSession = URLSession.shared(), owner: String, repository: String, number: Int, completion: (response: Response) -> Void) -> URLSessionDataTaskProtocol? { + public func issue(_ session: RequestKitURLSession = URLSession.shared, owner: String, repository: String, number: Int, completion: (response: Response) -> Void) -> URLSessionDataTaskProtocol? { let router = IssueRouter.readIssue(configuration, owner, repository, number) return router.loadJSON(session, expectedResultType: [String: AnyObject].self) { json, error in if let error = error { @@ -131,7 +131,7 @@ public extension Octokit { - parameter assignee: The name of the user to assign the issue to. This parameter is ignored if the user lacks push access to the repository. - parameter completion: Callback for the issue that is created. */ - public func postIssue(_ session: RequestKitURLSession = URLSession.shared(), owner: String, repository: String, title: String, body: String? = nil, assignee: String? = nil, completion: (response:Response) -> Void) -> URLSessionDataTaskProtocol? { + public func postIssue(_ session: RequestKitURLSession = URLSession.shared, owner: String, repository: String, title: String, body: String? = nil, assignee: String? = nil, completion: (response:Response) -> Void) -> URLSessionDataTaskProtocol? { let router = IssueRouter.postIssue(configuration, owner, repository, title, body, assignee) return router.postJSON(session, expectedResultType: [String: AnyObject].self) { json, error in if let error = error { @@ -157,7 +157,7 @@ public extension Octokit { - parameter state: Whether the issue is open or closed. - parameter completion: Callback for the issue that is created. */ - public func patchIssue(_ session: RequestKitURLSession = URLSession.shared(), owner: String, repository: String, number: Int, title: String? = nil, body: String? = nil, assignee: String? = nil, state: Openness? = nil, completion: (response:Response) -> Void) -> URLSessionDataTaskProtocol? { + public func patchIssue(_ session: RequestKitURLSession = URLSession.shared, owner: String, repository: String, number: Int, title: String? = nil, body: String? = nil, assignee: String? = nil, state: Openness? = nil, completion: (response:Response) -> Void) -> URLSessionDataTaskProtocol? { let router = IssueRouter.patchIssue(configuration, owner, repository, number, title, body, assignee, state) return router.postJSON(session, expectedResultType: [String: AnyObject].self) { json, error in if let error = error { diff --git a/OctoKit/PublicKey.swift b/OctoKit/PublicKey.swift index 22f1d3af..0c000c9c 100644 --- a/OctoKit/PublicKey.swift +++ b/OctoKit/PublicKey.swift @@ -4,7 +4,7 @@ import RequestKit // MARK: request public extension Octokit { - public func postPublicKey(_ session: RequestKitURLSession = URLSession.shared(), publicKey: String, title: String, completion: (response:Response) -> Void) -> URLSessionDataTaskProtocol? { + public func postPublicKey(_ session: RequestKitURLSession = URLSession.shared, publicKey: String, title: String, completion: (response:Response) -> Void) -> URLSessionDataTaskProtocol? { let router = PublicKeyRouter.postPublicKey(publicKey, title, configuration) return router.postJSON(session, expectedResultType: [String: AnyObject].self) { json, error in if let error = error { diff --git a/OctoKit/Repositories.swift b/OctoKit/Repositories.swift index 8ecb2289..cd65055e 100644 --- a/OctoKit/Repositories.swift +++ b/OctoKit/Repositories.swift @@ -53,7 +53,7 @@ public extension Octokit { - parameter perPage: Number of repositories per page. `100` by default. - parameter completion: Callback for the outcome of the fetch. */ - public func repositories(_ session: RequestKitURLSession = URLSession.shared(), owner: String? = nil, page: String = "1", perPage: String = "100", completion: (response: Response<[Repository]>) -> Void) -> URLSessionDataTaskProtocol? { + public func repositories(_ session: RequestKitURLSession = URLSession.shared, owner: String? = nil, page: String = "1", perPage: String = "100", completion: (response: Response<[Repository]>) -> Void) -> URLSessionDataTaskProtocol? { let router = (owner != nil) ? RepositoryRouter.readRepositories(configuration, owner!, page, perPage) : RepositoryRouter.readAuthenticatedRepositories(configuration, page, perPage) @@ -76,7 +76,7 @@ public extension Octokit { - parameter name: The name of the repository to fetch. - parameter completion: Callback for the outcome of the fetch. */ - public func repository(_ session: RequestKitURLSession = URLSession.shared(), owner: String, name: String, completion: (response: Response) -> Void) -> URLSessionDataTaskProtocol? { + public func repository(_ session: RequestKitURLSession = URLSession.shared, owner: String, name: String, completion: (response: Response) -> Void) -> URLSessionDataTaskProtocol? { let router = RepositoryRouter.readRepository(configuration, owner, name) return router.loadJSON(session, expectedResultType: [String: AnyObject].self) { json, error in if let error = error { diff --git a/OctoKit/Stars.swift b/OctoKit/Stars.swift index 85559d28..7855614b 100644 --- a/OctoKit/Stars.swift +++ b/OctoKit/Stars.swift @@ -9,7 +9,7 @@ public extension Octokit { - parameter name: The user who starred repositories. - parameter completion: Callback for the outcome of the fetch. */ - public func stars(_ session: RequestKitURLSession = URLSession.shared(), name: String, completion: (response: Response<[Repository]>) -> Void) -> URLSessionDataTaskProtocol? { + public func stars(_ session: RequestKitURLSession = URLSession.shared, name: String, completion: (response: Response<[Repository]>) -> Void) -> URLSessionDataTaskProtocol? { let router = StarsRouter.readStars(name, configuration) return router.loadJSON(session, expectedResultType: [[String: AnyObject]].self) { json, error in if let error = error { @@ -28,7 +28,7 @@ public extension Octokit { - parameter session: RequestKitURLSession, defaults to NSURLSession.sharedSession() - parameter completion: Callback for the outcome of the fetch. */ - public func myStars(_ session: RequestKitURLSession = URLSession.shared(), completion: (response: Response<[Repository]>) -> Void) -> URLSessionDataTaskProtocol? { + public func myStars(_ session: RequestKitURLSession = URLSession.shared, completion: (response: Response<[Repository]>) -> Void) -> URLSessionDataTaskProtocol? { let router = StarsRouter.readAuthenticatedStars(configuration) return router.loadJSON(session, expectedResultType: [[String: AnyObject]].self) { json, error in if let error = error { diff --git a/OctoKit/User.swift b/OctoKit/User.swift index 6a3ccf33..55061168 100644 --- a/OctoKit/User.swift +++ b/OctoKit/User.swift @@ -49,7 +49,7 @@ public extension Octokit { - parameter name: The name of the user or organization. - parameter completion: Callback for the outcome of the fetch. */ - public func user(_ session: RequestKitURLSession = URLSession.shared(), name: String, completion: (response: Response) -> Void) -> URLSessionDataTaskProtocol? { + public func user(_ session: RequestKitURLSession = URLSession.shared, name: String, completion: (response: Response) -> Void) -> URLSessionDataTaskProtocol? { let router = UserRouter.readUser(name, self.configuration) return router.loadJSON(session, expectedResultType: [String: AnyObject].self) { json, error in if let error = error { @@ -68,7 +68,7 @@ public extension Octokit { - parameter session: RequestKitURLSession, defaults to NSURLSession.sharedSession() - parameter completion: Callback for the outcome of the fetch. */ - public func me(_ session: RequestKitURLSession = URLSession.shared(), completion: (response: Response) -> Void) -> URLSessionDataTaskProtocol? { + public func me(_ session: RequestKitURLSession = URLSession.shared, completion: (response: Response) -> Void) -> URLSessionDataTaskProtocol? { let router = UserRouter.readAuthenticatedUser(self.configuration) return router.loadJSON(session, expectedResultType: [String: AnyObject].self) { json, error in if let error = error { From 9c1e1a3e24ff6d52b51d6888bf1d8ff031034ffc Mon Sep 17 00:00:00 2001 From: Ben Chatelain Date: Thu, 14 Jul 2016 22:13:02 -0600 Subject: [PATCH 085/302] Update RequestKit Bringing in latest from swift-3.0 branch --- Cartfile.resolved | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cartfile.resolved b/Cartfile.resolved index 2a50ace7..6adac5ce 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1 +1 @@ -github "nerdishbynature/RequestKit" "0e745cee26410c6ea89cc3534b77dc1027648ec3" +github "nerdishbynature/RequestKit" "6d11b89887d094da85795bf9fa2fe8e86aee30a3" From c3d69174b17fd77c0dfb100c33c884554a7da15e Mon Sep 17 00:00:00 2001 From: Ben Chatelain Date: Sat, 17 Sep 2016 16:25:45 -0600 Subject: [PATCH 086/302] Set SWIFT_VERSION to 3.0 --- OctoKit.xcodeproj/project.pbxproj | 2 ++ 1 file changed, 2 insertions(+) diff --git a/OctoKit.xcodeproj/project.pbxproj b/OctoKit.xcodeproj/project.pbxproj index bd4592cc..7252ebdb 100644 --- a/OctoKit.xcodeproj/project.pbxproj +++ b/OctoKit.xcodeproj/project.pbxproj @@ -902,6 +902,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 3.0; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -929,6 +930,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + SWIFT_VERSION = 3.0; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; From 27117f4648ec0cb8b19633b69419eb986e90a8e8 Mon Sep 17 00:00:00 2001 From: Ben Chatelain Date: Sat, 17 Sep 2016 16:47:18 -0600 Subject: [PATCH 087/302] Update RequestKit from swift-3.0 branch --- Cartfile.resolved | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cartfile.resolved b/Cartfile.resolved index 6adac5ce..5aaa2651 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1 +1 @@ -github "nerdishbynature/RequestKit" "6d11b89887d094da85795bf9fa2fe8e86aee30a3" +github "nerdishbynature/RequestKit" "36ec7cdd0cc34e4f874989c813153cec62bf2e1c" From a1aa2094399e93684418f2b375de69f0dc514388 Mon Sep 17 00:00:00 2001 From: Ben Chatelain Date: Sat, 17 Sep 2016 16:51:09 -0600 Subject: [PATCH 088/302] Addressed Swift 3 and RequestKit API changes - Removed argument labels from function types to fix warnings - Function types cannot have argument label 'response'; use '_' instead - Added missing 'let' in conditionals - Updated Router.params to type [String: Any] --- OctoKit/Configuration.swift | 14 +++++++------- OctoKit/Follow.swift | 26 ++++++++++++------------- OctoKit/Issue.swift | 38 ++++++++++++++++++------------------- OctoKit/Label.swift | 4 ++-- OctoKit/Milestone.swift | 4 ++-- OctoKit/PublicKey.swift | 8 ++++---- OctoKit/Repositories.swift | 14 +++++++------- OctoKit/Stars.swift | 14 +++++++------- OctoKit/User.swift | 14 +++++++------- 9 files changed, 68 insertions(+), 68 deletions(-) diff --git a/OctoKit/Configuration.swift b/OctoKit/Configuration.swift index d7096d48..f8d62791 100644 --- a/OctoKit/Configuration.swift +++ b/OctoKit/Configuration.swift @@ -39,19 +39,19 @@ public struct OAuthConfiguration: Configuration { return OAuthRouter.authorize(self).URLRequest?.url } - public func authorize(_ session: RequestKitURLSession = URLSession.shared, code: String, completion: (config: TokenConfiguration) -> Void) { + public func authorize(_ session: RequestKitURLSession = URLSession.shared, code: String, completion: (_ config: TokenConfiguration) -> Void) { let request = OAuthRouter.accessToken(self, code).URLRequest if let request = request { - let task = session.dataTaskWithRequest(request) { data, response, err in + let task = session.dataTask(with: request) { data, response, err in if let response = response as? HTTPURLResponse { if response.statusCode != 200 { return } else { - if let data = data, string = NSString(data: data, encoding: String.Encoding.utf8.rawValue) as? String { + if let data = data, let string = NSString(data: data, encoding: String.Encoding.utf8.rawValue) as? String { let accessToken = self.accessTokenFromResponse(string) if let accessToken = accessToken { let config = TokenConfiguration(accessToken, url: self.apiEndpoint) - completion(config: config) + completion(config) } } } @@ -61,11 +61,11 @@ public struct OAuthConfiguration: Configuration { } } - public func handleOpenURL(_ session: RequestKitURLSession = URLSession.shared, url: URL, completion: (config: TokenConfiguration) -> Void) { + public func handleOpenURL(_ session: RequestKitURLSession = URLSession.shared, url: URL, completion: (_ config: TokenConfiguration) -> Void) { let urlString: String? = url.absoluteString if let code = urlString?.components(separatedBy: "=").last { authorize(session, code: code) { (config) in - completion(config: config) + completion(config) } } } @@ -117,7 +117,7 @@ enum OAuthRouter: Router { } } - var params: [String: AnyObject] { + var params: [String: Any] { switch self { case .authorize(let config): let scope = (config.scopes as NSArray).componentsJoined(by: ",") diff --git a/OctoKit/Follow.swift b/OctoKit/Follow.swift index 8da1f66f..855c95fb 100644 --- a/OctoKit/Follow.swift +++ b/OctoKit/Follow.swift @@ -8,15 +8,15 @@ public extension Octokit { - parameter session: RequestKitURLSession, defaults to NSURLSession.sharedSession() - parameter completion: Callback for the outcome of the fetch. */ - public func myFollowers(_ session: RequestKitURLSession = URLSession.shared, completion: (response: Response<[User]>) -> Void) -> URLSessionDataTaskProtocol? { + public func myFollowers(_ session: RequestKitURLSession = URLSession.shared, completion: (_ response: Response<[User]>) -> Void) -> URLSessionDataTaskProtocol? { let router = FollowRouter.readAuthenticatedFollowers(configuration) return router.loadJSON(session, expectedResultType: [[String: AnyObject]].self) { json, error in if let error = error { - completion(response: Response.failure(error)) + completion(Response.failure(error)) } else { if let json = json { let parsedUsers = json.map { User($0) } - completion(response: Response.success(parsedUsers)) + completion(Response.success(parsedUsers)) } } } @@ -28,15 +28,15 @@ public extension Octokit { - parameter name: Name of the user - parameter completion: Callback for the outcome of the fetch. */ - public func followers(_ session: RequestKitURLSession = URLSession.shared, name: String, completion: (response: Response<[User]>) -> Void) -> URLSessionDataTaskProtocol? { + public func followers(_ session: RequestKitURLSession = URLSession.shared, name: String, completion: (_ response: Response<[User]>) -> Void) -> URLSessionDataTaskProtocol? { let router = FollowRouter.readFollowers(name, configuration) return router.loadJSON(session, expectedResultType: [[String: AnyObject]].self) { json, error in if let error = error { - completion(response: Response.failure(error)) + completion(Response.failure(error)) } else { if let json = json { let parsedUsers = json.map { User($0) } - completion(response: Response.success(parsedUsers)) + completion(Response.success(parsedUsers)) } } } @@ -47,15 +47,15 @@ public extension Octokit { - parameter session: RequestKitURLSession, defaults to NSURLSession.sharedSession() - parameter completion: Callback for the outcome of the fetch. */ - public func myFollowing(_ session: RequestKitURLSession = URLSession.shared, completion: (response: Response<[User]>) -> Void) -> URLSessionDataTaskProtocol? { + public func myFollowing(_ session: RequestKitURLSession = URLSession.shared, completion: (_ response: Response<[User]>) -> Void) -> URLSessionDataTaskProtocol? { let router = FollowRouter.readAuthenticatedFollowing(configuration) return router.loadJSON(session, expectedResultType: [[String: AnyObject]].self) { json, error in if let error = error { - completion(response: Response.failure(error)) + completion(Response.failure(error)) } else { if let json = json { let parsedUsers = json.map { User($0) } - completion(response: .success(parsedUsers)) + completion(.success(parsedUsers)) } } } @@ -67,15 +67,15 @@ public extension Octokit { - parameter name: The name of the user - parameter completion: Callback for the outcome of the fetch. */ - public func following(_ session: RequestKitURLSession = URLSession.shared, name: String, completion: (response: Response<[User]>) -> Void) -> URLSessionDataTaskProtocol? { + public func following(_ session: RequestKitURLSession = URLSession.shared, name: String, completion: (_ response: Response<[User]>) -> Void) -> URLSessionDataTaskProtocol? { let router = FollowRouter.readFollowing(name, configuration) return router.loadJSON(session, expectedResultType: [[String: AnyObject]].self) { json, error in if let error = error { - completion(response: Response.failure(error)) + completion(Response.failure(error)) } else { if let json = json { let parsedUsers = json.map { User($0) } - completion(response: Response.success(parsedUsers)) + completion(Response.success(parsedUsers)) } } } @@ -118,7 +118,7 @@ enum FollowRouter: Router { } } - var params: [String: AnyObject] { + var params: [String: Any] { return [:] } } diff --git a/OctoKit/Issue.swift b/OctoKit/Issue.swift index ed2fc35a..8bf5b094 100644 --- a/OctoKit/Issue.swift +++ b/OctoKit/Issue.swift @@ -34,22 +34,22 @@ public enum Openness: String { public init(_ json: [String: AnyObject]) { if let id = json["id"] as? Int { self.id = id - if let urlString = json["url"] as? String, url = URL(string: urlString) { + if let urlString = json["url"] as? String, let url = URL(string: urlString) { self.url = url } - if let urlString = json["repository_url"] as? String, url = URL(string: urlString) { + if let urlString = json["repository_url"] as? String, let url = URL(string: urlString) { repositoryURL = url } - if let urlString = json["labels_url"] as? String, url = URL(string: urlString) { + if let urlString = json["labels_url"] as? String, let url = URL(string: urlString) { labelsURL = url } - if let urlString = json["comments_url"] as? String, url = URL(string: urlString) { + if let urlString = json["comments_url"] as? String, let url = URL(string: urlString) { commentsURL = url } - if let urlString = json["events_url"] as? String, url = URL(string: urlString) { + if let urlString = json["events_url"] as? String, let url = URL(string: urlString) { eventsURL = url } - if let urlString = json["html_url"] as? String, url = URL(string: urlString) { + if let urlString = json["html_url"] as? String, let url = URL(string: urlString) { htmlURL = url } number = json["number"] as? Int @@ -85,15 +85,15 @@ public extension Octokit { - parameter perPage: Number of issues per page. `100` by default. - parameter completion: Callback for the outcome of the fetch. */ - public func myIssues(_ session: RequestKitURLSession = URLSession.shared, page: String = "1", perPage: String = "100", completion: (response: Response<[Issue]>) -> Void) -> URLSessionDataTaskProtocol? { + public func myIssues(_ session: RequestKitURLSession = URLSession.shared, page: String = "1", perPage: String = "100", completion: (_ response: Response<[Issue]>) -> Void) -> URLSessionDataTaskProtocol? { let router = IssueRouter.readAuthenticatedIssues(configuration, page, perPage) return router.loadJSON(session, expectedResultType: [[String: AnyObject]].self) { json, error in if let error = error { - completion(response: Response.failure(error)) + completion(Response.failure(error)) } else { if let json = json { let parsedIssues = json.map { Issue($0) } - completion(response: Response.success(parsedIssues)) + completion(Response.success(parsedIssues)) } } } @@ -107,15 +107,15 @@ public extension Octokit { - parameter number: The number of the issue. - parameter completion: Callback for the outcome of the fetch. */ - public func issue(_ session: RequestKitURLSession = URLSession.shared, owner: String, repository: String, number: Int, completion: (response: Response) -> Void) -> URLSessionDataTaskProtocol? { + public func issue(_ session: RequestKitURLSession = URLSession.shared, owner: String, repository: String, number: Int, completion: (_ response: Response) -> Void) -> URLSessionDataTaskProtocol? { let router = IssueRouter.readIssue(configuration, owner, repository, number) return router.loadJSON(session, expectedResultType: [String: AnyObject].self) { json, error in if let error = error { - completion(response: Response.failure(error)) + completion(Response.failure(error)) } else { if let json = json { let issue = Issue(json) - completion(response: Response.success(issue)) + completion(Response.success(issue)) } } } @@ -131,15 +131,15 @@ public extension Octokit { - parameter assignee: The name of the user to assign the issue to. This parameter is ignored if the user lacks push access to the repository. - parameter completion: Callback for the issue that is created. */ - public func postIssue(_ session: RequestKitURLSession = URLSession.shared, owner: String, repository: String, title: String, body: String? = nil, assignee: String? = nil, completion: (response:Response) -> Void) -> URLSessionDataTaskProtocol? { + public func postIssue(_ session: RequestKitURLSession = URLSession.shared, owner: String, repository: String, title: String, body: String? = nil, assignee: String? = nil, completion: (_ response: Response) -> Void) -> URLSessionDataTaskProtocol? { let router = IssueRouter.postIssue(configuration, owner, repository, title, body, assignee) return router.postJSON(session, expectedResultType: [String: AnyObject].self) { json, error in if let error = error { - completion(response: Response.failure(error)) + completion(Response.failure(error)) } else { if let json = json { let issue = Issue(json) - completion(response: Response.success(issue)) + completion(Response.success(issue)) } } } @@ -157,15 +157,15 @@ public extension Octokit { - parameter state: Whether the issue is open or closed. - parameter completion: Callback for the issue that is created. */ - public func patchIssue(_ session: RequestKitURLSession = URLSession.shared, owner: String, repository: String, number: Int, title: String? = nil, body: String? = nil, assignee: String? = nil, state: Openness? = nil, completion: (response:Response) -> Void) -> URLSessionDataTaskProtocol? { + public func patchIssue(_ session: RequestKitURLSession = URLSession.shared, owner: String, repository: String, number: Int, title: String? = nil, body: String? = nil, assignee: String? = nil, state: Openness? = nil, completion: (_ response: Response) -> Void) -> URLSessionDataTaskProtocol? { let router = IssueRouter.patchIssue(configuration, owner, repository, number, title, body, assignee, state) return router.postJSON(session, expectedResultType: [String: AnyObject].self) { json, error in if let error = error { - completion(response: Response.failure(error)) + completion(Response.failure(error)) } else { if let json = json { let issue = Issue(json) - completion(response: Response.success(issue)) + completion(Response.success(issue)) } } } @@ -207,7 +207,7 @@ enum IssueRouter: JSONPostRouter { } } - var params: [String: AnyObject] { + var params: [String: Any] { switch self { case .readAuthenticatedIssues(_, let page, let perPage): return ["per_page": perPage, "page": page] diff --git a/OctoKit/Label.swift b/OctoKit/Label.swift index aaee234e..a360fbd1 100644 --- a/OctoKit/Label.swift +++ b/OctoKit/Label.swift @@ -14,7 +14,7 @@ extension Color { let green = Int(String(hexChars.prefix(2)), radix: 16) hexChars = hexChars.dropFirst(2) let blue = Int(String(hexChars), radix: 16) - if let red = red, green = green, blue = blue { + if let red = red, let green = green, let blue = blue { self.init(red: CGFloat(red) / 255.0, green: CGFloat(green) / 255.0, blue: CGFloat(blue) / 255.0, alpha: 1) } else { return nil @@ -32,7 +32,7 @@ extension Color { #endif public init(_ json: [String: AnyObject]) { - if let urlString = json["url"] as? String, url = URL(string: urlString) { + if let urlString = json["url"] as? String, let url = URL(string: urlString) { self.url = url } name = json["name"] as? String diff --git a/OctoKit/Milestone.swift b/OctoKit/Milestone.swift index 2b7c6c36..fe5d7da0 100644 --- a/OctoKit/Milestone.swift +++ b/OctoKit/Milestone.swift @@ -19,10 +19,10 @@ import Foundation public init?(_ json: [String: AnyObject]) { if let id = json["id"] as? Int { - if let urlString = json["html_url"] as? String, url = URL(string: urlString) { + if let urlString = json["html_url"] as? String, let url = URL(string: urlString) { htmlURL = url } - if let urlString = json["labels_url"] as? String, url = URL(string: urlString) { + if let urlString = json["labels_url"] as? String, let url = URL(string: urlString) { labelsURL = url } self.id = id diff --git a/OctoKit/PublicKey.swift b/OctoKit/PublicKey.swift index 0c000c9c..32b7d22f 100644 --- a/OctoKit/PublicKey.swift +++ b/OctoKit/PublicKey.swift @@ -4,14 +4,14 @@ import RequestKit // MARK: request public extension Octokit { - public func postPublicKey(_ session: RequestKitURLSession = URLSession.shared, publicKey: String, title: String, completion: (response:Response) -> Void) -> URLSessionDataTaskProtocol? { + public func postPublicKey(_ session: RequestKitURLSession = URLSession.shared, publicKey: String, title: String, completion: (_ response: Response) -> Void) -> URLSessionDataTaskProtocol? { let router = PublicKeyRouter.postPublicKey(publicKey, title, configuration) return router.postJSON(session, expectedResultType: [String: AnyObject].self) { json, error in if let error = error { - completion(response: Response.failure(error)) + completion(Response.failure(error)) } else { if let _ = json { - completion(response: Response.success(publicKey)) + completion(Response.success(publicKey)) } } } @@ -48,7 +48,7 @@ enum PublicKeyRouter: JSONPostRouter { } } - var params: [String: AnyObject] { + var params: [String: Any] { switch self { case .postPublicKey(let publicKey, let title, _): return ["title": title, "key": publicKey] diff --git a/OctoKit/Repositories.swift b/OctoKit/Repositories.swift index cd65055e..f00bdc76 100644 --- a/OctoKit/Repositories.swift +++ b/OctoKit/Repositories.swift @@ -53,18 +53,18 @@ public extension Octokit { - parameter perPage: Number of repositories per page. `100` by default. - parameter completion: Callback for the outcome of the fetch. */ - public func repositories(_ session: RequestKitURLSession = URLSession.shared, owner: String? = nil, page: String = "1", perPage: String = "100", completion: (response: Response<[Repository]>) -> Void) -> URLSessionDataTaskProtocol? { + public func repositories(_ session: RequestKitURLSession = URLSession.shared, owner: String? = nil, page: String = "1", perPage: String = "100", completion: (_ response: Response<[Repository]>) -> Void) -> URLSessionDataTaskProtocol? { let router = (owner != nil) ? RepositoryRouter.readRepositories(configuration, owner!, page, perPage) : RepositoryRouter.readAuthenticatedRepositories(configuration, page, perPage) return router.loadJSON(session, expectedResultType: [[String: AnyObject]].self) { json, error in if let error = error { - completion(response: Response.failure(error)) + completion(Response.failure(error)) } if let json = json { let repos = json.map { Repository($0) } - completion(response: Response.success(repos)) + completion(Response.success(repos)) } } } @@ -76,15 +76,15 @@ public extension Octokit { - parameter name: The name of the repository to fetch. - parameter completion: Callback for the outcome of the fetch. */ - public func repository(_ session: RequestKitURLSession = URLSession.shared, owner: String, name: String, completion: (response: Response) -> Void) -> URLSessionDataTaskProtocol? { + public func repository(_ session: RequestKitURLSession = URLSession.shared, owner: String, name: String, completion: (_ response: Response) -> Void) -> URLSessionDataTaskProtocol? { let router = RepositoryRouter.readRepository(configuration, owner, name) return router.loadJSON(session, expectedResultType: [String: AnyObject].self) { json, error in if let error = error { - completion(response: Response.failure(error)) + completion(Response.failure(error)) } else { if let json = json { let repo = Repository(json) - completion(response: Response.success(repo)) + completion(Response.success(repo)) } } } @@ -114,7 +114,7 @@ enum RepositoryRouter: Router { return .url } - var params: [String: AnyObject] { + var params: [String: Any] { switch self { case .readRepositories(_, _, let page, let perPage): return ["per_page": perPage, "page": page] diff --git a/OctoKit/Stars.swift b/OctoKit/Stars.swift index 7855614b..fdd2fc70 100644 --- a/OctoKit/Stars.swift +++ b/OctoKit/Stars.swift @@ -9,15 +9,15 @@ public extension Octokit { - parameter name: The user who starred repositories. - parameter completion: Callback for the outcome of the fetch. */ - public func stars(_ session: RequestKitURLSession = URLSession.shared, name: String, completion: (response: Response<[Repository]>) -> Void) -> URLSessionDataTaskProtocol? { + public func stars(_ session: RequestKitURLSession = URLSession.shared, name: String, completion: (_ response: Response<[Repository]>) -> Void) -> URLSessionDataTaskProtocol? { let router = StarsRouter.readStars(name, configuration) return router.loadJSON(session, expectedResultType: [[String: AnyObject]].self) { json, error in if let error = error { - completion(response: Response.failure(error)) + completion(Response.failure(error)) } else { if let json = json { let parsedStars = json.map { Repository($0) } - completion(response: Response.success(parsedStars)) + completion(Response.success(parsedStars)) } } } @@ -28,15 +28,15 @@ public extension Octokit { - parameter session: RequestKitURLSession, defaults to NSURLSession.sharedSession() - parameter completion: Callback for the outcome of the fetch. */ - public func myStars(_ session: RequestKitURLSession = URLSession.shared, completion: (response: Response<[Repository]>) -> Void) -> URLSessionDataTaskProtocol? { + public func myStars(_ session: RequestKitURLSession = URLSession.shared, completion: (_ response: Response<[Repository]>) -> Void) -> URLSessionDataTaskProtocol? { let router = StarsRouter.readAuthenticatedStars(configuration) return router.loadJSON(session, expectedResultType: [[String: AnyObject]].self) { json, error in if let error = error { - completion(response: Response.failure(error)) + completion(Response.failure(error)) } else { if let json = json { let parsedStars = json.map { Repository($0) } - completion(response: Response.success(parsedStars)) + completion(Response.success(parsedStars)) } } } @@ -70,7 +70,7 @@ enum StarsRouter: Router { } } - var params: [String: AnyObject] { + var params: [String: Any] { return [:] } } diff --git a/OctoKit/User.swift b/OctoKit/User.swift index 55061168..ea97f865 100644 --- a/OctoKit/User.swift +++ b/OctoKit/User.swift @@ -49,15 +49,15 @@ public extension Octokit { - parameter name: The name of the user or organization. - parameter completion: Callback for the outcome of the fetch. */ - public func user(_ session: RequestKitURLSession = URLSession.shared, name: String, completion: (response: Response) -> Void) -> URLSessionDataTaskProtocol? { + public func user(_ session: RequestKitURLSession = URLSession.shared, name: String, completion: (_ response: Response) -> Void) -> URLSessionDataTaskProtocol? { let router = UserRouter.readUser(name, self.configuration) return router.loadJSON(session, expectedResultType: [String: AnyObject].self) { json, error in if let error = error { - completion(response: Response.failure(error)) + completion(Response.failure(error)) } else { if let json = json { let parsedUser = User(json) - completion(response: Response.success(parsedUser)) + completion(Response.success(parsedUser)) } } } @@ -68,15 +68,15 @@ public extension Octokit { - parameter session: RequestKitURLSession, defaults to NSURLSession.sharedSession() - parameter completion: Callback for the outcome of the fetch. */ - public func me(_ session: RequestKitURLSession = URLSession.shared, completion: (response: Response) -> Void) -> URLSessionDataTaskProtocol? { + public func me(_ session: RequestKitURLSession = URLSession.shared, completion: (_ response: Response) -> Void) -> URLSessionDataTaskProtocol? { let router = UserRouter.readAuthenticatedUser(self.configuration) return router.loadJSON(session, expectedResultType: [String: AnyObject].self) { json, error in if let error = error { - completion(response: Response.failure(error)) + completion(Response.failure(error)) } else { if let json = json { let parsedUser = User(json) - completion(response: Response.success(parsedUser)) + completion(Response.success(parsedUser)) } } } @@ -113,7 +113,7 @@ enum UserRouter: Router { } } - var params: [String: AnyObject] { + var params: [String: Any] { return [:] } } From edd8bead27ec95fe8262183a3904d7d93aa25e61 Mon Sep 17 00:00:00 2001 From: Ben Chatelain Date: Sat, 17 Sep 2016 16:57:37 -0600 Subject: [PATCH 089/302] Annotated closures as @escaping to address warnings. > Closure use of non-escaping parameter 'completion' may allow it to escape --- OctoKit/Configuration.swift | 4 ++-- OctoKit/Follow.swift | 8 ++++---- OctoKit/Issue.swift | 8 ++++---- OctoKit/PublicKey.swift | 2 +- OctoKit/Repositories.swift | 4 ++-- OctoKit/Stars.swift | 4 ++-- OctoKit/User.swift | 4 ++-- 7 files changed, 17 insertions(+), 17 deletions(-) diff --git a/OctoKit/Configuration.swift b/OctoKit/Configuration.swift index f8d62791..d4f86e61 100644 --- a/OctoKit/Configuration.swift +++ b/OctoKit/Configuration.swift @@ -39,7 +39,7 @@ public struct OAuthConfiguration: Configuration { return OAuthRouter.authorize(self).URLRequest?.url } - public func authorize(_ session: RequestKitURLSession = URLSession.shared, code: String, completion: (_ config: TokenConfiguration) -> Void) { + public func authorize(_ session: RequestKitURLSession = URLSession.shared, code: String, completion: @escaping (_ config: TokenConfiguration) -> Void) { let request = OAuthRouter.accessToken(self, code).URLRequest if let request = request { let task = session.dataTask(with: request) { data, response, err in @@ -61,7 +61,7 @@ public struct OAuthConfiguration: Configuration { } } - public func handleOpenURL(_ session: RequestKitURLSession = URLSession.shared, url: URL, completion: (_ config: TokenConfiguration) -> Void) { + public func handleOpenURL(_ session: RequestKitURLSession = URLSession.shared, url: URL, completion: @escaping (_ config: TokenConfiguration) -> Void) { let urlString: String? = url.absoluteString if let code = urlString?.components(separatedBy: "=").last { authorize(session, code: code) { (config) in diff --git a/OctoKit/Follow.swift b/OctoKit/Follow.swift index 855c95fb..8090a7e1 100644 --- a/OctoKit/Follow.swift +++ b/OctoKit/Follow.swift @@ -8,7 +8,7 @@ public extension Octokit { - parameter session: RequestKitURLSession, defaults to NSURLSession.sharedSession() - parameter completion: Callback for the outcome of the fetch. */ - public func myFollowers(_ session: RequestKitURLSession = URLSession.shared, completion: (_ response: Response<[User]>) -> Void) -> URLSessionDataTaskProtocol? { + public func myFollowers(_ session: RequestKitURLSession = URLSession.shared, completion: @escaping (_ response: Response<[User]>) -> Void) -> URLSessionDataTaskProtocol? { let router = FollowRouter.readAuthenticatedFollowers(configuration) return router.loadJSON(session, expectedResultType: [[String: AnyObject]].self) { json, error in if let error = error { @@ -28,7 +28,7 @@ public extension Octokit { - parameter name: Name of the user - parameter completion: Callback for the outcome of the fetch. */ - public func followers(_ session: RequestKitURLSession = URLSession.shared, name: String, completion: (_ response: Response<[User]>) -> Void) -> URLSessionDataTaskProtocol? { + public func followers(_ session: RequestKitURLSession = URLSession.shared, name: String, completion: @escaping (_ response: Response<[User]>) -> Void) -> URLSessionDataTaskProtocol? { let router = FollowRouter.readFollowers(name, configuration) return router.loadJSON(session, expectedResultType: [[String: AnyObject]].self) { json, error in if let error = error { @@ -47,7 +47,7 @@ public extension Octokit { - parameter session: RequestKitURLSession, defaults to NSURLSession.sharedSession() - parameter completion: Callback for the outcome of the fetch. */ - public func myFollowing(_ session: RequestKitURLSession = URLSession.shared, completion: (_ response: Response<[User]>) -> Void) -> URLSessionDataTaskProtocol? { + public func myFollowing(_ session: RequestKitURLSession = URLSession.shared, completion: @escaping (_ response: Response<[User]>) -> Void) -> URLSessionDataTaskProtocol? { let router = FollowRouter.readAuthenticatedFollowing(configuration) return router.loadJSON(session, expectedResultType: [[String: AnyObject]].self) { json, error in if let error = error { @@ -67,7 +67,7 @@ public extension Octokit { - parameter name: The name of the user - parameter completion: Callback for the outcome of the fetch. */ - public func following(_ session: RequestKitURLSession = URLSession.shared, name: String, completion: (_ response: Response<[User]>) -> Void) -> URLSessionDataTaskProtocol? { + public func following(_ session: RequestKitURLSession = URLSession.shared, name: String, completion: @escaping (_ response: Response<[User]>) -> Void) -> URLSessionDataTaskProtocol? { let router = FollowRouter.readFollowing(name, configuration) return router.loadJSON(session, expectedResultType: [[String: AnyObject]].self) { json, error in if let error = error { diff --git a/OctoKit/Issue.swift b/OctoKit/Issue.swift index 8bf5b094..bd0ff9d5 100644 --- a/OctoKit/Issue.swift +++ b/OctoKit/Issue.swift @@ -85,7 +85,7 @@ public extension Octokit { - parameter perPage: Number of issues per page. `100` by default. - parameter completion: Callback for the outcome of the fetch. */ - public func myIssues(_ session: RequestKitURLSession = URLSession.shared, page: String = "1", perPage: String = "100", completion: (_ response: Response<[Issue]>) -> Void) -> URLSessionDataTaskProtocol? { + public func myIssues(_ session: RequestKitURLSession = URLSession.shared, page: String = "1", perPage: String = "100", completion: @escaping (_ response: Response<[Issue]>) -> Void) -> URLSessionDataTaskProtocol? { let router = IssueRouter.readAuthenticatedIssues(configuration, page, perPage) return router.loadJSON(session, expectedResultType: [[String: AnyObject]].self) { json, error in if let error = error { @@ -107,7 +107,7 @@ public extension Octokit { - parameter number: The number of the issue. - parameter completion: Callback for the outcome of the fetch. */ - public func issue(_ session: RequestKitURLSession = URLSession.shared, owner: String, repository: String, number: Int, completion: (_ response: Response) -> Void) -> URLSessionDataTaskProtocol? { + public func issue(_ session: RequestKitURLSession = URLSession.shared, owner: String, repository: String, number: Int, completion: @escaping (_ response: Response) -> Void) -> URLSessionDataTaskProtocol? { let router = IssueRouter.readIssue(configuration, owner, repository, number) return router.loadJSON(session, expectedResultType: [String: AnyObject].self) { json, error in if let error = error { @@ -131,7 +131,7 @@ public extension Octokit { - parameter assignee: The name of the user to assign the issue to. This parameter is ignored if the user lacks push access to the repository. - parameter completion: Callback for the issue that is created. */ - public func postIssue(_ session: RequestKitURLSession = URLSession.shared, owner: String, repository: String, title: String, body: String? = nil, assignee: String? = nil, completion: (_ response: Response) -> Void) -> URLSessionDataTaskProtocol? { + public func postIssue(_ session: RequestKitURLSession = URLSession.shared, owner: String, repository: String, title: String, body: String? = nil, assignee: String? = nil, completion: @escaping (_ response: Response) -> Void) -> URLSessionDataTaskProtocol? { let router = IssueRouter.postIssue(configuration, owner, repository, title, body, assignee) return router.postJSON(session, expectedResultType: [String: AnyObject].self) { json, error in if let error = error { @@ -157,7 +157,7 @@ public extension Octokit { - parameter state: Whether the issue is open or closed. - parameter completion: Callback for the issue that is created. */ - public func patchIssue(_ session: RequestKitURLSession = URLSession.shared, owner: String, repository: String, number: Int, title: String? = nil, body: String? = nil, assignee: String? = nil, state: Openness? = nil, completion: (_ response: Response) -> Void) -> URLSessionDataTaskProtocol? { + public func patchIssue(_ session: RequestKitURLSession = URLSession.shared, owner: String, repository: String, number: Int, title: String? = nil, body: String? = nil, assignee: String? = nil, state: Openness? = nil, completion: @escaping (_ response: Response) -> Void) -> URLSessionDataTaskProtocol? { let router = IssueRouter.patchIssue(configuration, owner, repository, number, title, body, assignee, state) return router.postJSON(session, expectedResultType: [String: AnyObject].self) { json, error in if let error = error { diff --git a/OctoKit/PublicKey.swift b/OctoKit/PublicKey.swift index 32b7d22f..1a1a364c 100644 --- a/OctoKit/PublicKey.swift +++ b/OctoKit/PublicKey.swift @@ -4,7 +4,7 @@ import RequestKit // MARK: request public extension Octokit { - public func postPublicKey(_ session: RequestKitURLSession = URLSession.shared, publicKey: String, title: String, completion: (_ response: Response) -> Void) -> URLSessionDataTaskProtocol? { + public func postPublicKey(_ session: RequestKitURLSession = URLSession.shared, publicKey: String, title: String, completion: @escaping (_ response: Response) -> Void) -> URLSessionDataTaskProtocol? { let router = PublicKeyRouter.postPublicKey(publicKey, title, configuration) return router.postJSON(session, expectedResultType: [String: AnyObject].self) { json, error in if let error = error { diff --git a/OctoKit/Repositories.swift b/OctoKit/Repositories.swift index f00bdc76..4c93ddeb 100644 --- a/OctoKit/Repositories.swift +++ b/OctoKit/Repositories.swift @@ -53,7 +53,7 @@ public extension Octokit { - parameter perPage: Number of repositories per page. `100` by default. - parameter completion: Callback for the outcome of the fetch. */ - public func repositories(_ session: RequestKitURLSession = URLSession.shared, owner: String? = nil, page: String = "1", perPage: String = "100", completion: (_ response: Response<[Repository]>) -> Void) -> URLSessionDataTaskProtocol? { + public func repositories(_ session: RequestKitURLSession = URLSession.shared, owner: String? = nil, page: String = "1", perPage: String = "100", completion: @escaping (_ response: Response<[Repository]>) -> Void) -> URLSessionDataTaskProtocol? { let router = (owner != nil) ? RepositoryRouter.readRepositories(configuration, owner!, page, perPage) : RepositoryRouter.readAuthenticatedRepositories(configuration, page, perPage) @@ -76,7 +76,7 @@ public extension Octokit { - parameter name: The name of the repository to fetch. - parameter completion: Callback for the outcome of the fetch. */ - public func repository(_ session: RequestKitURLSession = URLSession.shared, owner: String, name: String, completion: (_ response: Response) -> Void) -> URLSessionDataTaskProtocol? { + public func repository(_ session: RequestKitURLSession = URLSession.shared, owner: String, name: String, completion: @escaping (_ response: Response) -> Void) -> URLSessionDataTaskProtocol? { let router = RepositoryRouter.readRepository(configuration, owner, name) return router.loadJSON(session, expectedResultType: [String: AnyObject].self) { json, error in if let error = error { diff --git a/OctoKit/Stars.swift b/OctoKit/Stars.swift index fdd2fc70..bed3524d 100644 --- a/OctoKit/Stars.swift +++ b/OctoKit/Stars.swift @@ -9,7 +9,7 @@ public extension Octokit { - parameter name: The user who starred repositories. - parameter completion: Callback for the outcome of the fetch. */ - public func stars(_ session: RequestKitURLSession = URLSession.shared, name: String, completion: (_ response: Response<[Repository]>) -> Void) -> URLSessionDataTaskProtocol? { + public func stars(_ session: RequestKitURLSession = URLSession.shared, name: String, completion: @escaping (_ response: Response<[Repository]>) -> Void) -> URLSessionDataTaskProtocol? { let router = StarsRouter.readStars(name, configuration) return router.loadJSON(session, expectedResultType: [[String: AnyObject]].self) { json, error in if let error = error { @@ -28,7 +28,7 @@ public extension Octokit { - parameter session: RequestKitURLSession, defaults to NSURLSession.sharedSession() - parameter completion: Callback for the outcome of the fetch. */ - public func myStars(_ session: RequestKitURLSession = URLSession.shared, completion: (_ response: Response<[Repository]>) -> Void) -> URLSessionDataTaskProtocol? { + public func myStars(_ session: RequestKitURLSession = URLSession.shared, completion: @escaping (_ response: Response<[Repository]>) -> Void) -> URLSessionDataTaskProtocol? { let router = StarsRouter.readAuthenticatedStars(configuration) return router.loadJSON(session, expectedResultType: [[String: AnyObject]].self) { json, error in if let error = error { diff --git a/OctoKit/User.swift b/OctoKit/User.swift index ea97f865..cbc4504c 100644 --- a/OctoKit/User.swift +++ b/OctoKit/User.swift @@ -49,7 +49,7 @@ public extension Octokit { - parameter name: The name of the user or organization. - parameter completion: Callback for the outcome of the fetch. */ - public func user(_ session: RequestKitURLSession = URLSession.shared, name: String, completion: (_ response: Response) -> Void) -> URLSessionDataTaskProtocol? { + public func user(_ session: RequestKitURLSession = URLSession.shared, name: String, completion: @escaping (_ response: Response) -> Void) -> URLSessionDataTaskProtocol? { let router = UserRouter.readUser(name, self.configuration) return router.loadJSON(session, expectedResultType: [String: AnyObject].self) { json, error in if let error = error { @@ -68,7 +68,7 @@ public extension Octokit { - parameter session: RequestKitURLSession, defaults to NSURLSession.sharedSession() - parameter completion: Callback for the outcome of the fetch. */ - public func me(_ session: RequestKitURLSession = URLSession.shared, completion: (_ response: Response) -> Void) -> URLSessionDataTaskProtocol? { + public func me(_ session: RequestKitURLSession = URLSession.shared, completion: @escaping (_ response: Response) -> Void) -> URLSessionDataTaskProtocol? { let router = UserRouter.readAuthenticatedUser(self.configuration) return router.loadJSON(session, expectedResultType: [String: AnyObject].self) { json, error in if let error = error { From 09bacc481e09d97d6e5be2ed66ec6a3c121953a4 Mon Sep 17 00:00:00 2001 From: Ben Chatelain Date: Sat, 17 Sep 2016 16:58:29 -0600 Subject: [PATCH 090/302] Update Local and TimeZone APIs --- OctoKit/Time.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OctoKit/Time.swift b/OctoKit/Time.swift index 6b249cb5..cf54b944 100644 --- a/OctoKit/Time.swift +++ b/OctoKit/Time.swift @@ -11,8 +11,8 @@ struct Time { private static var rfc3339DateFormatter: DateFormatter = { let formatter = DateFormatter() formatter.dateFormat = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'" - formatter.locale = Locale(localeIdentifier: "en_US_POSIX") - formatter.timeZone = TimeZone(forSecondsFromGMT: 0) + formatter.locale = Locale(identifier: "en_US_POSIX") + formatter.timeZone = TimeZone(secondsFromGMT: 0) return formatter }() From ce95605e6dadeeabd6e8734086b5589142fc8965 Mon Sep 17 00:00:00 2001 From: Ben Chatelain Date: Sat, 17 Sep 2016 17:08:24 -0600 Subject: [PATCH 091/302] Update tests --- OctoKitTests/OctoKitURLTestSession.swift | 4 ++-- OctoKitTests/TestHelper.swift | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/OctoKitTests/OctoKitURLTestSession.swift b/OctoKitTests/OctoKitURLTestSession.swift index eaa2b77d..55ea6cca 100644 --- a/OctoKitTests/OctoKitURLTestSession.swift +++ b/OctoKitTests/OctoKitURLTestSession.swift @@ -34,7 +34,7 @@ class OctoKitURLTestSession: RequestKitURLSession { self.statusCode = statusCode } - func dataTaskWithRequest(_ request: URLRequest, completionHandler: (Data?, URLResponse?, NSError?) -> Void) -> URLSessionDataTaskProtocol { + func dataTask(with request: URLRequest, completionHandler: @escaping (Data?, URLResponse?, Error?) -> Void) -> URLSessionDataTaskProtocol { XCTAssertEqual(request.url?.absoluteString, expectedURL) XCTAssertEqual(request.httpMethod, expectedHTTPMethod) let data = responseString?.data(using: String.Encoding.utf8) @@ -44,7 +44,7 @@ class OctoKitURLTestSession: RequestKitURLSession { return MockURLSessionDataTask() } - func uploadTaskWithRequest(_ request: URLRequest, fromData bodyData: Data?, completionHandler: (Data?, URLResponse?, NSError?) -> Void) -> URLSessionDataTaskProtocol { + func uploadTask(with request: URLRequest, fromData bodyData: Data?, completionHandler: @escaping (Data?, URLResponse?, Error?) -> Void) -> URLSessionDataTaskProtocol { XCTAssertEqual(request.url?.absoluteString, expectedURL) XCTAssertEqual(request.httpMethod, expectedHTTPMethod) let data = responseString?.data(using: String.Encoding.utf8) diff --git a/OctoKitTests/TestHelper.swift b/OctoKitTests/TestHelper.swift index 8df7db39..71aa59e5 100644 --- a/OctoKitTests/TestHelper.swift +++ b/OctoKitTests/TestHelper.swift @@ -3,7 +3,7 @@ import Foundation internal class Helper { internal class func stringFromFile(_ name: String) -> String? { let bundle = Bundle(for: self) - let path = bundle.pathForResource(name, ofType: "json") + let path = bundle.path(forResource: name, ofType: "json") if let path = path { let string = try? String(contentsOfFile: path, encoding: String.Encoding.utf8) return string @@ -11,11 +11,11 @@ internal class Helper { return nil } - internal class func JSONFromFile(_ name: String) -> AnyObject { + internal class func JSONFromFile(_ name: String) -> Any { let bundle = Bundle(for: self) - let path = bundle.pathForResource(name, ofType: "json")! + let path = bundle.path(forResource: name, ofType: "json")! let data = try! Data(contentsOf: URL(fileURLWithPath: path)) - let dict: AnyObject? = try? JSONSerialization.jsonObject(with: data, + let dict: Any? = try? JSONSerialization.jsonObject(with: data, options: JSONSerialization.ReadingOptions.mutableContainers) return dict! } From 6b63e1a59118b1d13903e38ef5db65c82a4380b9 Mon Sep 17 00:00:00 2001 From: Piet Brauer Date: Tue, 20 Sep 2016 09:23:08 +0200 Subject: [PATCH 092/302] Set Legacy Swift version project wide --- OctoKit.xcodeproj/project.pbxproj | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/OctoKit.xcodeproj/project.pbxproj b/OctoKit.xcodeproj/project.pbxproj index 7252ebdb..bd1e7883 100644 --- a/OctoKit.xcodeproj/project.pbxproj +++ b/OctoKit.xcodeproj/project.pbxproj @@ -902,7 +902,6 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 3.0; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -930,7 +929,6 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 3.0; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -1223,7 +1221,7 @@ PRODUCT_NAME = OctoKit; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 2.3; + SWIFT_VERSION = 3.0; }; name = Debug; }; @@ -1262,7 +1260,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.nerdishbynature.OctoKit; PRODUCT_NAME = OctoKit; SDKROOT = iphoneos; - SWIFT_VERSION = 2.3; + SWIFT_VERSION = 3.0; VALIDATE_PRODUCT = YES; }; name = Release; From 308b76848042f7bfafb37d07691afd11cb3a931f Mon Sep 17 00:00:00 2001 From: Piet Brauer Date: Tue, 20 Sep 2016 15:27:26 +0200 Subject: [PATCH 093/302] Update RequestKit --- Cartfile | 2 +- Cartfile.resolved | 2 +- OctoKit.swift.podspec | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cartfile b/Cartfile index 9cbb48a8..d1915c36 100644 --- a/Cartfile +++ b/Cartfile @@ -1 +1 @@ -github "nerdishbynature/RequestKit" "swift-3.0" +github "nerdishbynature/RequestKit" ~>2.0 diff --git a/Cartfile.resolved b/Cartfile.resolved index 5aaa2651..490733e3 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1 +1 @@ -github "nerdishbynature/RequestKit" "36ec7cdd0cc34e4f874989c813153cec62bf2e1c" +github "nerdishbynature/RequestKit" "2.0.0" diff --git a/OctoKit.swift.podspec b/OctoKit.swift.podspec index ef7deb53..29df7167 100644 --- a/OctoKit.swift.podspec +++ b/OctoKit.swift.podspec @@ -12,7 +12,7 @@ Pod::Spec.new do |s| s.source = { :git => "https://github.com/nerdishbynature/octokit.swift.git", :tag => s.version.to_s } s.social_media_url = "https://twitter.com/pietbrauer" s.module_name = "Octokit" - s.dependency "NBNRequestKit", "~> 1.1.0" + s.dependency "NBNRequestKit", "~> 2.0" s.requires_arc = true s.source_files = "OctoKit/*.swift" s.ios.deployment_target = '8.0' From c525e197193947bfed69640a2dd23569f867d3b8 Mon Sep 17 00:00:00 2001 From: Piet Brauer Date: Tue, 20 Sep 2016 15:48:27 +0200 Subject: [PATCH 094/302] Add swift version file --- .swift-version | 1 + 1 file changed, 1 insertion(+) create mode 100644 .swift-version diff --git a/.swift-version b/.swift-version new file mode 100644 index 00000000..9f55b2cc --- /dev/null +++ b/.swift-version @@ -0,0 +1 @@ +3.0 From dfb68af56a50c996a852e450e12f9c2f1dd0792e Mon Sep 17 00:00:00 2001 From: Piet Brauer Date: Tue, 20 Sep 2016 16:30:58 +0200 Subject: [PATCH 095/302] Bump version --- OctoKit.swift.podspec | 2 +- OctoKit/Info.plist | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/OctoKit.swift.podspec b/OctoKit.swift.podspec index 29df7167..fdca2b25 100644 --- a/OctoKit.swift.podspec +++ b/OctoKit.swift.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "OctoKit.swift" - s.version = "0.6.2" + s.version = "0.7.0" s.summary = "A Swift API Client for GitHub and GitHub Enterprise" s.description = <<-DESC You are looking at the A Swift API Client for GitHub and GitHub Enterprise. diff --git a/OctoKit/Info.plist b/OctoKit/Info.plist index 6f21e11d..3157e479 100644 --- a/OctoKit/Info.plist +++ b/OctoKit/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 0.6.2 + 0.7.0 CFBundleSignature ???? CFBundleVersion From 9fb90f32641f49c97283eccd9d3d8bf5307fcdf9 Mon Sep 17 00:00:00 2001 From: ambientlight Date: Sun, 4 Dec 2016 00:35:09 +0800 Subject: [PATCH 096/302] Added support to retrieve all issue for repository, issue state parameter added to issues retrieval API --- OctoKit/Issue.swift | 51 ++++++++++++++++++++++++++++++++++++++------- 1 file changed, 44 insertions(+), 7 deletions(-) diff --git a/OctoKit/Issue.swift b/OctoKit/Issue.swift index bd0ff9d5..3097056a 100644 --- a/OctoKit/Issue.swift +++ b/OctoKit/Issue.swift @@ -8,6 +8,12 @@ public enum Openness: String { case Closed = "closed" } +public enum State: String { + case Open = "open" + case Closed = "closed" + case All = "all" +} + @objc public class Issue: NSObject { public var id: Int public var url: URL? @@ -81,12 +87,13 @@ public extension Octokit { /** Fetches the issues of the authenticated user - parameter session: RequestKitURLSession, defaults to NSURLSession.sharedSession() + - parameter state: Issue state. Defaults to open if not specified. - parameter page: Current page for issue pagination. `1` by default. - parameter perPage: Number of issues per page. `100` by default. - parameter completion: Callback for the outcome of the fetch. */ - public func myIssues(_ session: RequestKitURLSession = URLSession.shared, page: String = "1", perPage: String = "100", completion: @escaping (_ response: Response<[Issue]>) -> Void) -> URLSessionDataTaskProtocol? { - let router = IssueRouter.readAuthenticatedIssues(configuration, page, perPage) + public func myIssues(_ session: RequestKitURLSession = URLSession.shared, state: State? = nil, page: String = "1", perPage: String = "100", completion: @escaping (_ response: Response<[Issue]>) -> Void) -> URLSessionDataTaskProtocol? { + let router = IssueRouter.readAuthenticatedIssues(configuration, page, perPage, state) return router.loadJSON(session, expectedResultType: [[String: AnyObject]].self) { json, error in if let error = error { completion(Response.failure(error)) @@ -120,7 +127,31 @@ public extension Octokit { } } } - + + /** + Fetches all issues in a repository + - parameter session: RequestKitURLSession, defaults to NSURLSession.sharedSession() + - parameter owner: The user or organization that owns the repository. + - parameter repository: The name of the repository. + - parameter state: Issue state. Defaults to open if not specified. + - parameter page: Current page for issue pagination. `1` by default. + - parameter perPage: Number of issues per page. `100` by default. + - parameter completion: Callback for the outcome of the fetch. + */ + public func issues(_ session: RequestKitURLSession = URLSession.shared, owner: String, repository: String, state: State? = nil, page: String = "1", perPage: String = "100", completion: @escaping (_ response: Response<[Issue]>) -> Void) -> URLSessionDataTaskProtocol? { + let router = IssueRouter.readIssues(configuration, owner, repository, page, perPage, state) + return router.loadJSON(session, expectedResultType: [[String: AnyObject]].self) { json, error in + if let error = error { + completion(Response.failure(error)) + } else { + if let json = json { + let parsedIssues = json.map { Issue($0) } + completion(Response.success(parsedIssues)) + } + } + } + } + /** Creates an issue in a repository. - parameter session: RequestKitURLSession, defaults to NSURLSession.sharedSession() @@ -175,8 +206,9 @@ public extension Octokit { // MARK: Router enum IssueRouter: JSONPostRouter { - case readAuthenticatedIssues(Configuration, String, String) + case readAuthenticatedIssues(Configuration, String, String, State?) case readIssue(Configuration, String, String, Int) + case readIssues(Configuration, String, String, String, String, State?) case postIssue(Configuration, String, String, String, String?, String?) case patchIssue(Configuration, String, String, Int, String?, String?, String?, Openness?) @@ -200,8 +232,9 @@ enum IssueRouter: JSONPostRouter { var configuration: Configuration { switch self { - case .readAuthenticatedIssues(let config, _, _): return config + case .readAuthenticatedIssues(let config, _, _, _): return config case .readIssue(let config, _, _, _): return config + case .readIssues(let config, _, _, _, _, _): return config case .postIssue(let config, _, _, _, _, _): return config case .patchIssue(let config, _, _, _, _, _, _, _): return config } @@ -209,10 +242,12 @@ enum IssueRouter: JSONPostRouter { var params: [String: Any] { switch self { - case .readAuthenticatedIssues(_, let page, let perPage): - return ["per_page": perPage, "page": page] + case .readAuthenticatedIssues(_, let page, let perPage, let state): + return ["per_page": perPage, "page": page, "state": state?.rawValue ?? State.Open.rawValue] case .readIssue: return [:] + case .readIssues(_, _, _, let page, let perPage, let state): + return ["per_page": perPage, "page": page, "state": state?.rawValue ?? State.Open.rawValue] case .postIssue(_, _, _, let title, let body, let assignee): var params = ["title": title] if let body = body { @@ -246,6 +281,8 @@ enum IssueRouter: JSONPostRouter { return "issues" case .readIssue(_, let owner, let repository, let number): return "repos/\(owner)/\(repository)/issues/\(number)" + case .readIssues(_, let owner, let repository, _, _, _): + return "repos/\(owner)/\(repository)/issues" case .postIssue(_, let owner, let repository, _, _, _): return "repos/\(owner)/\(repository)/issues" case .patchIssue(_, let owner, let repository, let number, _, _, _, _): From 8b740a79e8b877f555463de4d7f5254f65ed65b8 Mon Sep 17 00:00:00 2001 From: ambientlight Date: Mon, 5 Dec 2016 19:52:37 +0800 Subject: [PATCH 097/302] Openness preferred instead of separate State enum, state parameter changed to non-optional defaulting to .open, removed NS prefix in methods doc-comments, IssuesTests modified to reflect API additions --- OctoKit/Issue.swift | 27 +++++++++++---------------- OctoKitTests/IssueTests.swift | 2 +- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/OctoKit/Issue.swift b/OctoKit/Issue.swift index 3097056a..4bcee43d 100644 --- a/OctoKit/Issue.swift +++ b/OctoKit/Issue.swift @@ -6,11 +6,6 @@ import RequestKit public enum Openness: String { case Open = "open" case Closed = "closed" -} - -public enum State: String { - case Open = "open" - case Closed = "closed" case All = "all" } @@ -86,13 +81,13 @@ public extension Octokit { /** Fetches the issues of the authenticated user - - parameter session: RequestKitURLSession, defaults to NSURLSession.sharedSession() + - parameter session: RequestKitURLSession, defaults to URLSession.sharedSession() - parameter state: Issue state. Defaults to open if not specified. - parameter page: Current page for issue pagination. `1` by default. - parameter perPage: Number of issues per page. `100` by default. - parameter completion: Callback for the outcome of the fetch. */ - public func myIssues(_ session: RequestKitURLSession = URLSession.shared, state: State? = nil, page: String = "1", perPage: String = "100", completion: @escaping (_ response: Response<[Issue]>) -> Void) -> URLSessionDataTaskProtocol? { + public func myIssues(_ session: RequestKitURLSession = URLSession.shared, state: Openness = .Open, page: String = "1", perPage: String = "100", completion: @escaping (_ response: Response<[Issue]>) -> Void) -> URLSessionDataTaskProtocol? { let router = IssueRouter.readAuthenticatedIssues(configuration, page, perPage, state) return router.loadJSON(session, expectedResultType: [[String: AnyObject]].self) { json, error in if let error = error { @@ -108,7 +103,7 @@ public extension Octokit { /** Fetches an issue in a repository - - parameter session: RequestKitURLSession, defaults to NSURLSession.sharedSession() + - parameter session: RequestKitURLSession, defaults to URLSession.sharedSession() - parameter owner: The user or organization that owns the repository. - parameter repository: The name of the repository. - parameter number: The number of the issue. @@ -130,7 +125,7 @@ public extension Octokit { /** Fetches all issues in a repository - - parameter session: RequestKitURLSession, defaults to NSURLSession.sharedSession() + - parameter session: RequestKitURLSession, defaults to URLSession.sharedSession() - parameter owner: The user or organization that owns the repository. - parameter repository: The name of the repository. - parameter state: Issue state. Defaults to open if not specified. @@ -138,7 +133,7 @@ public extension Octokit { - parameter perPage: Number of issues per page. `100` by default. - parameter completion: Callback for the outcome of the fetch. */ - public func issues(_ session: RequestKitURLSession = URLSession.shared, owner: String, repository: String, state: State? = nil, page: String = "1", perPage: String = "100", completion: @escaping (_ response: Response<[Issue]>) -> Void) -> URLSessionDataTaskProtocol? { + public func issues(_ session: RequestKitURLSession = URLSession.shared, owner: String, repository: String, state: Openness = .Open, page: String = "1", perPage: String = "100", completion: @escaping (_ response: Response<[Issue]>) -> Void) -> URLSessionDataTaskProtocol? { let router = IssueRouter.readIssues(configuration, owner, repository, page, perPage, state) return router.loadJSON(session, expectedResultType: [[String: AnyObject]].self) { json, error in if let error = error { @@ -154,7 +149,7 @@ public extension Octokit { /** Creates an issue in a repository. - - parameter session: RequestKitURLSession, defaults to NSURLSession.sharedSession() + - parameter session: RequestKitURLSession, defaults to URLSession.sharedSession() - parameter owner: The user or organization that owns the repository. - parameter repository: The name of the repository. - parameter title: The title of the issue. @@ -178,7 +173,7 @@ public extension Octokit { /** Edits an issue in a repository. - - parameter session: RequestKitURLSession, defaults to NSURLSession.sharedSession() + - parameter session: RequestKitURLSession, defaults to URLSession.sharedSession() - parameter owner: The user or organization that owns the repository. - parameter repository: The name of the repository. - parameter number: The number of the issue. @@ -206,9 +201,9 @@ public extension Octokit { // MARK: Router enum IssueRouter: JSONPostRouter { - case readAuthenticatedIssues(Configuration, String, String, State?) + case readAuthenticatedIssues(Configuration, String, String, Openness) case readIssue(Configuration, String, String, Int) - case readIssues(Configuration, String, String, String, String, State?) + case readIssues(Configuration, String, String, String, String, Openness) case postIssue(Configuration, String, String, String, String?, String?) case patchIssue(Configuration, String, String, Int, String?, String?, String?, Openness?) @@ -243,11 +238,11 @@ enum IssueRouter: JSONPostRouter { var params: [String: Any] { switch self { case .readAuthenticatedIssues(_, let page, let perPage, let state): - return ["per_page": perPage, "page": page, "state": state?.rawValue ?? State.Open.rawValue] + return ["per_page": perPage, "page": page, "state": state.rawValue] case .readIssue: return [:] case .readIssues(_, _, _, let page, let perPage, let state): - return ["per_page": perPage, "page": page, "state": state?.rawValue ?? State.Open.rawValue] + return ["per_page": perPage, "page": page, "state": state.rawValue] case .postIssue(_, _, _, let title, let body, let assignee): var params = ["title": title] if let body = body { diff --git a/OctoKitTests/IssueTests.swift b/OctoKitTests/IssueTests.swift index 2a5923ae..8ec2bfd8 100644 --- a/OctoKitTests/IssueTests.swift +++ b/OctoKitTests/IssueTests.swift @@ -6,7 +6,7 @@ class IssueTests: XCTestCase { func testGetMyIssues() { let config = TokenConfiguration("12345") - let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/issues?access_token=12345&page=1&per_page=100", expectedHTTPMethod: "GET", jsonFile: "issues", statusCode: 200) + let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/issues?access_token=12345&page=1&per_page=100&state=open", expectedHTTPMethod: "GET", jsonFile: "issues", statusCode: 200) let task = Octokit(config).myIssues(session) { response in switch response { case .success(let issues): From 1d11c01d200c3f961ce4034b5fb546c3c12729f9 Mon Sep 17 00:00:00 2001 From: Piet Brauer Date: Thu, 6 Oct 2016 12:38:38 +0200 Subject: [PATCH 098/302] Remove slash from path to make URL composition work --- OctoKit/Repositories.swift | 6 ++-- OctoKitTests/RepositoryTests.swift | 47 ++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 3 deletions(-) diff --git a/OctoKit/Repositories.swift b/OctoKit/Repositories.swift index 4c93ddeb..98036d08 100644 --- a/OctoKit/Repositories.swift +++ b/OctoKit/Repositories.swift @@ -128,11 +128,11 @@ enum RepositoryRouter: Router { var path: String { switch self { case .readRepositories(_, let owner, _, _): - return "/users/\(owner)/repos" + return "users/\(owner)/repos" case .readAuthenticatedRepositories: - return "/user/repos" + return "user/repos" case .readRepository(_, let owner, let name): - return "/repos/\(owner)/\(name)" + return "repos/\(owner)/\(name)" } } } diff --git a/OctoKitTests/RepositoryTests.swift b/OctoKitTests/RepositoryTests.swift index bcee0d82..393a526c 100644 --- a/OctoKitTests/RepositoryTests.swift +++ b/OctoKitTests/RepositoryTests.swift @@ -18,6 +18,21 @@ class RepositoryTests: XCTestCase { XCTAssertTrue(session.wasCalled) } + func testGetRepositoriesEnterprise() { + let config = TokenConfiguration(url: "https://enterprise.nerdishbynature.com/api/v3/") + let session = OctoKitURLTestSession(expectedURL: "https://enterprise.nerdishbynature.com/api/v3/users/octocat/repos?page=1&per_page=100", expectedHTTPMethod: "GET", jsonFile: "user_repos", statusCode: 200) + let task = Octokit(config).repositories(session, owner: "octocat") { response in + switch response { + case .success(let repositories): + XCTAssertEqual(repositories.count, 1) + case .failure: + XCTAssert(false, "should not get an error") + } + } + XCTAssertNotNil(task) + XCTAssertTrue(session.wasCalled) + } + func testGetAuthenticatedRepositories() { let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/user/repos?access_token=12345&page=1&per_page=100", expectedHTTPMethod: "GET", jsonFile: "user_repos", statusCode: 200) let config = TokenConfiguration("12345") @@ -33,6 +48,21 @@ class RepositoryTests: XCTestCase { XCTAssertTrue(session.wasCalled) } + func testGetAuthenticatedRepositoriesEnterprise() { + let session = OctoKitURLTestSession(expectedURL: "https://enterprise.nerdishbynature.com/api/v3/user/repos?access_token=12345&page=1&per_page=100", expectedHTTPMethod: "GET", jsonFile: "user_repos", statusCode: 200) + let config = TokenConfiguration("12345", url: "https://enterprise.nerdishbynature.com/api/v3/") + let task = Octokit(config).repositories(session) { response in + switch response { + case .success(let repositories): + XCTAssertEqual(repositories.count, 1) + case .failure: + XCTAssert(false, "should not get an error") + } + } + XCTAssertNotNil(task) + XCTAssertTrue(session.wasCalled) + } + func testFailToGetRepositories() { let json = "{\"message\":\"Bad credentials\",\"documentation_url\":\"https://developer.github.com/v3\"}" let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/user/repos?access_token=12345&page=1&per_page=100", expectedHTTPMethod: "GET", response: json, statusCode: 401) @@ -68,6 +98,23 @@ class RepositoryTests: XCTestCase { XCTAssertTrue(session.wasCalled) } + func testGetRepositoryEnterprise() { + let config = TokenConfiguration(url: "https://enterprise.nerdishbynature.com/api/v3/") + let (owner, name) = ("mietzmithut", "Test") + let session = OctoKitURLTestSession(expectedURL: "https://enterprise.nerdishbynature.com/api/v3/repos/mietzmithut/Test", expectedHTTPMethod: "GET", jsonFile: "repo", statusCode: 200) + let task = Octokit(config).repository(session, owner: owner, name: name) { response in + switch response { + case .success(let repo): + XCTAssertEqual(repo.name, name) + XCTAssertEqual(repo.owner.login, owner) + case .failure: + XCTAssert(false, "should not get an error") + } + } + XCTAssertNotNil(task) + XCTAssertTrue(session.wasCalled) + } + func testFailToGetRepository() { let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/repos/mietzmithut/Test", expectedHTTPMethod: "GET", jsonFile: nil, statusCode: 404) let (owner, name) = ("mietzmithut", "Test") From 99785c6d735d2b92ffb72ec8c5f48fe80b799fad Mon Sep 17 00:00:00 2001 From: Piet Brauer Date: Wed, 18 Jan 2017 09:55:50 +0100 Subject: [PATCH 099/302] Build in Xcode 8.2 --- .travis.yml | 10 +- Cartfile.resolved | 2 +- Gemfile.lock | 271 ++++++++++++++---------------------------- fastlane/.env.default | 5 +- fastlane/.env.ios93 | 5 +- fastlane/.env.osx | 3 +- fastlane/.env.tvos92 | 4 +- 7 files changed, 104 insertions(+), 196 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7f041133..5275ec86 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ language: objective-c -osx_image: xcode8 +osx_image: xcode8.2 sudo: false env: global: @@ -8,13 +8,13 @@ env: - FASTLANE_LANE=ci_commit matrix: include: - - osx_image: xcode8 + - osx_image: xcode8.2 env: FASTLANE_LANE=code_coverage FASTLANE_ENV=default - - osx_image: xcode8 + - osx_image: xcode8.2 env: FASTLANE_ENV=ios93 - - osx_image: xcode8 + - osx_image: xcode8.2 env: FASTLANE_ENV=tvos92 - - osx_image: xcode8 + - osx_image: xcode8.2 env: FASTLANE_ENV=osx before_install: - make install diff --git a/Cartfile.resolved b/Cartfile.resolved index 490733e3..c7b9648a 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1 +1 @@ -github "nerdishbynature/RequestKit" "2.0.0" +github "nerdishbynature/RequestKit" "2.0.1" diff --git a/Gemfile.lock b/Gemfile.lock index d0ac2ac9..8086d1b5 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,126 +1,102 @@ GEM remote: https://rubygems.org/ specs: + CFPropertyList (2.3.4) activesupport (4.2.7.1) i18n (~> 0.7) json (~> 1.7, >= 1.7.7) minitest (~> 5.1) thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) - addressable (2.4.0) + addressable (2.5.0) + public_suffix (~> 2.0, >= 2.0.2) babosa (1.0.2) - cert (1.4.2) - fastlane_core (>= 0.50.3, < 1.0.0) - spaceship (>= 0.32.0, < 1.0.0) - claide (0.9.1) + claide (1.0.1) clamp (0.6.5) - cocoapods (0.39.0) - activesupport (>= 4.0.2) - claide (~> 0.9.1) - cocoapods-core (= 0.39.0) - cocoapods-downloader (~> 0.9.3) - cocoapods-plugins (~> 0.4.2) - cocoapods-search (~> 0.1.0) - cocoapods-stats (~> 0.6.2) - cocoapods-trunk (~> 0.6.4) - cocoapods-try (~> 0.5.1) + cocoapods (1.1.1) + activesupport (>= 4.0.2, < 5) + claide (>= 1.0.1, < 2.0) + cocoapods-core (= 1.1.1) + cocoapods-deintegrate (>= 1.0.1, < 2.0) + cocoapods-downloader (>= 1.1.2, < 2.0) + cocoapods-plugins (>= 1.0.0, < 2.0) + cocoapods-search (>= 1.0.0, < 2.0) + cocoapods-stats (>= 1.0.0, < 2.0) + cocoapods-trunk (>= 1.1.1, < 2.0) + cocoapods-try (>= 1.1.0, < 2.0) colored (~> 1.2) escape (~> 0.0.4) - molinillo (~> 0.4.0) + fourflusher (~> 2.0.1) + gh_inspector (~> 1.0) + molinillo (~> 0.5.1) nap (~> 1.0) - xcodeproj (~> 0.28.2) - cocoapods-core (0.39.0) - activesupport (>= 4.0.2) + xcodeproj (>= 1.3.3, < 2.0) + cocoapods-core (1.1.1) + activesupport (>= 4.0.2, < 5) fuzzy_match (~> 2.0.4) nap (~> 1.0) - cocoapods-downloader (0.9.3) - cocoapods-plugins (0.4.2) + cocoapods-deintegrate (1.0.1) + cocoapods-downloader (1.1.3) + cocoapods-plugins (1.0.0) nap - cocoapods-search (0.1.0) - cocoapods-stats (0.6.2) - cocoapods-trunk (0.6.4) + cocoapods-search (1.0.0) + cocoapods-stats (1.0.0) + cocoapods-trunk (1.1.2) nap (>= 0.8, < 2.0) netrc (= 0.7.8) - cocoapods-try (0.5.1) + cocoapods-try (1.1.0) colored (1.2) - commander (4.4.0) + commander (4.4.3) highline (~> 1.7.2) - credentials_manager (0.16.0) - colored - commander (>= 4.3.5) - highline (>= 1.7.1) - security - deliver (1.13.3) - credentials_manager (>= 0.16.0, < 1.0.0) - fastimage (~> 1.6) - fastlane_core (>= 0.50.3, < 1.0.0) - plist (~> 3.1.0) - spaceship (>= 0.31.6, < 1.0.0) - domain_name (0.5.20160826) + domain_name (0.5.20161129) unf (>= 0.0.5, < 1.0.0) - dotenv (2.1.1) + dotenv (2.1.2) escape (0.0.4) - excon (0.45.4) - faraday (0.9.2) + excon (0.54.0) + faraday (0.11.0) multipart-post (>= 1.2, < 3) faraday-cookie_jar (0.0.6) faraday (>= 0.7.4) http-cookie (~> 1.0.0) - faraday_middleware (0.10.0) - faraday (>= 0.7.4, < 0.10) - fastimage (1.6.8) - addressable (~> 2.3, >= 2.3.5) - fastlane (1.103.0) + faraday_middleware (0.11.0) + faraday (>= 0.7.4, < 1.0) + fastimage (2.0.1) + addressable (~> 2) + fastlane (2.9.0) activesupport (< 5) - addressable (~> 2.3) + addressable (>= 2.3, < 3.0.0) + babosa (>= 1.0.2, < 2.0.0) bundler (~> 1.12) - cert (>= 1.4.1, < 2.0.0) - credentials_manager (>= 0.16.0, < 1.0.0) - deliver (>= 1.13.3, < 2.0.0) - fastlane_core (>= 0.52.0, < 1.0.0) - frameit (>= 2.7.0, < 3.0.0) - gym (>= 1.7.0, < 2.0.0) - krausefx-shenzhen (>= 0.14.10) - match (>= 0.6.3, < 1.0.0) - multipart-post (~> 2.0.0) - pem (>= 1.3.2, < 2.0.0) - pilot (>= 1.10.0, < 2.0.0) - plist (~> 3.1.0) - produce (>= 1.2.0, < 2.0.0) - scan (>= 0.11.3, < 2.0.0) - screengrab (>= 0.5.0, < 1.0.0) - sigh (>= 1.10.2, < 2.0.0) - slack-notifier (~> 1.3) - snapshot (>= 1.14.0, < 2.0.0) - spaceship (>= 0.32.1, < 1.0.0) - supply (>= 0.7.0, < 1.0.0) - terminal-notifier (~> 1.6.2) - terminal-table (~> 1.4.5) - word_wrap (~> 1.0.0) - xcode-install (~> 2.0.0) - xcodeproj (>= 0.20, < 2.0.0) - xcpretty (>= 0.2.1) - fastlane_core (0.52.0) - babosa colored - commander (>= 4.4.0, <= 5.0.0) - credentials_manager (>= 0.16.0, < 1.0.0) - excon (~> 0.45.0) + commander (>= 4.4.0, < 5.0.0) + dotenv (>= 2.1.1, < 3.0.0) + excon (>= 0.45.0, < 1.0.0) + faraday (~> 0.9) + faraday-cookie_jar (~> 0.0.6) + faraday_middleware (~> 0.9) + fastimage (>= 1.6) gh_inspector (>= 1.0.1, < 2.0.0) - highline (>= 1.7.2) - json - multi_json - plist (~> 3.1) - rubyzip (~> 1.1.6) - terminal-table (~> 1.4.5) - frameit (2.7.0) - deliver (> 0.3) - fastimage (~> 1.6.3) - fastlane_core (>= 0.36.1, < 1.0.0) + google-api-client (~> 0.9.2) + highline (>= 1.7.2, < 2.0.0) + json (< 3.0.0) mini_magick (~> 4.5.1) + multi_json + multi_xml (~> 0.5) + multipart-post (~> 2.0.0) + plist (>= 3.1.0, < 4.0.0) + rubyzip (>= 1.1.0, < 2.0.0) + security (= 0.1.3) + slack-notifier (>= 1.3, < 2.0.0) + terminal-notifier (>= 1.6.2, < 2.0.0) + terminal-table (>= 1.4.5, < 2.0.0) + word_wrap (~> 1.0.0) + xcodeproj (>= 0.20, < 2.0.0) + xcpretty (>= 0.2.4, < 1.0.0) + xcpretty-travis-formatter (>= 0.0.3) + fourflusher (2.0.1) fuzzy_match (2.0.4) - gh_inspector (1.0.2) - google-api-client (0.9.14) + gh_inspector (1.0.3) + google-api-client (0.9.20) addressable (~> 2.3) googleauth (~> 0.5) httpclient (~> 2.7) @@ -137,124 +113,57 @@ GEM multi_json (~> 1.11) os (~> 0.9) signet (~> 0.7) - gym (1.9.0) - fastlane_core (>= 0.51.0, < 1.0.0) - plist - rubyzip (>= 1.1.7) - terminal-table - xcpretty (>= 0.2.1) highline (1.7.8) - http-cookie (1.0.2) + http-cookie (1.0.3) domain_name (~> 0.5) - httpclient (2.8.2.4) + httpclient (2.8.3) hurley (0.2) i18n (0.7.0) - json (1.8.3) + json (1.8.6) jwt (1.5.6) - krausefx-shenzhen (0.14.10) - commander (>= 4.3, < 5.0) - dotenv (>= 0.7) - faraday (~> 0.9) - faraday_middleware (~> 0.9) - highline (>= 1.7.2) - json (~> 1.8) - net-sftp (~> 2.1.2) - plist (~> 3.1.0) - rubyzip (~> 1.1) - security (~> 0.1.3) - terminal-table (~> 1.4.5) little-plugger (1.1.4) logging (2.1.0) little-plugger (~> 1.1) multi_json (~> 1.10) - match (0.6.4) - cert (>= 1.4.1, < 2.0.0) - credentials_manager (>= 0.16.0, < 1.0.0) - fastlane_core (>= 0.50.3, < 1.0.0) - security - sigh (>= 1.10.2, < 2.0.0) - spaceship (>= 0.31.10, < 1.0.0) memoist (0.15.0) mime-types (3.1) mime-types-data (~> 3.2015) mime-types-data (3.2016.0521) mini_magick (4.5.1) mini_portile2 (2.1.0) - minitest (5.9.0) - molinillo (0.4.4) + minitest (5.10.1) + molinillo (0.5.5) multi_json (1.12.1) - multi_xml (0.5.5) + multi_xml (0.6.0) multipart-post (2.0.0) + nanaimo (0.2.3) nap (1.1.0) - net-sftp (2.1.2) - net-ssh (>= 2.6.5) - net-ssh (3.2.0) netrc (0.7.8) - nokogiri (1.6.8) + nokogiri (1.6.8.1) mini_portile2 (~> 2.1.0) - pkg-config (~> 1.1.7) os (0.9.6) - pem (1.3.2) - fastlane_core (>= 0.43.1, < 1.0.0) - spaceship (>= 0.26.2, < 1.0.0) - pilot (1.10.0) - credentials_manager (>= 0.3.0) - fastlane_core (>= 0.46.2, < 1.0.0) - spaceship (>= 0.29.0, < 1.0.0) - terminal-table (~> 1.4.5) - pkg-config (1.1.7) - plist (3.1.0) - produce (1.2.0) - fastlane_core (>= 0.30.0, < 1.0.0) - spaceship (>= 0.31.1, < 1.0.0) + plist (3.2.0) + public_suffix (2.0.5) representable (2.3.0) uber (~> 0.0.7) retriable (2.1.0) rouge (1.11.1) - rubyzip (1.1.7) - scan (0.12.1) - fastlane_core (>= 0.51.0, < 1.0.0) - slack-notifier (~> 1.3) - terminal-table - xcpretty (>= 0.2.1) - xcpretty-travis-formatter (>= 0.0.3) - screengrab (0.5.2) - fastlane_core (>= 0.50.3, < 1.0.0) + rubyzip (1.2.0) security (0.1.3) - sigh (1.10.4) - fastlane_core (>= 0.52.0, < 1.0.0) - plist (~> 3.1) - spaceship (>= 0.32.4, < 1.0.0) signet (0.7.3) addressable (~> 2.3) faraday (~> 0.9) jwt (~> 1.5) multi_json (~> 1.10) slack-notifier (1.5.1) - slather (2.2.0) + slather (2.3.0) + activesupport (>= 4.0.2, < 5) clamp (~> 0.6) nokogiri (~> 1.6.3) - xcodeproj (>= 0.28.2, < 1.1.0) - snapshot (1.14.0) - fastimage (~> 1.6.3) - fastlane_core (>= 0.50.3, < 1.0.0) - plist (~> 3.1.0) - xcpretty (>= 0.2.1) - spaceship (0.32.4) - colored - credentials_manager (>= 0.16.0) - faraday (~> 0.9) - faraday-cookie_jar (~> 0.0.6) - faraday_middleware (~> 0.9) - fastimage (~> 1.6) - multi_xml (~> 0.5) - plist (~> 3.1) - supply (0.7.1) - credentials_manager (>= 0.15.0) - fastlane_core (>= 0.43.4) - google-api-client (~> 0.9.1) - terminal-notifier (1.6.3) - terminal-table (1.4.5) + xcodeproj (>= 0.20, < 2.0.0) + terminal-notifier (1.7.1) + terminal-table (1.7.3) + unicode-display_width (~> 1.1.1) thread_safe (0.3.5) tzinfo (1.2.2) thread_safe (~> 0.1) @@ -262,15 +171,15 @@ GEM unf (0.1.4) unf_ext unf_ext (0.0.7.2) + unicode-display_width (1.1.3) word_wrap (1.0.0) - xcode-install (2.0.6) - claide (>= 0.9.1, < 1.1.0) - spaceship (>= 0.25.1, < 1.0.0) - xcodeproj (0.28.2) + xcodeproj (1.4.2) + CFPropertyList (~> 2.3.3) activesupport (>= 3) - claide (~> 0.9.1) + claide (>= 1.0.1, < 2.0) colored (~> 1.2) - xcpretty (0.2.2) + nanaimo (~> 0.2.3) + xcpretty (0.2.4) rouge (~> 1.8) xcpretty-travis-formatter (0.0.4) xcpretty (~> 0.2, >= 0.0.7) @@ -284,4 +193,4 @@ DEPENDENCIES slather (~> 2.0) BUNDLED WITH - 1.13.1 + 1.13.6 diff --git a/fastlane/.env.default b/fastlane/.env.default index ea6fe911..dac232dc 100644 --- a/fastlane/.env.default +++ b/fastlane/.env.default @@ -1,11 +1,10 @@ -AF_IOS_SDK=iphonesimulator10.0 +AF_IOS_SDK=iphonesimulator10.2 AF_MAC_SDK=macosx10.12 -AF_TVOS_SDK=appletvsimulator10.0 +AF_TVOS_SDK=appletvsimulator10.1 AF_CONFIGURATION=Release SCAN_SCHEME=$AF_IOS_FRAMEWORK_SCHEME -SCAN_DESTINATION="OS=10.0,name=iPhone 6s" SCAN_SDK=$AF_IOS_SDK SCAN_OUTPUT_DIRECTORY=fastlane/test-output DEPLOY_PODSPEC=OctoKit.swift.podspec diff --git a/fastlane/.env.ios93 b/fastlane/.env.ios93 index 61555b8d..d677f887 100644 --- a/fastlane/.env.ios93 +++ b/fastlane/.env.ios93 @@ -1,2 +1,3 @@ -SCAN_DESTINATION="OS=10.0,name=iPhone 6s" -EXAMPLE_DESTINATION=$SCAN_DESTINATION +SCAN_DEVICE="iPhone 6s" +SCAN_SDK=iphonesimulator10.2 +EXAMPLE_DESTINATION="platform=iOS Simulator,name=iPhone 6s" diff --git a/fastlane/.env.osx b/fastlane/.env.osx index de1d9324..91dafd4e 100644 --- a/fastlane/.env.osx +++ b/fastlane/.env.osx @@ -1,6 +1,5 @@ SCAN_SCHEME=$AF_OSX_FRAMEWORK_SCHEME -SCAN_DESTINATION="arch=x86_64" SCAN_SDK=$AF_OSX_SDK EXAMPLE_SCHEME=$AF_OSX_EXAMPLE_SCHEME -EXAMPLE_DESTINATION=$SCAN_DESTINATION +EXAMPLE_DESTINATION="platform=macOS" \ No newline at end of file diff --git a/fastlane/.env.tvos92 b/fastlane/.env.tvos92 index 128f8be5..216d1be2 100644 --- a/fastlane/.env.tvos92 +++ b/fastlane/.env.tvos92 @@ -1,6 +1,6 @@ SCAN_SCHEME=$AF_TVOS_FRAMEWORK_SCHEME -SCAN_DESTINATION="OS=10.0,name=Apple TV 1080p" +SCAN_DEVICE="Apple TV 1080p" SCAN_SDK=$AF_TVOS_SDK EXAMPLE_SCHEME=$AF_TVOS_EXAMPLE_SCHEME -EXAMPLE_DESTINATION=$SCAN_DESTINATION +EXAMPLE_DESTINATION="platform=tvOS Simulator,name=Apple TV 1080p" \ No newline at end of file From 548a2895202fb354326b608007ed9e1b4c990af6 Mon Sep 17 00:00:00 2001 From: Piet Brauer Date: Thu, 9 Feb 2017 14:29:21 +0100 Subject: [PATCH 100/302] Bump version --- OctoKit.swift.podspec | 2 +- OctoKit/Info.plist | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/OctoKit.swift.podspec b/OctoKit.swift.podspec index fdca2b25..6fa25cb5 100644 --- a/OctoKit.swift.podspec +++ b/OctoKit.swift.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "OctoKit.swift" - s.version = "0.7.0" + s.version = "0.7.1" s.summary = "A Swift API Client for GitHub and GitHub Enterprise" s.description = <<-DESC You are looking at the A Swift API Client for GitHub and GitHub Enterprise. diff --git a/OctoKit/Info.plist b/OctoKit/Info.plist index 3157e479..425ef70f 100644 --- a/OctoKit/Info.plist +++ b/OctoKit/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 0.7.0 + 0.7.1 CFBundleSignature ???? CFBundleVersion From e40ae866dccff57e45fbe35f02ddb11e7b2c4fbd Mon Sep 17 00:00:00 2001 From: Piet Brauer Date: Mon, 20 Feb 2017 10:28:58 +0100 Subject: [PATCH 101/302] Handle undocumented optional parameters in Redirect URL --- OctoKit.xcodeproj/project.pbxproj | 10 ++++++++++ OctoKit/Configuration.swift | 2 +- OctoKit/URL+URLParameters.swift | 18 ++++++++++++++++++ OctoKitTests/ConfigurationTests.swift | 2 +- 4 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 OctoKit/URL+URLParameters.swift diff --git a/OctoKit.xcodeproj/project.pbxproj b/OctoKit.xcodeproj/project.pbxproj index bd1e7883..c0389580 100644 --- a/OctoKit.xcodeproj/project.pbxproj +++ b/OctoKit.xcodeproj/project.pbxproj @@ -21,6 +21,10 @@ 234F4BE11BDDE44600A58EF7 /* user_repos.json in Resources */ = {isa = PBXBuildFile; fileRef = 234F4BDC1BDDE44600A58EF7 /* user_repos.json */; }; 234F4C3F1BDE0FE200A58EF7 /* RequestKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 234F4C3E1BDE0FE200A58EF7 /* RequestKit.framework */; }; 234F4C401BDE113800A58EF7 /* RequestKit.framework in Carthage embed */ = {isa = PBXBuildFile; fileRef = 234F4C3E1BDE0FE200A58EF7 /* RequestKit.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + 237F91E41E5AEC82005FAA6B /* URL+URLParameters.swift in Sources */ = {isa = PBXBuildFile; fileRef = 237F91E31E5AEC82005FAA6B /* URL+URLParameters.swift */; }; + 237F91E51E5AEC87005FAA6B /* URL+URLParameters.swift in Sources */ = {isa = PBXBuildFile; fileRef = 237F91E31E5AEC82005FAA6B /* URL+URLParameters.swift */; }; + 237F91E61E5AEC88005FAA6B /* URL+URLParameters.swift in Sources */ = {isa = PBXBuildFile; fileRef = 237F91E31E5AEC82005FAA6B /* URL+URLParameters.swift */; }; + 237F91E71E5AEC89005FAA6B /* URL+URLParameters.swift in Sources */ = {isa = PBXBuildFile; fileRef = 237F91E31E5AEC82005FAA6B /* URL+URLParameters.swift */; }; 239BE7CE1B8C47A100D2CE22 /* OctoKit.h in Headers */ = {isa = PBXBuildFile; fileRef = 239BE7CD1B8C47A100D2CE22 /* OctoKit.h */; settings = {ATTRIBUTES = (Public, ); }; }; 23A0521F1CA924950068BFF7 /* OctoKitURLTestSession.swift in Sources */ = {isa = PBXBuildFile; fileRef = 23A0521E1CA924950068BFF7 /* OctoKitURLTestSession.swift */; }; 23A052201CA924950068BFF7 /* OctoKitURLTestSession.swift in Sources */ = {isa = PBXBuildFile; fileRef = 23A0521E1CA924950068BFF7 /* OctoKitURLTestSession.swift */; }; @@ -196,6 +200,7 @@ 234F4BDB1BDDE44600A58EF7 /* user_mietzmithut.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = user_mietzmithut.json; path = Fixtures/user_mietzmithut.json; sourceTree = ""; }; 234F4BDC1BDDE44600A58EF7 /* user_repos.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = user_repos.json; path = Fixtures/user_repos.json; sourceTree = ""; }; 234F4C3E1BDE0FE200A58EF7 /* RequestKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = RequestKit.framework; path = Carthage/Build/iOS/RequestKit.framework; sourceTree = ""; }; + 237F91E31E5AEC82005FAA6B /* URL+URLParameters.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "URL+URLParameters.swift"; sourceTree = ""; }; 239BE7C91B8C47A100D2CE22 /* OctoKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = OctoKit.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 239BE7CC1B8C47A100D2CE22 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 239BE7CD1B8C47A100D2CE22 /* OctoKit.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OctoKit.h; sourceTree = ""; }; @@ -339,6 +344,7 @@ 23B267891BDDD756003887E3 /* User.swift */, E7EE59D71BDFEFB30012E3D2 /* Stars.swift */, F8711EA11BFCAE9F005DDACA /* Time.swift */, + 237F91E31E5AEC82005FAA6B /* URL+URLParameters.swift */, 239BE7CB1B8C47A100D2CE22 /* Supporting Files */, ); path = OctoKit; @@ -724,6 +730,7 @@ F8711EA21BFCAE9F005DDACA /* Time.swift in Sources */, 23B2678C1BDDD756003887E3 /* PublicKey.swift in Sources */, 23B2678E1BDDD756003887E3 /* User.swift in Sources */, + 237F91E41E5AEC82005FAA6B /* URL+URLParameters.swift in Sources */, DAEFC5951C83EF0D00CF3785 /* Milestone.swift in Sources */, 23B2678B1BDDD756003887E3 /* Octokit.swift in Sources */, E7EDEA6A1C871CEB006BAAF2 /* Issue.swift in Sources */, @@ -742,6 +749,7 @@ 23CAF2B71C7AB6EB005011C4 /* Time.swift in Sources */, 23CAF2B41C7AB6D4005011C4 /* Stars.swift in Sources */, 23CAF2AB1C7AB6C9005011C4 /* PublicKey.swift in Sources */, + 237F91E51E5AEC87005FAA6B /* URL+URLParameters.swift in Sources */, DAEFC5961C83EF0D00CF3785 /* Milestone.swift in Sources */, 23CAF2A81C7AB6C6005011C4 /* Octokit.swift in Sources */, E7EDEA6F1C871F81006BAAF2 /* Issue.swift in Sources */, @@ -777,6 +785,7 @@ 23CAF2B81C7AB6EB005011C4 /* Time.swift in Sources */, 23CAF2B51C7AB6D5005011C4 /* Stars.swift in Sources */, 23CAF2AC1C7AB6CA005011C4 /* PublicKey.swift in Sources */, + 237F91E61E5AEC88005FAA6B /* URL+URLParameters.swift in Sources */, DAEFC5971C83EF0D00CF3785 /* Milestone.swift in Sources */, 23CAF2A91C7AB6C6005011C4 /* Octokit.swift in Sources */, E7EDEA701C871F81006BAAF2 /* Issue.swift in Sources */, @@ -812,6 +821,7 @@ 23CAF2B91C7AB6EC005011C4 /* Time.swift in Sources */, 23CAF2B61C7AB6D5005011C4 /* Stars.swift in Sources */, 23CAF2AD1C7AB6CA005011C4 /* PublicKey.swift in Sources */, + 237F91E71E5AEC89005FAA6B /* URL+URLParameters.swift in Sources */, DAEFC5981C83EF0D00CF3785 /* Milestone.swift in Sources */, 23CAF2AA1C7AB6C7005011C4 /* Octokit.swift in Sources */, E7EDEA711C871F82006BAAF2 /* Issue.swift in Sources */, diff --git a/OctoKit/Configuration.swift b/OctoKit/Configuration.swift index d4f86e61..16a225d9 100644 --- a/OctoKit/Configuration.swift +++ b/OctoKit/Configuration.swift @@ -63,7 +63,7 @@ public struct OAuthConfiguration: Configuration { public func handleOpenURL(_ session: RequestKitURLSession = URLSession.shared, url: URL, completion: @escaping (_ config: TokenConfiguration) -> Void) { let urlString: String? = url.absoluteString - if let code = urlString?.components(separatedBy: "=").last { + if let code = url.URLParameters["code"] { authorize(session, code: code) { (config) in completion(config) } diff --git a/OctoKit/URL+URLParameters.swift b/OctoKit/URL+URLParameters.swift new file mode 100644 index 00000000..71a7b51b --- /dev/null +++ b/OctoKit/URL+URLParameters.swift @@ -0,0 +1,18 @@ +import Foundation + +internal extension URL { + var URLParameters: [String: String] { + let stringParams = absoluteString.components(separatedBy: "?").last + let params = stringParams?.components(separatedBy: "&") + var returnParams: [String: String] = [:] + if let params = params { + for param in params { + let keyValue = param.components(separatedBy: "=") + if let key = keyValue.first, let value = keyValue.last { + returnParams[key] = value + } + } + } + return returnParams + } +} diff --git a/OctoKitTests/ConfigurationTests.swift b/OctoKitTests/ConfigurationTests.swift index 2a7b845c..60514ecc 100644 --- a/OctoKitTests/ConfigurationTests.swift +++ b/OctoKitTests/ConfigurationTests.swift @@ -40,7 +40,7 @@ class ConfigurationTests: XCTestCase { let config = OAuthConfiguration(token: "12345", secret: "6789", scopes: ["repo", "read:org"]) let response = "access_token=017ec60f4a182&scope=read%3Aorg%2Crepo&token_type=bearer" let session = OctoKitURLTestSession(expectedURL: "https://github.com/login/oauth/access_token", expectedHTTPMethod: "POST", response: response, statusCode: 200) - let url = URL(string: "urlscheme://authorize?code=dhfjgh23493")! + let url = URL(string: "urlscheme://authorize?code=dhfjgh23493&state=")! var token: String? = nil config.handleOpenURL(session, url: url) { accessToken in token = accessToken.accessToken From e5144e1004880a9c7590d9f02045c16eea2d1c2d Mon Sep 17 00:00:00 2001 From: Piet Brauer Date: Mon, 20 Feb 2017 10:44:10 +0100 Subject: [PATCH 102/302] Use URLComponents --- OctoKit/Configuration.swift | 1 - OctoKit/URL+URLParameters.swift | 16 +++++----------- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/OctoKit/Configuration.swift b/OctoKit/Configuration.swift index 16a225d9..79a57e88 100644 --- a/OctoKit/Configuration.swift +++ b/OctoKit/Configuration.swift @@ -62,7 +62,6 @@ public struct OAuthConfiguration: Configuration { } public func handleOpenURL(_ session: RequestKitURLSession = URLSession.shared, url: URL, completion: @escaping (_ config: TokenConfiguration) -> Void) { - let urlString: String? = url.absoluteString if let code = url.URLParameters["code"] { authorize(session, code: code) { (config) in completion(config) diff --git a/OctoKit/URL+URLParameters.swift b/OctoKit/URL+URLParameters.swift index 71a7b51b..8729b008 100644 --- a/OctoKit/URL+URLParameters.swift +++ b/OctoKit/URL+URLParameters.swift @@ -2,17 +2,11 @@ import Foundation internal extension URL { var URLParameters: [String: String] { - let stringParams = absoluteString.components(separatedBy: "?").last - let params = stringParams?.components(separatedBy: "&") - var returnParams: [String: String] = [:] - if let params = params { - for param in params { - let keyValue = param.components(separatedBy: "=") - if let key = keyValue.first, let value = keyValue.last { - returnParams[key] = value - } - } + guard let components = URLComponents(url: self, resolvingAgainstBaseURL: false) else { return [:] } + var params = [String: String]() + components.queryItems?.forEach { queryItem in + params[queryItem.name] = queryItem.value } - return returnParams + return params } } From 188cc87f5dbef0d6e996e1f65928f5ed00e918b6 Mon Sep 17 00:00:00 2001 From: Piet Brauer Date: Mon, 20 Feb 2017 10:58:03 +0100 Subject: [PATCH 103/302] Update Project Settings w/ Xcode 8.2 --- OctoKit.xcodeproj/project.pbxproj | 12 +++++++++++- .../xcshareddata/xcschemes/OctoKit Mac.xcscheme | 2 +- .../xcshareddata/xcschemes/OctoKit tvOS.xcscheme | 2 +- .../xcshareddata/xcschemes/OctoKit watchOS.xcscheme | 2 +- .../xcshareddata/xcschemes/OctoKit.xcscheme | 2 +- 5 files changed, 15 insertions(+), 5 deletions(-) diff --git a/OctoKit.xcodeproj/project.pbxproj b/OctoKit.xcodeproj/project.pbxproj index bd1e7883..0c8baa33 100644 --- a/OctoKit.xcodeproj/project.pbxproj +++ b/OctoKit.xcodeproj/project.pbxproj @@ -565,7 +565,7 @@ attributes = { LastSwiftMigration = 0700; LastSwiftUpdateCheck = 0720; - LastUpgradeCheck = 0800; + LastUpgradeCheck = 0820; ORGANIZATIONNAME = "nerdish by nature"; TargetAttributes = { 234F4BA81BDDE31A00A58EF7 = { @@ -882,6 +882,7 @@ isa = XCBuildConfiguration; buildSettings = { CLANG_ENABLE_MODULES = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; CURRENT_PROJECT_VERSION = 1; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEFINES_MODULE = YES; @@ -912,6 +913,7 @@ isa = XCBuildConfiguration; buildSettings = { CLANG_ENABLE_MODULES = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; COPY_PHASE_STRIP = NO; CURRENT_PROJECT_VERSION = 1; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; @@ -938,6 +940,7 @@ 23CAF2731C7AB5FC005011C4 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; CURRENT_PROJECT_VERSION = 1; DEBUG_INFORMATION_FORMAT = dwarf; DEFINES_MODULE = YES; @@ -963,6 +966,7 @@ 23CAF2741C7AB5FC005011C4 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; COPY_PHASE_STRIP = NO; CURRENT_PROJECT_VERSION = 1; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; @@ -1127,6 +1131,7 @@ isa = XCBuildConfiguration; buildSettings = { APPLICATION_EXTENSION_API_ONLY = YES; + "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; CURRENT_PROJECT_VERSION = 1; DEBUG_INFORMATION_FORMAT = dwarf; DEFINES_MODULE = YES; @@ -1153,6 +1158,7 @@ isa = XCBuildConfiguration; buildSettings = { APPLICATION_EXTENSION_API_ONLY = YES; + "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; COPY_PHASE_STRIP = NO; CURRENT_PROJECT_VERSION = 1; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; @@ -1190,8 +1196,10 @@ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; @@ -1238,8 +1246,10 @@ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; diff --git a/OctoKit.xcodeproj/xcshareddata/xcschemes/OctoKit Mac.xcscheme b/OctoKit.xcodeproj/xcshareddata/xcschemes/OctoKit Mac.xcscheme index 3e6f1e88..e513e207 100644 --- a/OctoKit.xcodeproj/xcshareddata/xcschemes/OctoKit Mac.xcscheme +++ b/OctoKit.xcodeproj/xcshareddata/xcschemes/OctoKit Mac.xcscheme @@ -1,6 +1,6 @@ Date: Wed, 22 Feb 2017 15:25:06 +0100 Subject: [PATCH 104/302] Bump version --- OctoKit.swift.podspec | 2 +- OctoKit/Info.plist | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/OctoKit.swift.podspec b/OctoKit.swift.podspec index 6fa25cb5..7b3afafd 100644 --- a/OctoKit.swift.podspec +++ b/OctoKit.swift.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "OctoKit.swift" - s.version = "0.7.1" + s.version = "0.7.2" s.summary = "A Swift API Client for GitHub and GitHub Enterprise" s.description = <<-DESC You are looking at the A Swift API Client for GitHub and GitHub Enterprise. diff --git a/OctoKit/Info.plist b/OctoKit/Info.plist index 425ef70f..e9c49a10 100644 --- a/OctoKit/Info.plist +++ b/OctoKit/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 0.7.1 + 0.7.2 CFBundleSignature ???? CFBundleVersion From c76be1e4fbecfe36f10eb5e7259726abaf29e1ba Mon Sep 17 00:00:00 2001 From: Piet Brauer Date: Wed, 29 Mar 2017 21:04:21 +0200 Subject: [PATCH 105/302] Migrate to Swift 3.1 --- Cartfile.resolved | 2 +- OctoKit.xcodeproj/project.pbxproj | 6 ++++ OctoKit/Configuration.swift | 2 +- OctoKit/Issue.swift | 44 ++++++++++++------------ OctoKit/Label.swift | 8 ++--- OctoKit/Milestone.swift | 32 ++++++++--------- OctoKit/Repositories.swift | 28 +++++++-------- OctoKit/Time.swift | 2 +- OctoKit/User.swift | 28 +++++++-------- OctoKitTests/OctoKitURLTestSession.swift | 2 +- 10 files changed, 80 insertions(+), 74 deletions(-) diff --git a/Cartfile.resolved b/Cartfile.resolved index c7b9648a..7b711263 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1 +1 @@ -github "nerdishbynature/RequestKit" "2.0.1" +github "nerdishbynature/RequestKit" "2.0.2" diff --git a/OctoKit.xcodeproj/project.pbxproj b/OctoKit.xcodeproj/project.pbxproj index 2f3fcbe6..ae79da77 100644 --- a/OctoKit.xcodeproj/project.pbxproj +++ b/OctoKit.xcodeproj/project.pbxproj @@ -592,9 +592,11 @@ }; 23CAF27D1C7AB60C005011C4 = { CreatedOnToolsVersion = 7.2.1; + LastSwiftMigration = 0830; }; 23CAF2861C7AB60D005011C4 = { CreatedOnToolsVersion = 7.2.1; + LastSwiftMigration = 0830; }; 23CAF2991C7AB619005011C4 = { CreatedOnToolsVersion = 7.2.1; @@ -1061,6 +1063,7 @@ MACOSX_DEPLOYMENT_TARGET = 10.10; SDKROOT = macosx; SKIP_INSTALL = YES; + SWIFT_VERSION = 3.0; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; }; @@ -1090,6 +1093,7 @@ SDKROOT = macosx; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + SWIFT_VERSION = 3.0; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; }; @@ -1112,6 +1116,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "com.nerdishbynature.OctoKit-MacTests"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = macosx; + SWIFT_VERSION = 3.0; }; name = Debug; }; @@ -1134,6 +1139,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = macosx; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + SWIFT_VERSION = 3.0; }; name = Release; }; diff --git a/OctoKit/Configuration.swift b/OctoKit/Configuration.swift index 79a57e88..260cc938 100644 --- a/OctoKit/Configuration.swift +++ b/OctoKit/Configuration.swift @@ -47,7 +47,7 @@ public struct OAuthConfiguration: Configuration { if response.statusCode != 200 { return } else { - if let data = data, let string = NSString(data: data, encoding: String.Encoding.utf8.rawValue) as? String { + if let data = data, let string = String(data: data, encoding: .utf8) { let accessToken = self.accessTokenFromResponse(string) if let accessToken = accessToken { let config = TokenConfiguration(accessToken, url: self.apiEndpoint) diff --git a/OctoKit/Issue.swift b/OctoKit/Issue.swift index 4bcee43d..7bef8811 100644 --- a/OctoKit/Issue.swift +++ b/OctoKit/Issue.swift @@ -9,28 +9,28 @@ public enum Openness: String { case All = "all" } -@objc public class Issue: NSObject { - public var id: Int - public var url: URL? - public var repositoryURL: URL? - public var labelsURL: URL? - public var commentsURL: URL? - public var eventsURL: URL? - public var htmlURL: URL? - public var number: Int? - public var state: Openness? - public var title: String? - public var body: String? - public var user: User? - public var labels: [Label]? - public var assignee: User? - public var milestone: Milestone? - public var locked: Bool? - public var comments: Int? - public var closedAt: Date? - public var createdAt: Date? - public var updatedAt: Date? - public var closedBy: User? +@objc open class Issue: NSObject { + open var id: Int + open var url: URL? + open var repositoryURL: URL? + open var labelsURL: URL? + open var commentsURL: URL? + open var eventsURL: URL? + open var htmlURL: URL? + open var number: Int? + open var state: Openness? + open var title: String? + open var body: String? + open var user: User? + open var labels: [Label]? + open var assignee: User? + open var milestone: Milestone? + open var locked: Bool? + open var comments: Int? + open var closedAt: Date? + open var createdAt: Date? + open var updatedAt: Date? + open var closedBy: User? public init(_ json: [String: AnyObject]) { if let id = json["id"] as? Int { diff --git a/OctoKit/Label.swift b/OctoKit/Label.swift index a360fbd1..14ce322c 100644 --- a/OctoKit/Label.swift +++ b/OctoKit/Label.swift @@ -22,11 +22,11 @@ extension Color { } } -@objc public class Label: NSObject { - public var url: URL? - public var name: String? +@objc open class Label: NSObject { + open var url: URL? + open var name: String? #if os(OSX) - public var color: NSColor? + open var color: NSColor? #elseif os(iOS) || os(tvOS) || os(watchOS) public var color: UIColor? #endif diff --git a/OctoKit/Milestone.swift b/OctoKit/Milestone.swift index fe5d7da0..af0f5681 100644 --- a/OctoKit/Milestone.swift +++ b/OctoKit/Milestone.swift @@ -1,21 +1,21 @@ import Foundation -@objc public class Milestone: NSObject { - public var url: URL? - public var htmlURL: URL? - public var labelsURL: URL? - public var id: Int - public var number: Int? - public var state: Openness? - public var title: String? - public var milestoneDescription: String? - public var creator: User? - public var openIssues: Int? - public var closedIssues: Int? - public var createdAt: Date? - public var updatedAt: Date? - public var closedAt: Date? - public var dueOn: Date? +@objc open class Milestone: NSObject { + open var url: URL? + open var htmlURL: URL? + open var labelsURL: URL? + open var id: Int + open var number: Int? + open var state: Openness? + open var title: String? + open var milestoneDescription: String? + open var creator: User? + open var openIssues: Int? + open var closedIssues: Int? + open var createdAt: Date? + open var updatedAt: Date? + open var closedAt: Date? + open var dueOn: Date? public init?(_ json: [String: AnyObject]) { if let id = json["id"] as? Int { diff --git a/OctoKit/Repositories.swift b/OctoKit/Repositories.swift index 98036d08..581634ec 100644 --- a/OctoKit/Repositories.swift +++ b/OctoKit/Repositories.swift @@ -3,20 +3,20 @@ import RequestKit // MARK: model -@objc public class Repository: NSObject { - public let id: Int - public let owner: User - public var name: String? - public var fullName: String? - public var isPrivate: Bool - public var repositoryDescription: String? - public var isFork: Bool? - public var gitURL: String? - public var sshURL: String? - public var cloneURL: String? - public var htmlURL: String? - public var size: Int - public var lastPush: Date? +@objc open class Repository: NSObject { + open let id: Int + open let owner: User + open var name: String? + open var fullName: String? + open var isPrivate: Bool + open var repositoryDescription: String? + open var isFork: Bool? + open var gitURL: String? + open var sshURL: String? + open var cloneURL: String? + open var htmlURL: String? + open var size: Int + open var lastPush: Date? public init(_ json: [String: AnyObject]) { owner = User(json["owner"] as? [String: AnyObject] ?? [:]) diff --git a/OctoKit/Time.swift b/OctoKit/Time.swift index cf54b944..5ef2918e 100644 --- a/OctoKit/Time.swift +++ b/OctoKit/Time.swift @@ -8,7 +8,7 @@ struct Time { - [https://developer.apple.com/library/mac/qa/qa1480/_index.html](https://developer.apple.com/library/mac/qa/qa1480/_index.html) - [https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/DataFormatting/Articles/dfDateFormatting10_4.html](https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/DataFormatting/Articles/dfDateFormatting10_4.html) */ - private static var rfc3339DateFormatter: DateFormatter = { + fileprivate static var rfc3339DateFormatter: DateFormatter = { let formatter = DateFormatter() formatter.dateFormat = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'" formatter.locale = Locale(identifier: "en_US_POSIX") diff --git a/OctoKit/User.swift b/OctoKit/User.swift index cbc4504c..1597d8aa 100644 --- a/OctoKit/User.swift +++ b/OctoKit/User.swift @@ -3,20 +3,20 @@ import RequestKit // MARK: model -@objc public class User: NSObject { - public let id: Int - public var login: String? - public var avatarURL: String? - public var gravatarID: String? - public var type: String? - public var name: String? - public var company: String? - public var blog: String? - public var location: String? - public var email: String? - public var numberOfPublicRepos: Int? - public var numberOfPublicGists: Int? - public var numberOfPrivateRepos: Int? +@objc open class User: NSObject { + open let id: Int + open var login: String? + open var avatarURL: String? + open var gravatarID: String? + open var type: String? + open var name: String? + open var company: String? + open var blog: String? + open var location: String? + open var email: String? + open var numberOfPublicRepos: Int? + open var numberOfPublicGists: Int? + open var numberOfPrivateRepos: Int? public init(_ json: [String: AnyObject]) { if let id = json["id"] as? Int { diff --git a/OctoKitTests/OctoKitURLTestSession.swift b/OctoKitTests/OctoKitURLTestSession.swift index 55ea6cca..490c0e06 100644 --- a/OctoKitTests/OctoKitURLTestSession.swift +++ b/OctoKitTests/OctoKitURLTestSession.swift @@ -2,7 +2,7 @@ import RequestKit import XCTest class MockURLSessionDataTask: URLSessionDataTaskProtocol { - private (set) var resumeWasCalled = false + fileprivate (set) var resumeWasCalled = false func resume() { resumeWasCalled = true From 6f3c9416e5588b83ba5e3247dc10c7bc0fa2a889 Mon Sep 17 00:00:00 2001 From: Piet Brauer Date: Wed, 29 Mar 2017 21:04:49 +0200 Subject: [PATCH 106/302] Bump version --- OctoKit.swift.podspec | 2 +- OctoKit/Info.plist | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/OctoKit.swift.podspec b/OctoKit.swift.podspec index 7b3afafd..86024a8d 100644 --- a/OctoKit.swift.podspec +++ b/OctoKit.swift.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "OctoKit.swift" - s.version = "0.7.2" + s.version = "0.7.3" s.summary = "A Swift API Client for GitHub and GitHub Enterprise" s.description = <<-DESC You are looking at the A Swift API Client for GitHub and GitHub Enterprise. diff --git a/OctoKit/Info.plist b/OctoKit/Info.plist index e9c49a10..fb0dd735 100644 --- a/OctoKit/Info.plist +++ b/OctoKit/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 0.7.2 + 0.7.3 CFBundleSignature ???? CFBundleVersion From 5a3502e0749f63e319a148b4a1aabdf4644d68fd Mon Sep 17 00:00:00 2001 From: Piet Brauer Date: Fri, 31 Mar 2017 09:05:46 +0200 Subject: [PATCH 107/302] Update simulator envs --- .travis.yml | 10 +++++----- Gemfile.lock | 42 +++++++++++++++++++++--------------------- fastlane/.env.default | 4 ++-- fastlane/.env.ios93 | 2 +- fastlane/.env.tvos92 | 2 +- 5 files changed, 30 insertions(+), 30 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5275ec86..36fb3f89 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ language: objective-c -osx_image: xcode8.2 +osx_image: xcode8.3 sudo: false env: global: @@ -8,13 +8,13 @@ env: - FASTLANE_LANE=ci_commit matrix: include: - - osx_image: xcode8.2 + - osx_image: xcode8.3 env: FASTLANE_LANE=code_coverage FASTLANE_ENV=default - - osx_image: xcode8.2 + - osx_image: xcode8.3 env: FASTLANE_ENV=ios93 - - osx_image: xcode8.2 + - osx_image: xcode8.3 env: FASTLANE_ENV=tvos92 - - osx_image: xcode8.2 + - osx_image: xcode8.3 env: FASTLANE_ENV=osx before_install: - make install diff --git a/Gemfile.lock b/Gemfile.lock index 8086d1b5..17664523 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,14 +1,13 @@ GEM remote: https://rubygems.org/ specs: - CFPropertyList (2.3.4) - activesupport (4.2.7.1) + CFPropertyList (2.3.5) + activesupport (4.2.8) i18n (~> 0.7) - json (~> 1.7, >= 1.7.7) minitest (~> 5.1) thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) - addressable (2.5.0) + addressable (2.5.1) public_suffix (~> 2.0, >= 2.0.2) babosa (1.0.2) claide (1.0.1) @@ -46,29 +45,28 @@ GEM netrc (= 0.7.8) cocoapods-try (1.1.0) colored (1.2) - commander (4.4.3) + commander-fastlane (4.4.4) highline (~> 1.7.2) - domain_name (0.5.20161129) + domain_name (0.5.20170223) unf (>= 0.0.5, < 1.0.0) - dotenv (2.1.2) + dotenv (2.2.0) escape (0.0.4) - excon (0.54.0) + excon (0.55.0) faraday (0.11.0) multipart-post (>= 1.2, < 3) faraday-cookie_jar (0.0.6) faraday (>= 0.7.4) http-cookie (~> 1.0.0) - faraday_middleware (0.11.0) + faraday_middleware (0.11.0.1) faraday (>= 0.7.4, < 1.0) - fastimage (2.0.1) - addressable (~> 2) - fastlane (2.9.0) + fastimage (2.1.0) + fastlane (2.24.0) activesupport (< 5) addressable (>= 2.3, < 3.0.0) babosa (>= 1.0.2, < 2.0.0) - bundler (~> 1.12) + bundler (>= 1.12.0, < 2.0.0) colored - commander (>= 4.4.0, < 5.0.0) + commander-fastlane (>= 4.4.0, < 5.0.0) dotenv (>= 2.1.1, < 3.0.0) excon (>= 0.45.0, < 1.0.0) faraday (~> 0.9) @@ -89,6 +87,7 @@ GEM slack-notifier (>= 1.3, < 2.0.0) terminal-notifier (>= 1.6.2, < 2.0.0) terminal-table (>= 1.4.5, < 2.0.0) + tty-screen (~> 0.5.0) word_wrap (~> 1.0.0) xcodeproj (>= 0.20, < 2.0.0) xcpretty (>= 0.2.4, < 1.0.0) @@ -96,7 +95,7 @@ GEM fourflusher (2.0.1) fuzzy_match (2.0.4) gh_inspector (1.0.3) - google-api-client (0.9.20) + google-api-client (0.9.28) addressable (~> 2.3) googleauth (~> 0.5) httpclient (~> 2.7) @@ -118,11 +117,11 @@ GEM domain_name (~> 0.5) httpclient (2.8.3) hurley (0.2) - i18n (0.7.0) - json (1.8.6) + i18n (0.8.1) + json (2.0.3) jwt (1.5.6) little-plugger (1.1.4) - logging (2.1.0) + logging (2.2.0) little-plugger (~> 1.1) multi_json (~> 1.10) memoist (0.15.0) @@ -148,7 +147,7 @@ GEM uber (~> 0.0.7) retriable (2.1.0) rouge (1.11.1) - rubyzip (1.2.0) + rubyzip (1.2.1) security (0.1.3) signet (0.7.3) addressable (~> 2.3) @@ -164,8 +163,9 @@ GEM terminal-notifier (1.7.1) terminal-table (1.7.3) unicode-display_width (~> 1.1.1) - thread_safe (0.3.5) - tzinfo (1.2.2) + thread_safe (0.3.6) + tty-screen (0.5.0) + tzinfo (1.2.3) thread_safe (~> 0.1) uber (0.0.15) unf (0.1.4) diff --git a/fastlane/.env.default b/fastlane/.env.default index dac232dc..7374bf0d 100644 --- a/fastlane/.env.default +++ b/fastlane/.env.default @@ -1,6 +1,6 @@ -AF_IOS_SDK=iphonesimulator10.2 +AF_IOS_SDK=iphonesimulator10.3 AF_MAC_SDK=macosx10.12 -AF_TVOS_SDK=appletvsimulator10.1 +AF_TVOS_SDK=appletvsimulator10.2 AF_CONFIGURATION=Release diff --git a/fastlane/.env.ios93 b/fastlane/.env.ios93 index d677f887..f9fe2be3 100644 --- a/fastlane/.env.ios93 +++ b/fastlane/.env.ios93 @@ -1,3 +1,3 @@ SCAN_DEVICE="iPhone 6s" -SCAN_SDK=iphonesimulator10.2 +SCAN_SDK=iphonesimulator10.3 EXAMPLE_DESTINATION="platform=iOS Simulator,name=iPhone 6s" diff --git a/fastlane/.env.tvos92 b/fastlane/.env.tvos92 index 216d1be2..2b1cc591 100644 --- a/fastlane/.env.tvos92 +++ b/fastlane/.env.tvos92 @@ -3,4 +3,4 @@ SCAN_DEVICE="Apple TV 1080p" SCAN_SDK=$AF_TVOS_SDK EXAMPLE_SCHEME=$AF_TVOS_EXAMPLE_SCHEME -EXAMPLE_DESTINATION="platform=tvOS Simulator,name=Apple TV 1080p" \ No newline at end of file +EXAMPLE_DESTINATION="platform=tvOS Simulator,name=Apple TV 1080p" From 72ccad58324efdb8222aacede43bd8eda485297d Mon Sep 17 00:00:00 2001 From: "marcin.polak" Date: Fri, 19 May 2017 22:08:45 +0200 Subject: [PATCH 108/302] Add basic support for pull requests --- OctoKit.xcodeproj/project.pbxproj | 44 ++ .../xcschemes/OctoKit MacTests.xcscheme | 69 +++ OctoKit/Parameters.swift | 18 + OctoKit/PullRequest.swift | 207 +++++++++ OctoKitTests/PullRequestTests.swift | 48 +++ OctoKitTests/pull_request.json | 399 ++++++++++++++++++ OctoKitTests/pull_requests.json | 373 ++++++++++++++++ README.md | 24 ++ 8 files changed, 1182 insertions(+) create mode 100644 OctoKit.xcodeproj/xcshareddata/xcschemes/OctoKit MacTests.xcscheme create mode 100644 OctoKit/Parameters.swift create mode 100644 OctoKit/PullRequest.swift create mode 100644 OctoKitTests/PullRequestTests.swift create mode 100644 OctoKitTests/pull_request.json create mode 100644 OctoKitTests/pull_requests.json diff --git a/OctoKit.xcodeproj/project.pbxproj b/OctoKit.xcodeproj/project.pbxproj index ae79da77..e721746b 100644 --- a/OctoKit.xcodeproj/project.pbxproj +++ b/OctoKit.xcodeproj/project.pbxproj @@ -96,6 +96,23 @@ 23F6434F1C7AEF70000427B3 /* user_repos.json in Resources */ = {isa = PBXBuildFile; fileRef = 234F4BDC1BDDE44600A58EF7 /* user_repos.json */; }; 23F643501C7AEF72000427B3 /* users.json in Resources */ = {isa = PBXBuildFile; fileRef = E7EE59DF1BE139FD0012E3D2 /* users.json */; }; 23F643511C7AEF73000427B3 /* users.json in Resources */ = {isa = PBXBuildFile; fileRef = E7EE59DF1BE139FD0012E3D2 /* users.json */; }; + BF8C711C2C6B42F9F323FCFE /* pull_requests.json in Resources */ = {isa = PBXBuildFile; fileRef = BF8C79B71035B425F7748392 /* pull_requests.json */; }; + BF8C716EB8D5CA2CBBA745CB /* pull_request.json in Resources */ = {isa = PBXBuildFile; fileRef = BF8C77314F563A710F11E2F6 /* pull_request.json */; }; + BF8C719220F02AC04EF3D137 /* PullRequestTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF8C76EB002802C14A08F63E /* PullRequestTests.swift */; }; + BF8C725A44F262E5305385CC /* PullRequestTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF8C76EB002802C14A08F63E /* PullRequestTests.swift */; }; + BF8C732A1D13EFA1DE994A6B /* PullRequestTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF8C76EB002802C14A08F63E /* PullRequestTests.swift */; }; + BF8C7567F24BC2E1EB83EE57 /* Parameters.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF8C72B985869B84F46B4E9D /* Parameters.swift */; }; + BF8C7808F0A0A71D0110AD43 /* PullRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF8C73E0EF3CEEBDEA68DD5E /* PullRequest.swift */; }; + BF8C78845606511558E7B929 /* pull_requests.json in Resources */ = {isa = PBXBuildFile; fileRef = BF8C79B71035B425F7748392 /* pull_requests.json */; }; + BF8C7923F427B3CFC6833337 /* pull_requests.json in Resources */ = {isa = PBXBuildFile; fileRef = BF8C79B71035B425F7748392 /* pull_requests.json */; }; + BF8C797115D9BB2DE41E59E6 /* PullRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF8C73E0EF3CEEBDEA68DD5E /* PullRequest.swift */; }; + BF8C7A3F2B4817EF3AD1B315 /* Parameters.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF8C72B985869B84F46B4E9D /* Parameters.swift */; }; + BF8C7A686709462323C702D8 /* pull_request.json in Resources */ = {isa = PBXBuildFile; fileRef = BF8C77314F563A710F11E2F6 /* pull_request.json */; }; + BF8C7AB9EBD2E18007A8B77D /* Parameters.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF8C72B985869B84F46B4E9D /* Parameters.swift */; }; + BF8C7B976A0652C486FAF736 /* pull_request.json in Resources */ = {isa = PBXBuildFile; fileRef = BF8C77314F563A710F11E2F6 /* pull_request.json */; }; + BF8C7BE0F4071324EBDCA204 /* PullRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF8C73E0EF3CEEBDEA68DD5E /* PullRequest.swift */; }; + BF8C7DEE90DD25CBCA4AEE71 /* Parameters.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF8C72B985869B84F46B4E9D /* Parameters.swift */; }; + BF8C7FFFDDAFA560EBEC35EE /* PullRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF8C73E0EF3CEEBDEA68DD5E /* PullRequest.swift */; }; DABBDE501C8C0C20008F57CD /* issue.json in Resources */ = {isa = PBXBuildFile; fileRef = DABBDE4F1C8C0C20008F57CD /* issue.json */; }; DABBDE511C8C0C20008F57CD /* issue.json in Resources */ = {isa = PBXBuildFile; fileRef = DABBDE4F1C8C0C20008F57CD /* issue.json */; }; DABBDE521C8C0C20008F57CD /* issue.json in Resources */ = {isa = PBXBuildFile; fileRef = DABBDE4F1C8C0C20008F57CD /* issue.json */; }; @@ -221,6 +238,11 @@ 23CAF2D81C7AB9DB005011C4 /* RequestKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = RequestKit.framework; path = Carthage/Build/watchOS/RequestKit.framework; sourceTree = ""; }; 23F6433C1C7AEEB6000427B3 /* Nocilla.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Nocilla.framework; path = Carthage/Build/tvOS/Nocilla.framework; sourceTree = ""; }; 23F643421C7AEF2F000427B3 /* Nocilla.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Nocilla.framework; path = Carthage/Build/Mac/Nocilla.framework; sourceTree = ""; }; + BF8C72B985869B84F46B4E9D /* Parameters.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Parameters.swift; sourceTree = ""; }; + BF8C73E0EF3CEEBDEA68DD5E /* PullRequest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PullRequest.swift; sourceTree = ""; }; + BF8C76EB002802C14A08F63E /* PullRequestTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PullRequestTests.swift; sourceTree = ""; }; + BF8C77314F563A710F11E2F6 /* pull_request.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = pull_request.json; sourceTree = ""; }; + BF8C79B71035B425F7748392 /* pull_requests.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = pull_requests.json; sourceTree = ""; }; DABBDE4F1C8C0C20008F57CD /* issue.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = issue.json; path = Fixtures/issue.json; sourceTree = ""; }; DAEFC58F1C83D85100CF3785 /* Label.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Label.swift; sourceTree = ""; }; DAEFC5941C83EF0D00CF3785 /* Milestone.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Milestone.swift; sourceTree = ""; }; @@ -310,6 +332,7 @@ 234F4BCF1BDDE3F900A58EF7 /* UserTests.swift */, 23A0521E1CA924950068BFF7 /* OctoKitURLTestSession.swift */, 234F4BAD1BDDE31A00A58EF7 /* Info.plist */, + BF8C76EB002802C14A08F63E /* PullRequestTests.swift */, ); path = OctoKitTests; sourceTree = ""; @@ -325,6 +348,8 @@ 234F4BDB1BDDE44600A58EF7 /* user_mietzmithut.json */, 234F4BDC1BDDE44600A58EF7 /* user_repos.json */, E7EE59DF1BE139FD0012E3D2 /* users.json */, + BF8C79B71035B425F7748392 /* pull_requests.json */, + BF8C77314F563A710F11E2F6 /* pull_request.json */, ); name = Fixtures; sourceTree = ""; @@ -346,6 +371,8 @@ F8711EA11BFCAE9F005DDACA /* Time.swift */, 237F91E31E5AEC82005FAA6B /* URL+URLParameters.swift */, 239BE7CB1B8C47A100D2CE22 /* Supporting Files */, + BF8C73E0EF3CEEBDEA68DD5E /* PullRequest.swift */, + BF8C72B985869B84F46B4E9D /* Parameters.swift */, ); path = OctoKit; sourceTree = ""; @@ -640,6 +667,8 @@ 234F4BE11BDDE44600A58EF7 /* user_repos.json in Resources */, 234F4BE01BDDE44600A58EF7 /* user_mietzmithut.json in Resources */, E7EDEA6E1C871D0E006BAAF2 /* issues.json in Resources */, + BF8C78845606511558E7B929 /* pull_requests.json in Resources */, + BF8C7B976A0652C486FAF736 /* pull_request.json in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -669,6 +698,8 @@ 23F6434E1C7AEF6F000427B3 /* user_repos.json in Resources */, 23F6434C1C7AEF6C000427B3 /* user_mietzmithut.json in Resources */, E7EDEA741C871FA8006BAAF2 /* issues.json in Resources */, + BF8C7923F427B3CFC6833337 /* pull_requests.json in Resources */, + BF8C7A686709462323C702D8 /* pull_request.json in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -691,6 +722,8 @@ 23F6434F1C7AEF70000427B3 /* user_repos.json in Resources */, 23F6434D1C7AEF6D000427B3 /* user_mietzmithut.json in Resources */, E7EDEA751C871FA9006BAAF2 /* issues.json in Resources */, + BF8C711C2C6B42F9F323FCFE /* pull_requests.json in Resources */, + BF8C716EB8D5CA2CBBA745CB /* pull_request.json in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -718,6 +751,7 @@ 234F4BD01BDDE3F900A58EF7 /* ConfigurationTests.swift in Sources */, 234F4BD21BDDE3F900A58EF7 /* OctokitSwiftTests.swift in Sources */, E7EE59DA1BE10DA60012E3D2 /* StarsTests.swift in Sources */, + BF8C719220F02AC04EF3D137 /* PullRequestTests.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -737,6 +771,8 @@ 23B2678B1BDDD756003887E3 /* Octokit.swift in Sources */, E7EDEA6A1C871CEB006BAAF2 /* Issue.swift in Sources */, DAEFC5901C83D85100CF3785 /* Label.swift in Sources */, + BF8C7BE0F4071324EBDCA204 /* PullRequest.swift in Sources */, + BF8C7567F24BC2E1EB83EE57 /* Parameters.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -756,6 +792,8 @@ 23CAF2A81C7AB6C6005011C4 /* Octokit.swift in Sources */, E7EDEA6F1C871F81006BAAF2 /* Issue.swift in Sources */, DAEFC5911C83D85100CF3785 /* Label.swift in Sources */, + BF8C797115D9BB2DE41E59E6 /* PullRequest.swift in Sources */, + BF8C7DEE90DD25CBCA4AEE71 /* Parameters.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -773,6 +811,7 @@ 23CAF2CA1C7AB711005011C4 /* UserTests.swift in Sources */, 23CAF2C21C7AB705005011C4 /* RepositoryTests.swift in Sources */, 23CAF2BA1C7AB6F1005011C4 /* ConfigurationTests.swift in Sources */, + BF8C725A44F262E5305385CC /* PullRequestTests.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -792,6 +831,8 @@ 23CAF2A91C7AB6C6005011C4 /* Octokit.swift in Sources */, E7EDEA701C871F81006BAAF2 /* Issue.swift in Sources */, DAEFC5921C83D85100CF3785 /* Label.swift in Sources */, + BF8C7FFFDDAFA560EBEC35EE /* PullRequest.swift in Sources */, + BF8C7A3F2B4817EF3AD1B315 /* Parameters.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -809,6 +850,7 @@ 23CAF2CB1C7AB712005011C4 /* UserTests.swift in Sources */, 23CAF2C31C7AB706005011C4 /* RepositoryTests.swift in Sources */, 23CAF2BB1C7AB6F1005011C4 /* ConfigurationTests.swift in Sources */, + BF8C732A1D13EFA1DE994A6B /* PullRequestTests.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -828,6 +870,8 @@ 23CAF2AA1C7AB6C7005011C4 /* Octokit.swift in Sources */, E7EDEA711C871F82006BAAF2 /* Issue.swift in Sources */, DAEFC5931C83D85100CF3785 /* Label.swift in Sources */, + BF8C7808F0A0A71D0110AD43 /* PullRequest.swift in Sources */, + BF8C7AB9EBD2E18007A8B77D /* Parameters.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/OctoKit.xcodeproj/xcshareddata/xcschemes/OctoKit MacTests.xcscheme b/OctoKit.xcodeproj/xcshareddata/xcschemes/OctoKit MacTests.xcscheme new file mode 100644 index 00000000..da59dc95 --- /dev/null +++ b/OctoKit.xcodeproj/xcshareddata/xcschemes/OctoKit MacTests.xcscheme @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OctoKit/Parameters.swift b/OctoKit/Parameters.swift new file mode 100644 index 00000000..60fff401 --- /dev/null +++ b/OctoKit/Parameters.swift @@ -0,0 +1,18 @@ +// +// Created by Marcin on 19/05/2017. +// Copyright (c) 2017 nerdish by nature. All rights reserved. +// + +import Foundation + +public enum SortDirection: String { + case asc = "asc" + case desc = "desc" +} + +public enum SortType: String { + case created = "created" + case updated = "updated" + case popularity = "popularity" + case longRunning = "long-running" +} diff --git a/OctoKit/PullRequest.swift b/OctoKit/PullRequest.swift new file mode 100644 index 00000000..3d1b3b6d --- /dev/null +++ b/OctoKit/PullRequest.swift @@ -0,0 +1,207 @@ +import Foundation +import RequestKit + +@objc open class PullRequest: NSObject { + + open var id: Int + open var url: URL? + + open var htmlURL: URL? + open var diffURL: URL? + open var patchURL: URL? + open var issueURL: URL? + open var commitsURL: URL? + open var reviewCommentsURL: URL? + open var reviewCommentURL: URL? + open var commentsURL: URL? + open var statusesURL: URL? + + open var number: Int? + open var state: Openness? + open var title: String? + open var body: String? + + open var assignee: User? + open var milestone: Milestone? + + open var locked: Bool? + open var createdAt: Date? + open var updatedAt: Date? + open var closedAt: Date? + open var mergedAt: Date? + + open var user: User? + + public init(_ json: [String: AnyObject]) { + if let id = json["id"] as? Int { + self.id = id + + if let urlString = json["url"] as? String, let url = URL(string: urlString) { + self.url = url + } + if let diffURL = json["diff_url"] as? String, let url = URL(string: diffURL) { + self.diffURL = url + } + if let patchURL = json["patch_url"] as? String, let url = URL(string: patchURL) { + self.patchURL = url + } + if let issueURL = json["issue_url"] as? String, let url = URL(string: issueURL) { + self.patchURL = url + } + if let commitsURL = json["commits_url"] as? String, let url = URL(string: commitsURL) { + self.commitsURL = url + } + if let reviewCommentsURL = json["review_comments_url"] as? String, + let url = URL(string: reviewCommentsURL) { + self.reviewCommentsURL = url + } + if let reviewCommentURL = json["review_comment_url"] as? String, let url = URL(string: reviewCommentURL) { + self.reviewCommentURL = url + } + if let commentsURL = json["comments_url"] as? String, let url = URL(string: commentsURL) { + self.commentsURL = url + } + if let statusesURL = json["statuses_url"] as? String, let url = URL(string: statusesURL) { + self.statusesURL = url + } + number = json["number"] as? Int + state = Openness(rawValue: json["state"] as? String ?? "") + title = json["title"] as? String + body = json["body"] as? String + + assignee = User(json["assignee"] as? [String: AnyObject] ?? [:]) + milestone = Milestone(json["milestone"] as? [String: AnyObject] ?? [:]) + + locked = json["locked"] as? Bool + closedAt = Time.rfc3339Date(json["closed_at"] as? String) + createdAt = Time.rfc3339Date(json["created_at"] as? String) + updatedAt = Time.rfc3339Date(json["updated_at"] as? String) + mergedAt = Time.rfc3339Date(json["merged_at"] as? String) + } else { + id = -1 + } + } +} + +// MARK: Request + +public extension Octokit { + + /** + Get a single pull request + - parameter session: RequestKitURLSession, defaults to NSURLSession.sharedSession() + - parameter owner: The user or organization that owns the repositories. + - parameter repository: The name of the repository. + - parameter number: The number of the PR to fetch. + - parameter completion: Callback for the outcome of the fetch. + */ + public func pullRequest(_ session: RequestKitURLSession = URLSession.shared, + owner: String, + repository: String, + number: Int, + completion: @escaping (_ response: Response) -> Void) -> URLSessionDataTaskProtocol? { + + let router = PullRequestRouter.readPullRequest(configuration, owner, repository, "\(number)") + return router.loadJSON(session, expectedResultType: [String: AnyObject].self) { json, error in + if let error = error { + completion(Response.failure(error)) + } else { + if let json = json { + let parsedPullRequest = PullRequest(json) + completion(Response.success(parsedPullRequest)) + } + } + } + } + + /** + Get a list of pull requests + - parameter session: RequestKitURLSession, defaults to NSURLSession.sharedSession() + - parameter owner: The user or organization that owns the repositories. + - parameter repository: The name of the repository. + - parameter base: Filter pulls by base branch name. + - parameter state: Filter pulls by their state. + - parameter direction: The direction of the sort. + - parameter completion: Callback for the outcome of the fetch. + */ + public func pullRequests(_ session: RequestKitURLSession = URLSession.shared, + owner: String, + repository: String, + base: String? = nil, + state: Openness = .Open, + sort: SortType = .created, + direction: SortDirection = .desc, + completion: @escaping (_ response: Response<[PullRequest]>) -> Void) -> URLSessionDataTaskProtocol? { + + let router = PullRequestRouter.readPullRequests(configuration, owner, repository, base, state, sort, direction) + return router.loadJSON(session, expectedResultType: [[String: AnyObject]].self) { json, error in + if let error = error { + completion(Response.failure(error)) + } else { + if let json = json { + let parsedPullRequest = json.map { + PullRequest($0) + } + completion(Response.success(parsedPullRequest)) + } + } + } + } +} + +// MARK: Router + +enum PullRequestRouter: JSONPostRouter { + case readPullRequest(Configuration, String, String, String) + case readPullRequests(Configuration, String, String, String?, Openness, SortType, SortDirection) + + var method: HTTPMethod { + switch self { + case .readPullRequest, + .readPullRequests: + return .GET + } + } + + var encoding: HTTPEncoding { + switch self { + default: + return .url + } + } + + var configuration: Configuration { + switch self { + case .readPullRequest(let config, _, _, _): return config + case .readPullRequests(let config, _, _, _, _, _, _): return config + } + } + + var params: [String: Any] { + switch self { + case .readPullRequest(_, _, _, _): + return [:] + case .readPullRequests(_, _, _, let base, let state, let sort, let direction): + var parameters = [ + "state": state.rawValue, + "sort": sort.rawValue, + "direction": direction.rawValue + ] + + if let base = base { + parameters["base"] = base + } + + return parameters + } + } + + var path: String { + switch self { + case .readPullRequest(_, let owner, let repository, let number): + return "repos/\(owner)/\(repository)/pulls/\(number)" + case .readPullRequests(_, let owner, let repository, _, _, _, _): + return "repos/\(owner)/\(repository)/pulls" + } + } +} diff --git a/OctoKitTests/PullRequestTests.swift b/OctoKitTests/PullRequestTests.swift new file mode 100644 index 00000000..1a961b31 --- /dev/null +++ b/OctoKitTests/PullRequestTests.swift @@ -0,0 +1,48 @@ +import XCTest +import OctoKit + +class PullRequeastTests: XCTestCase { + + func testGetPullRequest() { + let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/repos/octocat/Hello-World/pulls/1", + expectedHTTPMethod: "GET", + jsonFile: "pull_request", + statusCode: 200 + ) + + let task = Octokit().pullRequest(session, owner: "octocat", repository: "Hello-World", number: 1) { response in + switch response { + case .success(let pullRequests): + XCTAssertEqual(pullRequests.id, 1) + XCTAssertEqual(pullRequests.title, "new-feature") + XCTAssertEqual(pullRequests.body, "Please pull these awesome changes") + case .failure: + XCTAssert(false, "should not get an error") + } + } + XCTAssertNotNil(task) + XCTAssertTrue(session.wasCalled) + } + + func testGetPullRequests() { + let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/repos/octocat/Hello-World/pulls?base=develop&direction=desc&sort=created&state=open", + expectedHTTPMethod: "GET", + jsonFile: "pull_requests", + statusCode: 200 + ) + + let task = Octokit().pullRequests(session, owner: "octocat", repository: "Hello-World", base: "develop", state: Openness.Open) { response in + switch response { + case .success(let pullRequests): + XCTAssertEqual(pullRequests.count, 1) + XCTAssertEqual(pullRequests.first?.title, "new-feature") + XCTAssertEqual(pullRequests.first?.body, "Please pull these awesome changes") + case .failure: + XCTAssert(false, "should not get an error") + } + } + XCTAssertNotNil(task) + XCTAssertTrue(session.wasCalled) + } + +} diff --git a/OctoKitTests/pull_request.json b/OctoKitTests/pull_request.json new file mode 100644 index 00000000..9f2a74d4 --- /dev/null +++ b/OctoKitTests/pull_request.json @@ -0,0 +1,399 @@ + { + "id": 1, + "url": "https://api.github.com/repos/octocat/Hello-World/pulls/1347", + "html_url": "https://github.com/octocat/Hello-World/pull/1347", + "diff_url": "https://github.com/octocat/Hello-World/pull/1347.diff", + "patch_url": "https://github.com/octocat/Hello-World/pull/1347.patch", + "issue_url": "https://api.github.com/repos/octocat/Hello-World/issues/1347", + "commits_url": "https://api.github.com/repos/octocat/Hello-World/pulls/1347/commits", + "review_comments_url": "https://api.github.com/repos/octocat/Hello-World/pulls/1347/comments", + "review_comment_url": "https://api.github.com/repos/octocat/Hello-World/pulls/comments{/number}", + "comments_url": "https://api.github.com/repos/octocat/Hello-World/issues/1347/comments", + "statuses_url": "https://api.github.com/repos/octocat/Hello-World/statuses/6dcb09b5b57875f334f61aebed695e2e4193db5e", + "number": 1347, + "state": "open", + "title": "new-feature", + "body": "Please pull these awesome changes", + "assignee": { + "login": "octocat", + "id": 1, + "avatar_url": "https://github.com/images/error/octocat_happy.gif", + "gravatar_id": "", + "url": "https://api.github.com/users/octocat", + "html_url": "https://github.com/octocat", + "followers_url": "https://api.github.com/users/octocat/followers", + "following_url": "https://api.github.com/users/octocat/following{/other_user}", + "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", + "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", + "organizations_url": "https://api.github.com/users/octocat/orgs", + "repos_url": "https://api.github.com/users/octocat/repos", + "events_url": "https://api.github.com/users/octocat/events{/privacy}", + "received_events_url": "https://api.github.com/users/octocat/received_events", + "type": "User", + "site_admin": false + }, + "milestone": { + "url": "https://api.github.com/repos/octocat/Hello-World/milestones/1", + "html_url": "https://github.com/octocat/Hello-World/milestones/v1.0", + "labels_url": "https://api.github.com/repos/octocat/Hello-World/milestones/1/labels", + "id": 1002604, + "number": 1, + "state": "open", + "title": "v1.0", + "description": "Tracking milestone for version 1.0", + "creator": { + "login": "octocat", + "id": 1, + "avatar_url": "https://github.com/images/error/octocat_happy.gif", + "gravatar_id": "", + "url": "https://api.github.com/users/octocat", + "html_url": "https://github.com/octocat", + "followers_url": "https://api.github.com/users/octocat/followers", + "following_url": "https://api.github.com/users/octocat/following{/other_user}", + "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", + "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", + "organizations_url": "https://api.github.com/users/octocat/orgs", + "repos_url": "https://api.github.com/users/octocat/repos", + "events_url": "https://api.github.com/users/octocat/events{/privacy}", + "received_events_url": "https://api.github.com/users/octocat/received_events", + "type": "User", + "site_admin": false + }, + "open_issues": 4, + "closed_issues": 8, + "created_at": "2011-04-10T20:09:31Z", + "updated_at": "2014-03-03T18:58:10Z", + "closed_at": "2013-02-12T13:22:01Z", + "due_on": "2012-10-09T23:39:01Z" + }, + "locked": false, + "created_at": "2011-01-26T19:01:12Z", + "updated_at": "2011-01-26T19:01:12Z", + "closed_at": "2011-01-26T19:01:12Z", + "merged_at": "2011-01-26T19:01:12Z", + "head": { + "label": "new-topic", + "ref": "new-topic", + "sha": "6dcb09b5b57875f334f61aebed695e2e4193db5e", + "user": { + "login": "octocat", + "id": 1, + "avatar_url": "https://github.com/images/error/octocat_happy.gif", + "gravatar_id": "", + "url": "https://api.github.com/users/octocat", + "html_url": "https://github.com/octocat", + "followers_url": "https://api.github.com/users/octocat/followers", + "following_url": "https://api.github.com/users/octocat/following{/other_user}", + "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", + "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", + "organizations_url": "https://api.github.com/users/octocat/orgs", + "repos_url": "https://api.github.com/users/octocat/repos", + "events_url": "https://api.github.com/users/octocat/events{/privacy}", + "received_events_url": "https://api.github.com/users/octocat/received_events", + "type": "User", + "site_admin": false + }, + "repo": { + "id": 1296269, + "owner": { + "login": "octocat", + "id": 1, + "avatar_url": "https://github.com/images/error/octocat_happy.gif", + "gravatar_id": "", + "url": "https://api.github.com/users/octocat", + "html_url": "https://github.com/octocat", + "followers_url": "https://api.github.com/users/octocat/followers", + "following_url": "https://api.github.com/users/octocat/following{/other_user}", + "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", + "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", + "organizations_url": "https://api.github.com/users/octocat/orgs", + "repos_url": "https://api.github.com/users/octocat/repos", + "events_url": "https://api.github.com/users/octocat/events{/privacy}", + "received_events_url": "https://api.github.com/users/octocat/received_events", + "type": "User", + "site_admin": false + }, + "name": "Hello-World", + "full_name": "octocat/Hello-World", + "description": "This your first repo!", + "private": false, + "fork": true, + "url": "https://api.github.com/repos/octocat/Hello-World", + "html_url": "https://github.com/octocat/Hello-World", + "archive_url": "http://api.github.com/repos/octocat/Hello-World/{archive_format}{/ref}", + "assignees_url": "http://api.github.com/repos/octocat/Hello-World/assignees{/user}", + "blobs_url": "http://api.github.com/repos/octocat/Hello-World/git/blobs{/sha}", + "branches_url": "http://api.github.com/repos/octocat/Hello-World/branches{/branch}", + "clone_url": "https://github.com/octocat/Hello-World.git", + "collaborators_url": "http://api.github.com/repos/octocat/Hello-World/collaborators{/collaborator}", + "comments_url": "http://api.github.com/repos/octocat/Hello-World/comments{/number}", + "commits_url": "http://api.github.com/repos/octocat/Hello-World/commits{/sha}", + "compare_url": "http://api.github.com/repos/octocat/Hello-World/compare/{base}...{head}", + "contents_url": "http://api.github.com/repos/octocat/Hello-World/contents/{+path}", + "contributors_url": "http://api.github.com/repos/octocat/Hello-World/contributors", + "deployments_url": "http://api.github.com/repos/octocat/Hello-World/deployments", + "downloads_url": "http://api.github.com/repos/octocat/Hello-World/downloads", + "events_url": "http://api.github.com/repos/octocat/Hello-World/events", + "forks_url": "http://api.github.com/repos/octocat/Hello-World/forks", + "git_commits_url": "http://api.github.com/repos/octocat/Hello-World/git/commits{/sha}", + "git_refs_url": "http://api.github.com/repos/octocat/Hello-World/git/refs{/sha}", + "git_tags_url": "http://api.github.com/repos/octocat/Hello-World/git/tags{/sha}", + "git_url": "git:github.com/octocat/Hello-World.git", + "hooks_url": "http://api.github.com/repos/octocat/Hello-World/hooks", + "issue_comment_url": "http://api.github.com/repos/octocat/Hello-World/issues/comments{/number}", + "issue_events_url": "http://api.github.com/repos/octocat/Hello-World/issues/events{/number}", + "issues_url": "http://api.github.com/repos/octocat/Hello-World/issues{/number}", + "keys_url": "http://api.github.com/repos/octocat/Hello-World/keys{/key_id}", + "labels_url": "http://api.github.com/repos/octocat/Hello-World/labels{/name}", + "languages_url": "http://api.github.com/repos/octocat/Hello-World/languages", + "merges_url": "http://api.github.com/repos/octocat/Hello-World/merges", + "milestones_url": "http://api.github.com/repos/octocat/Hello-World/milestones{/number}", + "mirror_url": "git:git.example.com/octocat/Hello-World", + "notifications_url": "http://api.github.com/repos/octocat/Hello-World/notifications{?since, all, participating}", + "pulls_url": "http://api.github.com/repos/octocat/Hello-World/pulls{/number}", + "releases_url": "http://api.github.com/repos/octocat/Hello-World/releases{/id}", + "ssh_url": "git@github.com:octocat/Hello-World.git", + "stargazers_url": "http://api.github.com/repos/octocat/Hello-World/stargazers", + "statuses_url": "http://api.github.com/repos/octocat/Hello-World/statuses/{sha}", + "subscribers_url": "http://api.github.com/repos/octocat/Hello-World/subscribers", + "subscription_url": "http://api.github.com/repos/octocat/Hello-World/subscription", + "svn_url": "https://svn.github.com/octocat/Hello-World", + "tags_url": "http://api.github.com/repos/octocat/Hello-World/tags", + "teams_url": "http://api.github.com/repos/octocat/Hello-World/teams", + "trees_url": "http://api.github.com/repos/octocat/Hello-World/git/trees{/sha}", + "homepage": "https://github.com", + "language": null, + "forks_count": 9, + "stargazers_count": 80, + "watchers_count": 80, + "size": 108, + "default_branch": "master", + "open_issues_count": 0, + "topics": [ + "octocat", + "atom", + "electron", + "API" + ], + "has_issues": true, + "has_wiki": true, + "has_pages": false, + "has_downloads": true, + "pushed_at": "2011-01-26T19:06:43Z", + "created_at": "2011-01-26T19:01:12Z", + "updated_at": "2011-01-26T19:14:43Z", + "permissions": { + "admin": false, + "push": false, + "pull": true + }, + "allow_rebase_merge": true, + "allow_squash_merge": true, + "allow_merge_commit": true, + "subscribers_count": 42, + "network_count": 0 + } + }, + "base": { + "label": "master", + "ref": "master", + "sha": "6dcb09b5b57875f334f61aebed695e2e4193db5e", + "user": { + "login": "octocat", + "id": 1, + "avatar_url": "https://github.com/images/error/octocat_happy.gif", + "gravatar_id": "", + "url": "https://api.github.com/users/octocat", + "html_url": "https://github.com/octocat", + "followers_url": "https://api.github.com/users/octocat/followers", + "following_url": "https://api.github.com/users/octocat/following{/other_user}", + "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", + "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", + "organizations_url": "https://api.github.com/users/octocat/orgs", + "repos_url": "https://api.github.com/users/octocat/repos", + "events_url": "https://api.github.com/users/octocat/events{/privacy}", + "received_events_url": "https://api.github.com/users/octocat/received_events", + "type": "User", + "site_admin": false + }, + "repo": { + "id": 1296269, + "owner": { + "login": "octocat", + "id": 1, + "avatar_url": "https://github.com/images/error/octocat_happy.gif", + "gravatar_id": "", + "url": "https://api.github.com/users/octocat", + "html_url": "https://github.com/octocat", + "followers_url": "https://api.github.com/users/octocat/followers", + "following_url": "https://api.github.com/users/octocat/following{/other_user}", + "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", + "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", + "organizations_url": "https://api.github.com/users/octocat/orgs", + "repos_url": "https://api.github.com/users/octocat/repos", + "events_url": "https://api.github.com/users/octocat/events{/privacy}", + "received_events_url": "https://api.github.com/users/octocat/received_events", + "type": "User", + "site_admin": false + }, + "name": "Hello-World", + "full_name": "octocat/Hello-World", + "description": "This your first repo!", + "private": false, + "fork": true, + "url": "https://api.github.com/repos/octocat/Hello-World", + "html_url": "https://github.com/octocat/Hello-World", + "archive_url": "http://api.github.com/repos/octocat/Hello-World/{archive_format}{/ref}", + "assignees_url": "http://api.github.com/repos/octocat/Hello-World/assignees{/user}", + "blobs_url": "http://api.github.com/repos/octocat/Hello-World/git/blobs{/sha}", + "branches_url": "http://api.github.com/repos/octocat/Hello-World/branches{/branch}", + "clone_url": "https://github.com/octocat/Hello-World.git", + "collaborators_url": "http://api.github.com/repos/octocat/Hello-World/collaborators{/collaborator}", + "comments_url": "http://api.github.com/repos/octocat/Hello-World/comments{/number}", + "commits_url": "http://api.github.com/repos/octocat/Hello-World/commits{/sha}", + "compare_url": "http://api.github.com/repos/octocat/Hello-World/compare/{base}...{head}", + "contents_url": "http://api.github.com/repos/octocat/Hello-World/contents/{+path}", + "contributors_url": "http://api.github.com/repos/octocat/Hello-World/contributors", + "deployments_url": "http://api.github.com/repos/octocat/Hello-World/deployments", + "downloads_url": "http://api.github.com/repos/octocat/Hello-World/downloads", + "events_url": "http://api.github.com/repos/octocat/Hello-World/events", + "forks_url": "http://api.github.com/repos/octocat/Hello-World/forks", + "git_commits_url": "http://api.github.com/repos/octocat/Hello-World/git/commits{/sha}", + "git_refs_url": "http://api.github.com/repos/octocat/Hello-World/git/refs{/sha}", + "git_tags_url": "http://api.github.com/repos/octocat/Hello-World/git/tags{/sha}", + "git_url": "git:github.com/octocat/Hello-World.git", + "hooks_url": "http://api.github.com/repos/octocat/Hello-World/hooks", + "issue_comment_url": "http://api.github.com/repos/octocat/Hello-World/issues/comments{/number}", + "issue_events_url": "http://api.github.com/repos/octocat/Hello-World/issues/events{/number}", + "issues_url": "http://api.github.com/repos/octocat/Hello-World/issues{/number}", + "keys_url": "http://api.github.com/repos/octocat/Hello-World/keys{/key_id}", + "labels_url": "http://api.github.com/repos/octocat/Hello-World/labels{/name}", + "languages_url": "http://api.github.com/repos/octocat/Hello-World/languages", + "merges_url": "http://api.github.com/repos/octocat/Hello-World/merges", + "milestones_url": "http://api.github.com/repos/octocat/Hello-World/milestones{/number}", + "mirror_url": "git:git.example.com/octocat/Hello-World", + "notifications_url": "http://api.github.com/repos/octocat/Hello-World/notifications{?since, all, participating}", + "pulls_url": "http://api.github.com/repos/octocat/Hello-World/pulls{/number}", + "releases_url": "http://api.github.com/repos/octocat/Hello-World/releases{/id}", + "ssh_url": "git@github.com:octocat/Hello-World.git", + "stargazers_url": "http://api.github.com/repos/octocat/Hello-World/stargazers", + "statuses_url": "http://api.github.com/repos/octocat/Hello-World/statuses/{sha}", + "subscribers_url": "http://api.github.com/repos/octocat/Hello-World/subscribers", + "subscription_url": "http://api.github.com/repos/octocat/Hello-World/subscription", + "svn_url": "https://svn.github.com/octocat/Hello-World", + "tags_url": "http://api.github.com/repos/octocat/Hello-World/tags", + "teams_url": "http://api.github.com/repos/octocat/Hello-World/teams", + "trees_url": "http://api.github.com/repos/octocat/Hello-World/git/trees{/sha}", + "homepage": "https://github.com", + "language": null, + "forks_count": 9, + "stargazers_count": 80, + "watchers_count": 80, + "size": 108, + "default_branch": "master", + "open_issues_count": 0, + "topics": [ + "octocat", + "atom", + "electron", + "API" + ], + "has_issues": true, + "has_wiki": true, + "has_pages": false, + "has_downloads": true, + "pushed_at": "2011-01-26T19:06:43Z", + "created_at": "2011-01-26T19:01:12Z", + "updated_at": "2011-01-26T19:14:43Z", + "permissions": { + "admin": false, + "push": false, + "pull": true + }, + "allow_rebase_merge": true, + "allow_squash_merge": true, + "allow_merge_commit": true, + "subscribers_count": 42, + "network_count": 0 + } + }, + "_links": { + "self": { + "href": "https://api.github.com/repos/octocat/Hello-World/pulls/1347" + }, + "html": { + "href": "https://github.com/octocat/Hello-World/pull/1347" + }, + "issue": { + "href": "https://api.github.com/repos/octocat/Hello-World/issues/1347" + }, + "comments": { + "href": "https://api.github.com/repos/octocat/Hello-World/issues/1347/comments" + }, + "review_comments": { + "href": "https://api.github.com/repos/octocat/Hello-World/pulls/1347/comments" + }, + "review_comment": { + "href": "https://api.github.com/repos/octocat/Hello-World/pulls/comments{/number}" + }, + "commits": { + "href": "https://api.github.com/repos/octocat/Hello-World/pulls/1347/commits" + }, + "statuses": { + "href": "https://api.github.com/repos/octocat/Hello-World/statuses/6dcb09b5b57875f334f61aebed695e2e4193db5e" + } + }, + "user": { + "login": "octocat", + "id": 1, + "avatar_url": "https://github.com/images/error/octocat_happy.gif", + "gravatar_id": "", + "url": "https://api.github.com/users/octocat", + "html_url": "https://github.com/octocat", + "followers_url": "https://api.github.com/users/octocat/followers", + "following_url": "https://api.github.com/users/octocat/following{/other_user}", + "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", + "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", + "organizations_url": "https://api.github.com/users/octocat/orgs", + "repos_url": "https://api.github.com/users/octocat/repos", + "events_url": "https://api.github.com/users/octocat/events{/privacy}", + "received_events_url": "https://api.github.com/users/octocat/received_events", + "type": "User", + "site_admin": false + }, + "merge_commit_sha": "e5bd3914e2e596debea16f433f57875b5b90bcd6", + "merged": false, + "mergeable": true, + "merged_by": { + "login": "octocat", + "id": 1, + "avatar_url": "https://github.com/images/error/octocat_happy.gif", + "gravatar_id": "", + "url": "https://api.github.com/users/octocat", + "html_url": "https://github.com/octocat", + "followers_url": "https://api.github.com/users/octocat/followers", + "following_url": "https://api.github.com/users/octocat/following{/other_user}", + "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", + "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", + "organizations_url": "https://api.github.com/users/octocat/orgs", + "repos_url": "https://api.github.com/users/octocat/repos", + "events_url": "https://api.github.com/users/octocat/events{/privacy}", + "received_events_url": "https://api.github.com/users/octocat/received_events", + "type": "User", + "site_admin": false + }, + "comments": 10, + "commits": 3, + "additions": 100, + "deletions": 3, + "changed_files": 5, + "maintainer_can_modify": true +} diff --git a/OctoKitTests/pull_requests.json b/OctoKitTests/pull_requests.json new file mode 100644 index 00000000..5b98375c --- /dev/null +++ b/OctoKitTests/pull_requests.json @@ -0,0 +1,373 @@ + [ + { + "id": 1, + "url": "https://api.github.com/repos/octocat/Hello-World/pulls/1347", + "html_url": "https://github.com/octocat/Hello-World/pull/1347", + "diff_url": "https://github.com/octocat/Hello-World/pull/1347.diff", + "patch_url": "https://github.com/octocat/Hello-World/pull/1347.patch", + "issue_url": "https://api.github.com/repos/octocat/Hello-World/issues/1347", + "commits_url": "https://api.github.com/repos/octocat/Hello-World/pulls/1347/commits", + "review_comments_url": "https://api.github.com/repos/octocat/Hello-World/pulls/1347/comments", + "review_comment_url": "https://api.github.com/repos/octocat/Hello-World/pulls/comments{/number}", + "comments_url": "https://api.github.com/repos/octocat/Hello-World/issues/1347/comments", + "statuses_url": "https://api.github.com/repos/octocat/Hello-World/statuses/6dcb09b5b57875f334f61aebed695e2e4193db5e", + "number": 1347, + "state": "open", + "title": "new-feature", + "body": "Please pull these awesome changes", + "assignee": { + "login": "octocat", + "id": 1, + "avatar_url": "https://github.com/images/error/octocat_happy.gif", + "gravatar_id": "", + "url": "https://api.github.com/users/octocat", + "html_url": "https://github.com/octocat", + "followers_url": "https://api.github.com/users/octocat/followers", + "following_url": "https://api.github.com/users/octocat/following{/other_user}", + "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", + "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", + "organizations_url": "https://api.github.com/users/octocat/orgs", + "repos_url": "https://api.github.com/users/octocat/repos", + "events_url": "https://api.github.com/users/octocat/events{/privacy}", + "received_events_url": "https://api.github.com/users/octocat/received_events", + "type": "User", + "site_admin": false + }, + "milestone": { + "url": "https://api.github.com/repos/octocat/Hello-World/milestones/1", + "html_url": "https://github.com/octocat/Hello-World/milestones/v1.0", + "labels_url": "https://api.github.com/repos/octocat/Hello-World/milestones/1/labels", + "id": 1002604, + "number": 1, + "state": "open", + "title": "v1.0", + "description": "Tracking milestone for version 1.0", + "creator": { + "login": "octocat", + "id": 1, + "avatar_url": "https://github.com/images/error/octocat_happy.gif", + "gravatar_id": "", + "url": "https://api.github.com/users/octocat", + "html_url": "https://github.com/octocat", + "followers_url": "https://api.github.com/users/octocat/followers", + "following_url": "https://api.github.com/users/octocat/following{/other_user}", + "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", + "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", + "organizations_url": "https://api.github.com/users/octocat/orgs", + "repos_url": "https://api.github.com/users/octocat/repos", + "events_url": "https://api.github.com/users/octocat/events{/privacy}", + "received_events_url": "https://api.github.com/users/octocat/received_events", + "type": "User", + "site_admin": false + }, + "open_issues": 4, + "closed_issues": 8, + "created_at": "2011-04-10T20:09:31Z", + "updated_at": "2014-03-03T18:58:10Z", + "closed_at": "2013-02-12T13:22:01Z", + "due_on": "2012-10-09T23:39:01Z" + }, + "locked": false, + "created_at": "2011-01-26T19:01:12Z", + "updated_at": "2011-01-26T19:01:12Z", + "closed_at": "2011-01-26T19:01:12Z", + "merged_at": "2011-01-26T19:01:12Z", + "head": { + "label": "new-topic", + "ref": "new-topic", + "sha": "6dcb09b5b57875f334f61aebed695e2e4193db5e", + "user": { + "login": "octocat", + "id": 1, + "avatar_url": "https://github.com/images/error/octocat_happy.gif", + "gravatar_id": "", + "url": "https://api.github.com/users/octocat", + "html_url": "https://github.com/octocat", + "followers_url": "https://api.github.com/users/octocat/followers", + "following_url": "https://api.github.com/users/octocat/following{/other_user}", + "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", + "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", + "organizations_url": "https://api.github.com/users/octocat/orgs", + "repos_url": "https://api.github.com/users/octocat/repos", + "events_url": "https://api.github.com/users/octocat/events{/privacy}", + "received_events_url": "https://api.github.com/users/octocat/received_events", + "type": "User", + "site_admin": false + }, + "repo": { + "id": 1296269, + "owner": { + "login": "octocat", + "id": 1, + "avatar_url": "https://github.com/images/error/octocat_happy.gif", + "gravatar_id": "", + "url": "https://api.github.com/users/octocat", + "html_url": "https://github.com/octocat", + "followers_url": "https://api.github.com/users/octocat/followers", + "following_url": "https://api.github.com/users/octocat/following{/other_user}", + "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", + "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", + "organizations_url": "https://api.github.com/users/octocat/orgs", + "repos_url": "https://api.github.com/users/octocat/repos", + "events_url": "https://api.github.com/users/octocat/events{/privacy}", + "received_events_url": "https://api.github.com/users/octocat/received_events", + "type": "User", + "site_admin": false + }, + "name": "Hello-World", + "full_name": "octocat/Hello-World", + "description": "This your first repo!", + "private": false, + "fork": true, + "url": "https://api.github.com/repos/octocat/Hello-World", + "html_url": "https://github.com/octocat/Hello-World", + "archive_url": "http://api.github.com/repos/octocat/Hello-World/{archive_format}{/ref}", + "assignees_url": "http://api.github.com/repos/octocat/Hello-World/assignees{/user}", + "blobs_url": "http://api.github.com/repos/octocat/Hello-World/git/blobs{/sha}", + "branches_url": "http://api.github.com/repos/octocat/Hello-World/branches{/branch}", + "clone_url": "https://github.com/octocat/Hello-World.git", + "collaborators_url": "http://api.github.com/repos/octocat/Hello-World/collaborators{/collaborator}", + "comments_url": "http://api.github.com/repos/octocat/Hello-World/comments{/number}", + "commits_url": "http://api.github.com/repos/octocat/Hello-World/commits{/sha}", + "compare_url": "http://api.github.com/repos/octocat/Hello-World/compare/{base}...{head}", + "contents_url": "http://api.github.com/repos/octocat/Hello-World/contents/{+path}", + "contributors_url": "http://api.github.com/repos/octocat/Hello-World/contributors", + "deployments_url": "http://api.github.com/repos/octocat/Hello-World/deployments", + "downloads_url": "http://api.github.com/repos/octocat/Hello-World/downloads", + "events_url": "http://api.github.com/repos/octocat/Hello-World/events", + "forks_url": "http://api.github.com/repos/octocat/Hello-World/forks", + "git_commits_url": "http://api.github.com/repos/octocat/Hello-World/git/commits{/sha}", + "git_refs_url": "http://api.github.com/repos/octocat/Hello-World/git/refs{/sha}", + "git_tags_url": "http://api.github.com/repos/octocat/Hello-World/git/tags{/sha}", + "git_url": "git:github.com/octocat/Hello-World.git", + "hooks_url": "http://api.github.com/repos/octocat/Hello-World/hooks", + "issue_comment_url": "http://api.github.com/repos/octocat/Hello-World/issues/comments{/number}", + "issue_events_url": "http://api.github.com/repos/octocat/Hello-World/issues/events{/number}", + "issues_url": "http://api.github.com/repos/octocat/Hello-World/issues{/number}", + "keys_url": "http://api.github.com/repos/octocat/Hello-World/keys{/key_id}", + "labels_url": "http://api.github.com/repos/octocat/Hello-World/labels{/name}", + "languages_url": "http://api.github.com/repos/octocat/Hello-World/languages", + "merges_url": "http://api.github.com/repos/octocat/Hello-World/merges", + "milestones_url": "http://api.github.com/repos/octocat/Hello-World/milestones{/number}", + "mirror_url": "git:git.example.com/octocat/Hello-World", + "notifications_url": "http://api.github.com/repos/octocat/Hello-World/notifications{?since, all, participating}", + "pulls_url": "http://api.github.com/repos/octocat/Hello-World/pulls{/number}", + "releases_url": "http://api.github.com/repos/octocat/Hello-World/releases{/id}", + "ssh_url": "git@github.com:octocat/Hello-World.git", + "stargazers_url": "http://api.github.com/repos/octocat/Hello-World/stargazers", + "statuses_url": "http://api.github.com/repos/octocat/Hello-World/statuses/{sha}", + "subscribers_url": "http://api.github.com/repos/octocat/Hello-World/subscribers", + "subscription_url": "http://api.github.com/repos/octocat/Hello-World/subscription", + "svn_url": "https://svn.github.com/octocat/Hello-World", + "tags_url": "http://api.github.com/repos/octocat/Hello-World/tags", + "teams_url": "http://api.github.com/repos/octocat/Hello-World/teams", + "trees_url": "http://api.github.com/repos/octocat/Hello-World/git/trees{/sha}", + "homepage": "https://github.com", + "language": null, + "forks_count": 9, + "stargazers_count": 80, + "watchers_count": 80, + "size": 108, + "default_branch": "master", + "open_issues_count": 0, + "topics": [ + "octocat", + "atom", + "electron", + "API" + ], + "has_issues": true, + "has_wiki": true, + "has_pages": false, + "has_downloads": true, + "pushed_at": "2011-01-26T19:06:43Z", + "created_at": "2011-01-26T19:01:12Z", + "updated_at": "2011-01-26T19:14:43Z", + "permissions": { + "admin": false, + "push": false, + "pull": true + }, + "allow_rebase_merge": true, + "allow_squash_merge": true, + "allow_merge_commit": true, + "subscribers_count": 42, + "network_count": 0 + } + }, + "base": { + "label": "master", + "ref": "master", + "sha": "6dcb09b5b57875f334f61aebed695e2e4193db5e", + "user": { + "login": "octocat", + "id": 1, + "avatar_url": "https://github.com/images/error/octocat_happy.gif", + "gravatar_id": "", + "url": "https://api.github.com/users/octocat", + "html_url": "https://github.com/octocat", + "followers_url": "https://api.github.com/users/octocat/followers", + "following_url": "https://api.github.com/users/octocat/following{/other_user}", + "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", + "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", + "organizations_url": "https://api.github.com/users/octocat/orgs", + "repos_url": "https://api.github.com/users/octocat/repos", + "events_url": "https://api.github.com/users/octocat/events{/privacy}", + "received_events_url": "https://api.github.com/users/octocat/received_events", + "type": "User", + "site_admin": false + }, + "repo": { + "id": 1296269, + "owner": { + "login": "octocat", + "id": 1, + "avatar_url": "https://github.com/images/error/octocat_happy.gif", + "gravatar_id": "", + "url": "https://api.github.com/users/octocat", + "html_url": "https://github.com/octocat", + "followers_url": "https://api.github.com/users/octocat/followers", + "following_url": "https://api.github.com/users/octocat/following{/other_user}", + "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", + "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", + "organizations_url": "https://api.github.com/users/octocat/orgs", + "repos_url": "https://api.github.com/users/octocat/repos", + "events_url": "https://api.github.com/users/octocat/events{/privacy}", + "received_events_url": "https://api.github.com/users/octocat/received_events", + "type": "User", + "site_admin": false + }, + "name": "Hello-World", + "full_name": "octocat/Hello-World", + "description": "This your first repo!", + "private": false, + "fork": true, + "url": "https://api.github.com/repos/octocat/Hello-World", + "html_url": "https://github.com/octocat/Hello-World", + "archive_url": "http://api.github.com/repos/octocat/Hello-World/{archive_format}{/ref}", + "assignees_url": "http://api.github.com/repos/octocat/Hello-World/assignees{/user}", + "blobs_url": "http://api.github.com/repos/octocat/Hello-World/git/blobs{/sha}", + "branches_url": "http://api.github.com/repos/octocat/Hello-World/branches{/branch}", + "clone_url": "https://github.com/octocat/Hello-World.git", + "collaborators_url": "http://api.github.com/repos/octocat/Hello-World/collaborators{/collaborator}", + "comments_url": "http://api.github.com/repos/octocat/Hello-World/comments{/number}", + "commits_url": "http://api.github.com/repos/octocat/Hello-World/commits{/sha}", + "compare_url": "http://api.github.com/repos/octocat/Hello-World/compare/{base}...{head}", + "contents_url": "http://api.github.com/repos/octocat/Hello-World/contents/{+path}", + "contributors_url": "http://api.github.com/repos/octocat/Hello-World/contributors", + "deployments_url": "http://api.github.com/repos/octocat/Hello-World/deployments", + "downloads_url": "http://api.github.com/repos/octocat/Hello-World/downloads", + "events_url": "http://api.github.com/repos/octocat/Hello-World/events", + "forks_url": "http://api.github.com/repos/octocat/Hello-World/forks", + "git_commits_url": "http://api.github.com/repos/octocat/Hello-World/git/commits{/sha}", + "git_refs_url": "http://api.github.com/repos/octocat/Hello-World/git/refs{/sha}", + "git_tags_url": "http://api.github.com/repos/octocat/Hello-World/git/tags{/sha}", + "git_url": "git:github.com/octocat/Hello-World.git", + "hooks_url": "http://api.github.com/repos/octocat/Hello-World/hooks", + "issue_comment_url": "http://api.github.com/repos/octocat/Hello-World/issues/comments{/number}", + "issue_events_url": "http://api.github.com/repos/octocat/Hello-World/issues/events{/number}", + "issues_url": "http://api.github.com/repos/octocat/Hello-World/issues{/number}", + "keys_url": "http://api.github.com/repos/octocat/Hello-World/keys{/key_id}", + "labels_url": "http://api.github.com/repos/octocat/Hello-World/labels{/name}", + "languages_url": "http://api.github.com/repos/octocat/Hello-World/languages", + "merges_url": "http://api.github.com/repos/octocat/Hello-World/merges", + "milestones_url": "http://api.github.com/repos/octocat/Hello-World/milestones{/number}", + "mirror_url": "git:git.example.com/octocat/Hello-World", + "notifications_url": "http://api.github.com/repos/octocat/Hello-World/notifications{?since, all, participating}", + "pulls_url": "http://api.github.com/repos/octocat/Hello-World/pulls{/number}", + "releases_url": "http://api.github.com/repos/octocat/Hello-World/releases{/id}", + "ssh_url": "git@github.com:octocat/Hello-World.git", + "stargazers_url": "http://api.github.com/repos/octocat/Hello-World/stargazers", + "statuses_url": "http://api.github.com/repos/octocat/Hello-World/statuses/{sha}", + "subscribers_url": "http://api.github.com/repos/octocat/Hello-World/subscribers", + "subscription_url": "http://api.github.com/repos/octocat/Hello-World/subscription", + "svn_url": "https://svn.github.com/octocat/Hello-World", + "tags_url": "http://api.github.com/repos/octocat/Hello-World/tags", + "teams_url": "http://api.github.com/repos/octocat/Hello-World/teams", + "trees_url": "http://api.github.com/repos/octocat/Hello-World/git/trees{/sha}", + "homepage": "https://github.com", + "language": null, + "forks_count": 9, + "stargazers_count": 80, + "watchers_count": 80, + "size": 108, + "default_branch": "master", + "open_issues_count": 0, + "topics": [ + "octocat", + "atom", + "electron", + "API" + ], + "has_issues": true, + "has_wiki": true, + "has_pages": false, + "has_downloads": true, + "pushed_at": "2011-01-26T19:06:43Z", + "created_at": "2011-01-26T19:01:12Z", + "updated_at": "2011-01-26T19:14:43Z", + "permissions": { + "admin": false, + "push": false, + "pull": true + }, + "allow_rebase_merge": true, + "allow_squash_merge": true, + "allow_merge_commit": true, + "subscribers_count": 42, + "network_count": 0 + } + }, + "_links": { + "self": { + "href": "https://api.github.com/repos/octocat/Hello-World/pulls/1347" + }, + "html": { + "href": "https://github.com/octocat/Hello-World/pull/1347" + }, + "issue": { + "href": "https://api.github.com/repos/octocat/Hello-World/issues/1347" + }, + "comments": { + "href": "https://api.github.com/repos/octocat/Hello-World/issues/1347/comments" + }, + "review_comments": { + "href": "https://api.github.com/repos/octocat/Hello-World/pulls/1347/comments" + }, + "review_comment": { + "href": "https://api.github.com/repos/octocat/Hello-World/pulls/comments{/number}" + }, + "commits": { + "href": "https://api.github.com/repos/octocat/Hello-World/pulls/1347/commits" + }, + "statuses": { + "href": "https://api.github.com/repos/octocat/Hello-World/statuses/6dcb09b5b57875f334f61aebed695e2e4193db5e" + } + }, + "user": { + "login": "octocat", + "id": 1, + "avatar_url": "https://github.com/images/error/octocat_happy.gif", + "gravatar_id": "", + "url": "https://api.github.com/users/octocat", + "html_url": "https://github.com/octocat", + "followers_url": "https://api.github.com/users/octocat/followers", + "following_url": "https://api.github.com/users/octocat/following{/other_user}", + "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", + "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", + "organizations_url": "https://api.github.com/users/octocat/orgs", + "repos_url": "https://api.github.com/users/octocat/repos", + "events_url": "https://api.github.com/users/octocat/events{/privacy}", + "received_events_url": "https://api.github.com/users/octocat/received_events", + "type": "User", + "site_admin": false + } + } +] diff --git a/README.md b/README.md index 3bd222f4..d09ec2f4 100644 --- a/README.md +++ b/README.md @@ -301,3 +301,27 @@ Octokit(config).patchIssue("owner", repository: "repo", number: 1347, title: "Fo } } ``` +## Pull requests + +### Get a single pull request +```swift +let task = Octokit().pullRequest(session, owner: "octocat", repository: "Hello-World", number: 1) { response in + switch response { + case .success(let pullRequests): + // do something with a pull request + case .failure: + // handle any errors + } +} +``` + +### List a pull requests +```swift +let task = Octokit().pullRequests(session, owner: "octocat", repository: "Hello-World", base: "develop", state: Openness.Open) { response in + switch response { + case .success(let pullRequests): + // do something with a pull request list + case .failure: + // handle any errors + } +} From c28f93cb2075acdbea6aace7853a647b96f6bcf4 Mon Sep 17 00:00:00 2001 From: muhdmirzamz Date: Tue, 25 Jul 2017 16:16:56 +0800 Subject: [PATCH 109/302] Updated README --- README.md | 69 +++++++++++++++++++++++++++++++------------------------ 1 file changed, 39 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index d09ec2f4..9c4bfb36 100644 --- a/README.md +++ b/README.md @@ -19,13 +19,14 @@ the OAuth Flow You can initialize a new config for `github.com` as follows: ```swift -let config = TokenConfiguration(token: "12345") +let config = TokenConfiguration() +config.accessToken = "12345" ``` or for Github Enterprise ```swift -let config = TokenConfiguration("https://github.example.com/api/v3/", token: "12345") +let config = TokenConfiguration("12345", url: "https://github.example.com/api/v3/") ``` After you got your token you can use it with `Octokit` @@ -33,10 +34,10 @@ After you got your token you can use it with `Octokit` ```swift Octokit(config).me() { response in switch response { - case .Success(let user): - println(user.login) - case .Failure(let error): - println(error) + case .success(let user): + print(user.login) + case .failure(let error): + print(error) } } ``` @@ -49,8 +50,16 @@ user has to login to your application. This also handles the OAuth flow. You can authenticate an user for `github.com` as follows: ```swift -let config = OAuthConfiguration(token: "", secret: "", scopes: ["repo", "read:org"]) -config.authenticate() +// AppDelegate.swift + +func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { + let config = OAuthConfiguration(token: "", secret: "", scopes: ["repo", "read:org"]) + let url = config.authenticate() + + UIApplication.shared.open(url!, options: [:], completionHandler: nil) + + return true +} ``` @@ -65,25 +74,23 @@ After you got your config you can authenticate the user: ```swift // AppDelegate.swift -config.authenticate() +func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool { + config?.handleOpenURL(url: url, completion: { (tokenConfig) in + // store access token somewhere + let token = token.accessToken + + let _ = Octokit(tokenConfig).me() { response in + switch response { + case .success(let user): + print("User login: \(user.login!)") + case .failure(let error): + print("Error: \(error)") + } + } + }) -func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject?) -> Bool { - config.handleOpenURL(url) { config in - self.loadCurrentUser(config) // purely optional of course - } return false } - -func loadCurrentUser(config: TokenConfiguration) { - Octokit(config).me() { response in - switch response { - case .Success(let user): - println(user.login) - case .Failure(let error): - println(error) - } - } -} ``` Please note that you will be given a `TokenConfiguration` back from the OAuth flow. @@ -92,15 +99,17 @@ necessary to do the OAuth Flow again. You can just use a `TokenConfiguration`. ```swift let token = // get your token from your keychain, user defaults (not recommended) etc. -let config = TokenConfiguration(token) -Octokit(config).user("octocat") { response in +let config = TokenConfiguration() +config.accessToken = tokenYouStored + +let _ = Octokit(config).user("octocat") { response in switch response { - case .Success(let user): - println(user.login) - case .Failure(let error): - println(error) + case .success(let user): print("User login: \(user.login!)") + case .failure(let error): + print("Error: \(error)") } } + ``` ## Users From 2a3431f30eb56f2adec03b201c34d8e4332ce40e Mon Sep 17 00:00:00 2001 From: muhdmirzamz Date: Tue, 25 Jul 2017 16:21:03 +0800 Subject: [PATCH 110/302] Fixed indentation --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 9c4bfb36..7e7a9d40 100644 --- a/README.md +++ b/README.md @@ -81,11 +81,11 @@ func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpe let _ = Octokit(tokenConfig).me() { response in switch response { - case .success(let user): - print("User login: \(user.login!)") - case .failure(let error): - print("Error: \(error)") - } + case .success(let user): + print(user.login) + case .failure(let error): + print(error) + } } }) From fa4b5c3d2ec643558bba579896937775c6764967 Mon Sep 17 00:00:00 2001 From: muhdmirzamz Date: Tue, 25 Jul 2017 16:22:50 +0800 Subject: [PATCH 111/302] Fixed indentation p2 --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 7e7a9d40..83d26a5c 100644 --- a/README.md +++ b/README.md @@ -81,10 +81,10 @@ func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpe let _ = Octokit(tokenConfig).me() { response in switch response { - case .success(let user): - print(user.login) - case .failure(let error): - print(error) + case .success(let user): + print(user.login) + case .failure(let error): + print(error) } } }) From bd189d98d01e32d7594812844a16957626efbec0 Mon Sep 17 00:00:00 2001 From: muhdmirzamz Date: Tue, 25 Jul 2017 16:25:01 +0800 Subject: [PATCH 112/302] Fixed indentation p3 --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 83d26a5c..81748ac2 100644 --- a/README.md +++ b/README.md @@ -104,7 +104,8 @@ config.accessToken = tokenYouStored let _ = Octokit(config).user("octocat") { response in switch response { - case .success(let user): print("User login: \(user.login!)") + case .success(let user): + print("User login: \(user.login!)") case .failure(let error): print("Error: \(error)") } From 33f254908e813359aecce1d900a3b758df5ec192 Mon Sep 17 00:00:00 2001 From: muhdmirzamz Date: Tue, 25 Jul 2017 16:26:32 +0800 Subject: [PATCH 113/302] Fixed code in segment telling users to use stored token --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 81748ac2..bb168f84 100644 --- a/README.md +++ b/README.md @@ -100,7 +100,7 @@ necessary to do the OAuth Flow again. You can just use a `TokenConfiguration`. ```swift let token = // get your token from your keychain, user defaults (not recommended) etc. let config = TokenConfiguration() -config.accessToken = tokenYouStored +config.accessToken = token let _ = Octokit(config).user("octocat") { response in switch response { From 5fbbf638c51cff63e4c57ba93ab64c574dd5fdb0 Mon Sep 17 00:00:00 2001 From: Muhd Mirza Date: Thu, 10 Aug 2017 20:23:34 +0800 Subject: [PATCH 114/302] README changes --- README.md | 116 +++++++++++++++++++++++++----------------------------- 1 file changed, 53 insertions(+), 63 deletions(-) diff --git a/README.md b/README.md index bb168f84..d237101a 100644 --- a/README.md +++ b/README.md @@ -19,8 +19,7 @@ the OAuth Flow You can initialize a new config for `github.com` as follows: ```swift -let config = TokenConfiguration() -config.accessToken = "12345" +let config = TokenConfiguration(token: "12345") ``` or for Github Enterprise @@ -50,17 +49,8 @@ user has to login to your application. This also handles the OAuth flow. You can authenticate an user for `github.com` as follows: ```swift -// AppDelegate.swift - -func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { - let config = OAuthConfiguration(token: "", secret: "", scopes: ["repo", "read:org"]) - let url = config.authenticate() - - UIApplication.shared.open(url!, options: [:], completionHandler: nil) - - return true -} - +let config = OAuthConfiguration(token: "", secret: "", scopes: ["repo", "read:org"]) +let url = config.authenticate() ``` or for Github Enterprise @@ -74,23 +64,25 @@ After you got your config you can authenticate the user: ```swift // AppDelegate.swift -func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool { - config?.handleOpenURL(url: url, completion: { (tokenConfig) in - // store access token somewhere - let token = token.accessToken - - let _ = Octokit(tokenConfig).me() { response in - switch response { - case .success(let user): - print(user.login) - case .failure(let error): - print(error) - } - } - }) +config.authenticate() +func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject?) -> Bool { + config.handleOpenURL(url) { config in + self.loadCurrentUser(config) // purely optional of course + } return false } + +func loadCurrentUser(config: TokenConfiguration) { + Octokit(config).me() { response in + switch response { + case .success(let user): + print(user.login) + case .failure(let error): + print(error) + } + } +} ``` Please note that you will be given a `TokenConfiguration` back from the OAuth flow. @@ -99,15 +91,13 @@ necessary to do the OAuth Flow again. You can just use a `TokenConfiguration`. ```swift let token = // get your token from your keychain, user defaults (not recommended) etc. -let config = TokenConfiguration() -config.accessToken = token - -let _ = Octokit(config).user("octocat") { response in +let config = TokenConfiguration(token) +Octokit(config).user("octocat") { response in switch response { - case .success(let user): - print("User login: \(user.login!)") - case .failure(let error): - print("Error: \(error)") + case .success(let user): + print("User login: \(user.login!)") + case .failure(let error): + print("Error: \(error)") } } @@ -121,9 +111,9 @@ let _ = Octokit(config).user("octocat") { response in let username = ... // set the username Octokit().user(username) { response in switch response { - case .Success(let user): + case .success(let user): // do something with the user - case .Failure(let error): + case .failure(let error): // handle any errors } } @@ -134,9 +124,9 @@ Octokit().user(username) { response in ```swift Octokit().me() { response in switch response { - case .Success(let user): + case .success(let user): // do something with the user - case .Failure(let error): + case .failure(let error): // handle any errors } ``` @@ -149,9 +139,9 @@ Octokit().me() { response in let (owner, name) = ("owner", "name") // replace with actual owner and name Octokit().repository(owner, name) { response in switch response { - case .Success(let repository): + case .success(let repository): // do something with the repository - case .Failure(let error): + case .failure(let error): // handle any errors } } @@ -162,9 +152,9 @@ Octokit().repository(owner, name) { response in ```swift Octokit().repositories() { response in switch response { - case .Success(let repository): + case .success(let repository): // do something - case .Failure(let error): + case .failure(let error): // handle any errors } } @@ -178,9 +168,9 @@ Octokit().repositories() { response in let username = "username" Octokit().stars(username) { response in switch response { - case .Success(let repositories): + case .success(let repositories): // do something with the repositories - case .Failure(let error): + case .failure(let error): // handle any errors } } @@ -191,9 +181,9 @@ Octokit().stars(username) { response in ```swift Octokit().myStars() { response in switch response { - case .Success(let repositories): + case .success(let repositories): // do something with the repositories - case .Failure(let error): + case .failure(let error): // handle any errors } } @@ -207,9 +197,9 @@ Octokit().myStars() { response in let username = "username" Octokit().followers(username) { response in switch response { - case .Success(let users): + case .success(let users): // do something with the users - case .Failure(let error): + case .failure(let error): // handle any errors } } @@ -220,9 +210,9 @@ Octokit().followers(username) { response in ```swift Octokit().myFollowers() { response in switch response { - case .Success(let users): + case .success(let users): // do something with the users - case .Failure(let error): + case .failure(let error): // handle any errors } } @@ -234,9 +224,9 @@ Octokit().myFollowers() { response in let username = "username" Octokit().following(username) { response in switch response { - case .Success(let users): + case .success(let users): // do something with the users - case .Failure(let error): + case .failure(let error): // handle any errors } } @@ -247,9 +237,9 @@ Octokit().following(username) { response in ```swift Octokit().myFollowing() { response in switch response { - case .Success(let users): + case .success(let users): // do something with the users - case .Failure(let error): + case .failure(let error): // handle any errors } } @@ -264,9 +254,9 @@ Get all issues across all the authenticated user's visible repositories includin ```swift Octokit(config).myIssues() { response in switch response { - case .Success(let issues): + case .success(let issues): // do something with the issues - case .Failure: + case .failure: // handle any errors } } @@ -278,9 +268,9 @@ Octokit(config).myIssues() { response in let (owner, repo, number) = ("owner", "repo", 1347) // replace with actual owner, repo name, and issue number Octokit(config).issue(owner, repository: repo, number: number) { response in switch response { - case .Success(let issue): + case .success(let issue): // do something with the issue - case .Failure: + case .failure: // handle any errors } } @@ -291,9 +281,9 @@ Octokit(config).issue(owner, repository: repo, number: number) { response in ```swift Octokit(config).postIssue("owner", repository: "repo", title: "Found a bug", body: "I'm having a problem with this.", assignee: "octocat") { response in switch response { - case .Success(let issue): + case .success(let issue): // do something with the issue - case .Failure: + case .failure: // handle any errors } } @@ -304,9 +294,9 @@ Octokit(config).postIssue("owner", repository: "repo", title: "Found a bug", bod ```swift Octokit(config).patchIssue("owner", repository: "repo", number: 1347, title: "Found a bug", body: "I'm having a problem with this.", assignee: "octocat", state: .Closed) { response in switch response { - case .Success(let issue): + case .success(let issue): // do something with the issue - case .Failure: + case .failure: // handle any errors } } From 3a7a93c85a4df5e888badda114e6cf6799ea40bb Mon Sep 17 00:00:00 2001 From: Piet Brauer Date: Fri, 25 Aug 2017 13:36:46 +0200 Subject: [PATCH 115/302] Bump version --- OctoKit.swift.podspec | 2 +- OctoKit/Info.plist | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/OctoKit.swift.podspec b/OctoKit.swift.podspec index 86024a8d..2ba94b91 100644 --- a/OctoKit.swift.podspec +++ b/OctoKit.swift.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "OctoKit.swift" - s.version = "0.7.3" + s.version = "0.7.4" s.summary = "A Swift API Client for GitHub and GitHub Enterprise" s.description = <<-DESC You are looking at the A Swift API Client for GitHub and GitHub Enterprise. diff --git a/OctoKit/Info.plist b/OctoKit/Info.plist index fb0dd735..342a2465 100644 --- a/OctoKit/Info.plist +++ b/OctoKit/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 0.7.3 + 0.7.4 CFBundleSignature ???? CFBundleVersion From 3f6fa233909f475451c5be10d2d10cb03af864fd Mon Sep 17 00:00:00 2001 From: Piet Brauer Date: Tue, 28 Nov 2017 13:53:39 +0100 Subject: [PATCH 116/302] Migrate to Swift 4 --- OctoKit.xcodeproj/project.pbxproj | 24 +++++++--- .../xcschemes/OctoKit Mac.xcscheme | 4 +- .../xcschemes/OctoKit MacTests.xcscheme | 18 +++++++- .../xcschemes/OctoKit tvOS.xcscheme | 4 +- .../xcschemes/OctoKit watchOS.xcscheme | 4 +- .../xcshareddata/xcschemes/OctoKit.xcscheme | 4 +- OctoKit/Configuration.swift | 4 +- OctoKit/Issue.swift | 36 +++++++-------- OctoKit/Label.swift | 14 +++--- OctoKit/Milestone.swift | 24 +++++----- OctoKit/PullRequest.swift | 44 +++++++++---------- OctoKit/Repositories.swift | 26 +++++------ OctoKit/User.swift | 22 +++++----- OctoKitTests/FollowTests.swift | 8 ---- OctoKitTests/RepositoryTests.swift | 4 -- OctoKitTests/StarsTests.swift | 4 -- OctoKitTests/UserTests.swift | 4 -- 17 files changed, 132 insertions(+), 116 deletions(-) diff --git a/OctoKit.xcodeproj/project.pbxproj b/OctoKit.xcodeproj/project.pbxproj index e721746b..d832bf16 100644 --- a/OctoKit.xcodeproj/project.pbxproj +++ b/OctoKit.xcodeproj/project.pbxproj @@ -598,18 +598,18 @@ attributes = { LastSwiftMigration = 0700; LastSwiftUpdateCheck = 0720; - LastUpgradeCheck = 0820; + LastUpgradeCheck = 0910; ORGANIZATIONNAME = "nerdish by nature"; TargetAttributes = { 234F4BA81BDDE31A00A58EF7 = { CreatedOnToolsVersion = 7.1; - LastSwiftMigration = 0800; + LastSwiftMigration = 0910; }; 239BE7C81B8C47A100D2CE22 = { CreatedOnToolsVersion = 6.4; DevelopmentTeam = 3NPZ2HXWU8; DevelopmentTeamName = "Piet Brauer"; - LastSwiftMigration = 0800; + LastSwiftMigration = 0910; }; 23CAF2611C7AB5FB005011C4 = { CreatedOnToolsVersion = 7.2.1; @@ -910,7 +910,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.nerdishbynature.OctoKitTests; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; }; name = Debug; }; @@ -930,7 +930,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.nerdishbynature.OctoKitTests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; }; name = Release; }; @@ -959,6 +959,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -987,6 +988,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -1251,14 +1253,20 @@ CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; @@ -1301,14 +1309,20 @@ CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; diff --git a/OctoKit.xcodeproj/xcshareddata/xcschemes/OctoKit Mac.xcscheme b/OctoKit.xcodeproj/xcshareddata/xcschemes/OctoKit Mac.xcscheme index e513e207..126e186b 100644 --- a/OctoKit.xcodeproj/xcshareddata/xcschemes/OctoKit Mac.xcscheme +++ b/OctoKit.xcodeproj/xcshareddata/xcschemes/OctoKit Mac.xcscheme @@ -1,6 +1,6 @@ + buildForProfiling = "YES" + buildForArchiving = "YES" + buildForAnalyzing = "YES"> + + + + diff --git a/OctoKit.xcodeproj/xcshareddata/xcschemes/OctoKit tvOS.xcscheme b/OctoKit.xcodeproj/xcshareddata/xcschemes/OctoKit tvOS.xcscheme index ed871386..b16cfa1f 100644 --- a/OctoKit.xcodeproj/xcshareddata/xcschemes/OctoKit tvOS.xcscheme +++ b/OctoKit.xcodeproj/xcshareddata/xcschemes/OctoKit tvOS.xcscheme @@ -1,6 +1,6 @@ @@ -36,6 +37,7 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + language = "" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" diff --git a/OctoKit.xcodeproj/xcshareddata/xcschemes/OctoKit.xcscheme b/OctoKit.xcodeproj/xcshareddata/xcschemes/OctoKit.xcscheme index cbd3d4ae..2fe7bdfe 100644 --- a/OctoKit.xcodeproj/xcshareddata/xcschemes/OctoKit.xcscheme +++ b/OctoKit.xcodeproj/xcshareddata/xcschemes/OctoKit.xcscheme @@ -1,6 +1,6 @@ @@ -56,6 +57,7 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + language = "" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" diff --git a/OctoKit/Configuration.swift b/OctoKit/Configuration.swift index 260cc938..51071e8c 100644 --- a/OctoKit/Configuration.swift +++ b/OctoKit/Configuration.swift @@ -1,8 +1,8 @@ import Foundation import RequestKit -let githubBaseURL = "https://api.github.com" -let githubWebURL = "https://github.com" +public let githubBaseURL = "https://api.github.com" +public let githubWebURL = "https://github.com" public let OctoKitErrorDomain = "com.nerdishbynature.octokit" diff --git a/OctoKit/Issue.swift b/OctoKit/Issue.swift index 7bef8811..4f8877b5 100644 --- a/OctoKit/Issue.swift +++ b/OctoKit/Issue.swift @@ -10,29 +10,29 @@ public enum Openness: String { } @objc open class Issue: NSObject { - open var id: Int - open var url: URL? - open var repositoryURL: URL? - open var labelsURL: URL? - open var commentsURL: URL? - open var eventsURL: URL? - open var htmlURL: URL? + @objc open var id: Int + @objc open var url: URL? + @objc open var repositoryURL: URL? + @objc open var labelsURL: URL? + @objc open var commentsURL: URL? + @objc open var eventsURL: URL? + @objc open var htmlURL: URL? open var number: Int? open var state: Openness? - open var title: String? - open var body: String? - open var user: User? - open var labels: [Label]? - open var assignee: User? - open var milestone: Milestone? + @objc open var title: String? + @objc open var body: String? + @objc open var user: User? + @objc open var labels: [Label]? + @objc open var assignee: User? + @objc open var milestone: Milestone? open var locked: Bool? open var comments: Int? - open var closedAt: Date? - open var createdAt: Date? - open var updatedAt: Date? - open var closedBy: User? + @objc open var closedAt: Date? + @objc open var createdAt: Date? + @objc open var updatedAt: Date? + @objc open var closedBy: User? - public init(_ json: [String: AnyObject]) { + @objc public init(_ json: [String: AnyObject]) { if let id = json["id"] as? Int { self.id = id if let urlString = json["url"] as? String, let url = URL(string: urlString) { diff --git a/OctoKit/Label.swift b/OctoKit/Label.swift index 14ce322c..7eed9817 100644 --- a/OctoKit/Label.swift +++ b/OctoKit/Label.swift @@ -7,9 +7,9 @@ #endif extension Color { - convenience init?(hexTriplet hex: String) { - var hexChars = hex.characters - let red = Int(String(hexChars.prefix(2)), radix: 16) + @objc convenience init?(hexTriplet hex: String) { + var hexChars = Substring(hex) + let red = Int(String(hex.prefix(2)), radix: 16) hexChars = hexChars.dropFirst(2) let green = Int(String(hexChars.prefix(2)), radix: 16) hexChars = hexChars.dropFirst(2) @@ -23,15 +23,15 @@ extension Color { } @objc open class Label: NSObject { - open var url: URL? - open var name: String? + @objc open var url: URL? + @objc open var name: String? #if os(OSX) open var color: NSColor? #elseif os(iOS) || os(tvOS) || os(watchOS) - public var color: UIColor? + @objc public var color: UIColor? #endif - public init(_ json: [String: AnyObject]) { + @objc public init(_ json: [String: AnyObject]) { if let urlString = json["url"] as? String, let url = URL(string: urlString) { self.url = url } diff --git a/OctoKit/Milestone.swift b/OctoKit/Milestone.swift index af0f5681..7e3ce1c0 100644 --- a/OctoKit/Milestone.swift +++ b/OctoKit/Milestone.swift @@ -1,23 +1,23 @@ import Foundation @objc open class Milestone: NSObject { - open var url: URL? - open var htmlURL: URL? - open var labelsURL: URL? - open var id: Int + @objc open var url: URL? + @objc open var htmlURL: URL? + @objc open var labelsURL: URL? + @objc open var id: Int open var number: Int? open var state: Openness? - open var title: String? - open var milestoneDescription: String? - open var creator: User? + @objc open var title: String? + @objc open var milestoneDescription: String? + @objc open var creator: User? open var openIssues: Int? open var closedIssues: Int? - open var createdAt: Date? - open var updatedAt: Date? - open var closedAt: Date? - open var dueOn: Date? + @objc open var createdAt: Date? + @objc open var updatedAt: Date? + @objc open var closedAt: Date? + @objc open var dueOn: Date? - public init?(_ json: [String: AnyObject]) { + @objc public init?(_ json: [String: AnyObject]) { if let id = json["id"] as? Int { if let urlString = json["html_url"] as? String, let url = URL(string: urlString) { htmlURL = url diff --git a/OctoKit/PullRequest.swift b/OctoKit/PullRequest.swift index 3d1b3b6d..4c1b8a47 100644 --- a/OctoKit/PullRequest.swift +++ b/OctoKit/PullRequest.swift @@ -3,36 +3,36 @@ import RequestKit @objc open class PullRequest: NSObject { - open var id: Int - open var url: URL? - - open var htmlURL: URL? - open var diffURL: URL? - open var patchURL: URL? - open var issueURL: URL? - open var commitsURL: URL? - open var reviewCommentsURL: URL? - open var reviewCommentURL: URL? - open var commentsURL: URL? - open var statusesURL: URL? + @objc open var id: Int + @objc open var url: URL? + + @objc open var htmlURL: URL? + @objc open var diffURL: URL? + @objc open var patchURL: URL? + @objc open var issueURL: URL? + @objc open var commitsURL: URL? + @objc open var reviewCommentsURL: URL? + @objc open var reviewCommentURL: URL? + @objc open var commentsURL: URL? + @objc open var statusesURL: URL? open var number: Int? open var state: Openness? - open var title: String? - open var body: String? + @objc open var title: String? + @objc open var body: String? - open var assignee: User? - open var milestone: Milestone? + @objc open var assignee: User? + @objc open var milestone: Milestone? open var locked: Bool? - open var createdAt: Date? - open var updatedAt: Date? - open var closedAt: Date? - open var mergedAt: Date? + @objc open var createdAt: Date? + @objc open var updatedAt: Date? + @objc open var closedAt: Date? + @objc open var mergedAt: Date? - open var user: User? + @objc open var user: User? - public init(_ json: [String: AnyObject]) { + @objc public init(_ json: [String: AnyObject]) { if let id = json["id"] as? Int { self.id = id diff --git a/OctoKit/Repositories.swift b/OctoKit/Repositories.swift index 581634ec..0221d774 100644 --- a/OctoKit/Repositories.swift +++ b/OctoKit/Repositories.swift @@ -4,21 +4,21 @@ import RequestKit // MARK: model @objc open class Repository: NSObject { - open let id: Int - open let owner: User - open var name: String? - open var fullName: String? - open var isPrivate: Bool - open var repositoryDescription: String? + @objc open let id: Int + @objc open let owner: User + @objc open var name: String? + @objc open var fullName: String? + @objc open var isPrivate: Bool + @objc open var repositoryDescription: String? open var isFork: Bool? - open var gitURL: String? - open var sshURL: String? - open var cloneURL: String? - open var htmlURL: String? - open var size: Int - open var lastPush: Date? + @objc open var gitURL: String? + @objc open var sshURL: String? + @objc open var cloneURL: String? + @objc open var htmlURL: String? + @objc open var size: Int + @objc open var lastPush: Date? - public init(_ json: [String: AnyObject]) { + @objc public init(_ json: [String: AnyObject]) { owner = User(json["owner"] as? [String: AnyObject] ?? [:]) if let id = json["id"] as? Int { self.id = id diff --git a/OctoKit/User.swift b/OctoKit/User.swift index 1597d8aa..e4f8cc13 100644 --- a/OctoKit/User.swift +++ b/OctoKit/User.swift @@ -4,21 +4,21 @@ import RequestKit // MARK: model @objc open class User: NSObject { - open let id: Int - open var login: String? - open var avatarURL: String? - open var gravatarID: String? - open var type: String? - open var name: String? - open var company: String? - open var blog: String? - open var location: String? - open var email: String? + @objc open let id: Int + @objc open var login: String? + @objc open var avatarURL: String? + @objc open var gravatarID: String? + @objc open var type: String? + @objc open var name: String? + @objc open var company: String? + @objc open var blog: String? + @objc open var location: String? + @objc open var email: String? open var numberOfPublicRepos: Int? open var numberOfPublicGists: Int? open var numberOfPrivateRepos: Int? - public init(_ json: [String: AnyObject]) { + @objc public init(_ json: [String: AnyObject]) { if let id = json["id"] as? Int { self.id = id login = json["login"] as? String diff --git a/OctoKitTests/FollowTests.swift b/OctoKitTests/FollowTests.swift index 71c8790f..ceb81eab 100644 --- a/OctoKitTests/FollowTests.swift +++ b/OctoKitTests/FollowTests.swift @@ -27,8 +27,6 @@ class FollowTests: XCTestCase { case .failure(let error as NSError): XCTAssertEqual(error.code, 404) XCTAssertEqual(error.domain, OctoKitErrorDomain) - case .failure: - XCTAssertTrue(false) } } XCTAssertNotNil(task) @@ -58,8 +56,6 @@ class FollowTests: XCTestCase { case .failure(let error as NSError): XCTAssertEqual(error.code, 404) XCTAssertEqual(error.domain, OctoKitErrorDomain) - case .failure: - XCTAssertTrue(false) } } XCTAssertNotNil(task) @@ -91,8 +87,6 @@ class FollowTests: XCTestCase { case .failure(let error as NSError): XCTAssertEqual(error.code, 404) XCTAssertEqual(error.domain, OctoKitErrorDomain) - case .failure: - XCTAssertTrue(false) } } XCTAssertNotNil(task) @@ -122,8 +116,6 @@ class FollowTests: XCTestCase { case .failure(let error as NSError): XCTAssertEqual(error.code, 404) XCTAssertEqual(error.domain, OctoKitErrorDomain) - case .failure: - XCTAssertTrue(false) } } XCTAssertNotNil(task) diff --git a/OctoKitTests/RepositoryTests.swift b/OctoKitTests/RepositoryTests.swift index 393a526c..34979389 100644 --- a/OctoKitTests/RepositoryTests.swift +++ b/OctoKitTests/RepositoryTests.swift @@ -74,8 +74,6 @@ class RepositoryTests: XCTestCase { case .failure(let error as NSError): XCTAssertEqual(error.code, 401) XCTAssertEqual(error.domain, OctoKitErrorDomain) - case .failure: - XCTAssertTrue(false) } } XCTAssertNotNil(task) @@ -125,8 +123,6 @@ class RepositoryTests: XCTestCase { case .failure(let error as NSError): XCTAssertEqual(error.code, 404) XCTAssertEqual(error.domain, OctoKitErrorDomain) - case .failure: - XCTAssertTrue(false) } } XCTAssertNotNil(task) diff --git a/OctoKitTests/StarsTests.swift b/OctoKitTests/StarsTests.swift index 56724eba..11c43158 100644 --- a/OctoKitTests/StarsTests.swift +++ b/OctoKitTests/StarsTests.swift @@ -29,8 +29,6 @@ class StarsTests: XCTestCase { case .failure(let error as NSError): XCTAssertEqual(error.code, 404) XCTAssertEqual(error.domain, OctoKitErrorDomain) - case .failure: - XCTAssertTrue(false) } } XCTAssertNotNil(task) @@ -60,8 +58,6 @@ class StarsTests: XCTestCase { case .failure(let error as NSError): XCTAssertEqual(error.code, 404) XCTAssertEqual(error.domain, OctoKitErrorDomain) - case .failure: - XCTAssertTrue(false) } } XCTAssertNotNil(task) diff --git a/OctoKitTests/UserTests.swift b/OctoKitTests/UserTests.swift index 569cfdc7..d121d42e 100644 --- a/OctoKitTests/UserTests.swift +++ b/OctoKitTests/UserTests.swift @@ -29,8 +29,6 @@ class UserTests: XCTestCase { case .failure(let error as NSError): XCTAssertEqual(error.code, 404) XCTAssertEqual(error.domain, OctoKitErrorDomain) - case .failure: - XCTAssertTrue(false) } } XCTAssertNotNil(task) @@ -61,8 +59,6 @@ class UserTests: XCTestCase { case .failure(let error as NSError): XCTAssertEqual(error.code, 401) XCTAssertEqual(error.domain, OctoKitErrorDomain) - case .failure: - XCTAssertTrue(false) } } XCTAssertNotNil(task) From 0d7fececded5a0239130b0afd752bbe69b0a47b4 Mon Sep 17 00:00:00 2001 From: Piet Brauer Date: Tue, 28 Nov 2017 16:41:08 +0100 Subject: [PATCH 117/302] Add codable for some items --- OctoKit.xcodeproj/project.pbxproj | 205 +++++++++++++++++++++++++---- OctoKit/Follow.swift | 28 ++-- OctoKit/Issue.swift | 105 ++++++--------- OctoKit/Label.swift | 18 +-- OctoKit/Milestone.swift | 53 ++++---- OctoKit/PullRequest.swift | 12 +- OctoKit/Repositories.swift | 58 ++++---- OctoKit/Stars.swift | 14 +- OctoKit/Time.swift | 5 +- OctoKit/User.swift | 50 ++++--- OctoKitTests/RepositoryTests.swift | 2 +- OctoKitTests/TestHelper.swift | 7 + OctoKitTests/UserTests.swift | 26 ++-- 13 files changed, 344 insertions(+), 239 deletions(-) diff --git a/OctoKit.xcodeproj/project.pbxproj b/OctoKit.xcodeproj/project.pbxproj index d832bf16..4403b709 100644 --- a/OctoKit.xcodeproj/project.pbxproj +++ b/OctoKit.xcodeproj/project.pbxproj @@ -19,8 +19,6 @@ 234F4BDF1BDDE44600A58EF7 /* user_me.json in Resources */ = {isa = PBXBuildFile; fileRef = 234F4BDA1BDDE44600A58EF7 /* user_me.json */; }; 234F4BE01BDDE44600A58EF7 /* user_mietzmithut.json in Resources */ = {isa = PBXBuildFile; fileRef = 234F4BDB1BDDE44600A58EF7 /* user_mietzmithut.json */; }; 234F4BE11BDDE44600A58EF7 /* user_repos.json in Resources */ = {isa = PBXBuildFile; fileRef = 234F4BDC1BDDE44600A58EF7 /* user_repos.json */; }; - 234F4C3F1BDE0FE200A58EF7 /* RequestKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 234F4C3E1BDE0FE200A58EF7 /* RequestKit.framework */; }; - 234F4C401BDE113800A58EF7 /* RequestKit.framework in Carthage embed */ = {isa = PBXBuildFile; fileRef = 234F4C3E1BDE0FE200A58EF7 /* RequestKit.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 237F91E41E5AEC82005FAA6B /* URL+URLParameters.swift in Sources */ = {isa = PBXBuildFile; fileRef = 237F91E31E5AEC82005FAA6B /* URL+URLParameters.swift */; }; 237F91E51E5AEC87005FAA6B /* URL+URLParameters.swift in Sources */ = {isa = PBXBuildFile; fileRef = 237F91E31E5AEC82005FAA6B /* URL+URLParameters.swift */; }; 237F91E61E5AEC88005FAA6B /* URL+URLParameters.swift in Sources */ = {isa = PBXBuildFile; fileRef = 237F91E31E5AEC82005FAA6B /* URL+URLParameters.swift */; }; @@ -79,11 +77,6 @@ 23CAF2CC1C7AB728005011C4 /* OctoKit.h in Headers */ = {isa = PBXBuildFile; fileRef = 239BE7CD1B8C47A100D2CE22 /* OctoKit.h */; settings = {ATTRIBUTES = (Public, ); }; }; 23CAF2CE1C7AB73D005011C4 /* OctoKit.h in Headers */ = {isa = PBXBuildFile; fileRef = 239BE7CD1B8C47A100D2CE22 /* OctoKit.h */; settings = {ATTRIBUTES = (Public, ); }; }; 23CAF2D11C7AB759005011C4 /* OctoKit.h in Headers */ = {isa = PBXBuildFile; fileRef = 239BE7CD1B8C47A100D2CE22 /* OctoKit.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 23CAF2D51C7AB9C0005011C4 /* RequestKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 23CAF2D41C7AB9C0005011C4 /* RequestKit.framework */; }; - 23CAF2D91C7AB9DB005011C4 /* RequestKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 23CAF2D81C7AB9DB005011C4 /* RequestKit.framework */; }; - 23CAF2DA1C7ABA67005011C4 /* RequestKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 23CAF2D61C7AB9CE005011C4 /* RequestKit.framework */; }; - 23F6433F1C7AEED7000427B3 /* RequestKit.framework in Carthage embed */ = {isa = PBXBuildFile; fileRef = 23CAF2D41C7AB9C0005011C4 /* RequestKit.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; - 23F643451C7AEF37000427B3 /* RequestKit.framework in Carthage embed */ = {isa = PBXBuildFile; fileRef = 23CAF2D61C7AB9CE005011C4 /* RequestKit.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 23F643461C7AEF63000427B3 /* public_key.json in Resources */ = {isa = PBXBuildFile; fileRef = 234F4BD81BDDE44600A58EF7 /* public_key.json */; }; 23F643471C7AEF63000427B3 /* public_key.json in Resources */ = {isa = PBXBuildFile; fileRef = 234F4BD81BDDE44600A58EF7 /* public_key.json */; }; 23F643481C7AEF66000427B3 /* repo.json in Resources */ = {isa = PBXBuildFile; fileRef = 234F4BD91BDDE44600A58EF7 /* repo.json */; }; @@ -96,6 +89,10 @@ 23F6434F1C7AEF70000427B3 /* user_repos.json in Resources */ = {isa = PBXBuildFile; fileRef = 234F4BDC1BDDE44600A58EF7 /* user_repos.json */; }; 23F643501C7AEF72000427B3 /* users.json in Resources */ = {isa = PBXBuildFile; fileRef = E7EE59DF1BE139FD0012E3D2 /* users.json */; }; 23F643511C7AEF73000427B3 /* users.json in Resources */ = {isa = PBXBuildFile; fileRef = E7EE59DF1BE139FD0012E3D2 /* users.json */; }; + 66C0632A1FCD95CE00920667 /* RequestKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 66C0631D1FCD95C200920667 /* RequestKit.framework */; }; + 66C0632B1FCD95D200920667 /* RequestKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 66C063211FCD95C200920667 /* RequestKit.framework */; }; + 66C0632C1FCD95D900920667 /* RequestKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 66C063271FCD95C200920667 /* RequestKit.framework */; }; + 66C0632D1FCD95E000920667 /* RequestKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 66C063251FCD95C200920667 /* RequestKit.framework */; }; BF8C711C2C6B42F9F323FCFE /* pull_requests.json in Resources */ = {isa = PBXBuildFile; fileRef = BF8C79B71035B425F7748392 /* pull_requests.json */; }; BF8C716EB8D5CA2CBBA745CB /* pull_request.json in Resources */ = {isa = PBXBuildFile; fileRef = BF8C77314F563A710F11E2F6 /* pull_request.json */; }; BF8C719220F02AC04EF3D137 /* PullRequestTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF8C76EB002802C14A08F63E /* PullRequestTests.swift */; }; @@ -164,6 +161,83 @@ remoteGlobalIDString = 23CAF27D1C7AB60C005011C4; remoteInfo = "OctoKit Mac"; }; + 66C0631C1FCD95C200920667 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 66C063121FCD95C200920667 /* RequestKit.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 234F4C1C1BDDF64300A58EF7; + remoteInfo = RequestKit; + }; + 66C0631E1FCD95C200920667 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 66C063121FCD95C200920667 /* RequestKit.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 234F4C261BDDF64300A58EF7; + remoteInfo = RequestKitTests; + }; + 66C063201FCD95C200920667 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 66C063121FCD95C200920667 /* RequestKit.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 233743001C7981A800013492; + remoteInfo = "RequestKit tvOS"; + }; + 66C063221FCD95C200920667 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 66C063121FCD95C200920667 /* RequestKit.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 2337434D1C79833A00013492; + remoteInfo = "RequestKit tvTests"; + }; + 66C063241FCD95C200920667 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 66C063121FCD95C200920667 /* RequestKit.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 2337430D1C7981D700013492; + remoteInfo = "RequestKit watchOS"; + }; + 66C063261FCD95C200920667 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 66C063121FCD95C200920667 /* RequestKit.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 2337431A1C7981E700013492; + remoteInfo = "RequestKit Mac"; + }; + 66C063281FCD95C200920667 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 66C063121FCD95C200920667 /* RequestKit.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 2337433E1C79832700013492; + remoteInfo = "RequestKit MacTests"; + }; + 66C0632E1FCD95E700920667 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 66C063121FCD95C200920667 /* RequestKit.xcodeproj */; + proxyType = 1; + remoteGlobalIDString = 234F4C1B1BDDF64300A58EF7; + remoteInfo = RequestKit; + }; + 66C063301FCD95EB00920667 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 66C063121FCD95C200920667 /* RequestKit.xcodeproj */; + proxyType = 1; + remoteGlobalIDString = 233742FF1C7981A800013492; + remoteInfo = "RequestKit tvOS"; + }; + 66C063321FCD95EF00920667 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 66C063121FCD95C200920667 /* RequestKit.xcodeproj */; + proxyType = 1; + remoteGlobalIDString = 233743191C7981E700013492; + remoteInfo = "RequestKit Mac"; + }; + 66C063341FCD95F500920667 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 66C063121FCD95C200920667 /* RequestKit.xcodeproj */; + proxyType = 1; + remoteGlobalIDString = 2337430C1C7981D700013492; + remoteInfo = "RequestKit watchOS"; + }; /* End PBXContainerItemProxy section */ /* Begin PBXCopyFilesBuildPhase section */ @@ -173,7 +247,6 @@ dstPath = ""; dstSubfolderSpec = 10; files = ( - 234F4C401BDE113800A58EF7 /* RequestKit.framework in Carthage embed */, ); name = "Carthage embed"; runOnlyForDeploymentPostprocessing = 0; @@ -184,7 +257,6 @@ dstPath = ""; dstSubfolderSpec = 10; files = ( - 23F6433F1C7AEED7000427B3 /* RequestKit.framework in Carthage embed */, ); name = "Carthage embed"; runOnlyForDeploymentPostprocessing = 0; @@ -195,7 +267,6 @@ dstPath = ""; dstSubfolderSpec = 10; files = ( - 23F643451C7AEF37000427B3 /* RequestKit.framework in Carthage embed */, ); name = "Carthage embed"; runOnlyForDeploymentPostprocessing = 0; @@ -216,7 +287,6 @@ 234F4BDA1BDDE44600A58EF7 /* user_me.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = user_me.json; path = Fixtures/user_me.json; sourceTree = ""; }; 234F4BDB1BDDE44600A58EF7 /* user_mietzmithut.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = user_mietzmithut.json; path = Fixtures/user_mietzmithut.json; sourceTree = ""; }; 234F4BDC1BDDE44600A58EF7 /* user_repos.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = user_repos.json; path = Fixtures/user_repos.json; sourceTree = ""; }; - 234F4C3E1BDE0FE200A58EF7 /* RequestKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = RequestKit.framework; path = Carthage/Build/iOS/RequestKit.framework; sourceTree = ""; }; 237F91E31E5AEC82005FAA6B /* URL+URLParameters.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "URL+URLParameters.swift"; sourceTree = ""; }; 239BE7C91B8C47A100D2CE22 /* OctoKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = OctoKit.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 239BE7CC1B8C47A100D2CE22 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; @@ -233,11 +303,9 @@ 23CAF27E1C7AB60C005011C4 /* OctoKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = OctoKit.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 23CAF2871C7AB60D005011C4 /* OctoKit MacTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "OctoKit MacTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; 23CAF29A1C7AB619005011C4 /* OctoKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = OctoKit.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - 23CAF2D41C7AB9C0005011C4 /* RequestKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = RequestKit.framework; path = Carthage/Build/tvOS/RequestKit.framework; sourceTree = ""; }; - 23CAF2D61C7AB9CE005011C4 /* RequestKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = RequestKit.framework; path = Carthage/Build/Mac/RequestKit.framework; sourceTree = ""; }; - 23CAF2D81C7AB9DB005011C4 /* RequestKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = RequestKit.framework; path = Carthage/Build/watchOS/RequestKit.framework; sourceTree = ""; }; 23F6433C1C7AEEB6000427B3 /* Nocilla.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Nocilla.framework; path = Carthage/Build/tvOS/Nocilla.framework; sourceTree = ""; }; 23F643421C7AEF2F000427B3 /* Nocilla.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Nocilla.framework; path = Carthage/Build/Mac/Nocilla.framework; sourceTree = ""; }; + 66C063121FCD95C200920667 /* RequestKit.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RequestKit.xcodeproj; path = ../RequestKit/RequestKit.xcodeproj; sourceTree = ""; }; BF8C72B985869B84F46B4E9D /* Parameters.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Parameters.swift; sourceTree = ""; }; BF8C73E0EF3CEEBDEA68DD5E /* PullRequest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PullRequest.swift; sourceTree = ""; }; BF8C76EB002802C14A08F63E /* PullRequestTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PullRequestTests.swift; sourceTree = ""; }; @@ -270,7 +338,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 234F4C3F1BDE0FE200A58EF7 /* RequestKit.framework in Frameworks */, + 66C0632A1FCD95CE00920667 /* RequestKit.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -278,7 +346,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 23CAF2D51C7AB9C0005011C4 /* RequestKit.framework in Frameworks */, + 66C0632B1FCD95D200920667 /* RequestKit.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -294,7 +362,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 23CAF2DA1C7ABA67005011C4 /* RequestKit.framework in Frameworks */, + 66C0632C1FCD95D900920667 /* RequestKit.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -310,7 +378,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 23CAF2D91C7AB9DB005011C4 /* RequestKit.framework in Frameworks */, + 66C0632D1FCD95E000920667 /* RequestKit.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -385,15 +453,26 @@ name = "Supporting Files"; sourceTree = ""; }; + 66C063131FCD95C200920667 /* Products */ = { + isa = PBXGroup; + children = ( + 66C0631D1FCD95C200920667 /* RequestKit.framework */, + 66C0631F1FCD95C200920667 /* RequestKitTests.xctest */, + 66C063211FCD95C200920667 /* RequestKit.framework */, + 66C063231FCD95C200920667 /* RequestKit tvTests.xctest */, + 66C063251FCD95C200920667 /* RequestKit.framework */, + 66C063271FCD95C200920667 /* RequestKit.framework */, + 66C063291FCD95C200920667 /* RequestKit MacTests.xctest */, + ); + name = Products; + sourceTree = ""; + }; B975D5A3F8B0384EFB0C5863 /* Frameworks */ = { isa = PBXGroup; children = ( + 66C063121FCD95C200920667 /* RequestKit.xcodeproj */, 23F643421C7AEF2F000427B3 /* Nocilla.framework */, 23F6433C1C7AEEB6000427B3 /* Nocilla.framework */, - 23CAF2D81C7AB9DB005011C4 /* RequestKit.framework */, - 23CAF2D61C7AB9CE005011C4 /* RequestKit.framework */, - 23CAF2D41C7AB9C0005011C4 /* RequestKit.framework */, - 234F4C3E1BDE0FE200A58EF7 /* RequestKit.framework */, 23B2679C1BDDDBBE003887E3 /* Nocilla.framework */, ); name = Frameworks; @@ -492,6 +571,7 @@ buildRules = ( ); dependencies = ( + 66C0632F1FCD95E700920667 /* PBXTargetDependency */, ); name = OctoKit; productName = OctoKit; @@ -510,6 +590,7 @@ buildRules = ( ); dependencies = ( + 66C063311FCD95EB00920667 /* PBXTargetDependency */, ); name = "OctoKit tvOS"; productName = "OctoKit tvOS"; @@ -547,6 +628,7 @@ buildRules = ( ); dependencies = ( + 66C063331FCD95EF00920667 /* PBXTargetDependency */, ); name = "OctoKit Mac"; productName = "OctoKit Mac"; @@ -584,6 +666,7 @@ buildRules = ( ); dependencies = ( + 66C063351FCD95F500920667 /* PBXTargetDependency */, ); name = "OctoKit watchOS"; productName = "OctoKit watchOS"; @@ -641,6 +724,12 @@ mainGroup = F01C6F2B1A6429CC0072FA44; productRefGroup = F01C6F351A6429CC0072FA44 /* Products */; projectDirPath = ""; + projectReferences = ( + { + ProductGroup = 66C063131FCD95C200920667 /* Products */; + ProjectRef = 66C063121FCD95C200920667 /* RequestKit.xcodeproj */; + }, + ); projectRoot = ""; targets = ( 239BE7C81B8C47A100D2CE22 /* OctoKit */, @@ -654,6 +743,58 @@ }; /* End PBXProject section */ +/* Begin PBXReferenceProxy section */ + 66C0631D1FCD95C200920667 /* RequestKit.framework */ = { + isa = PBXReferenceProxy; + fileType = wrapper.framework; + path = RequestKit.framework; + remoteRef = 66C0631C1FCD95C200920667 /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + 66C0631F1FCD95C200920667 /* RequestKitTests.xctest */ = { + isa = PBXReferenceProxy; + fileType = wrapper.cfbundle; + path = RequestKitTests.xctest; + remoteRef = 66C0631E1FCD95C200920667 /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + 66C063211FCD95C200920667 /* RequestKit.framework */ = { + isa = PBXReferenceProxy; + fileType = wrapper.framework; + path = RequestKit.framework; + remoteRef = 66C063201FCD95C200920667 /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + 66C063231FCD95C200920667 /* RequestKit tvTests.xctest */ = { + isa = PBXReferenceProxy; + fileType = wrapper.cfbundle; + path = "RequestKit tvTests.xctest"; + remoteRef = 66C063221FCD95C200920667 /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + 66C063251FCD95C200920667 /* RequestKit.framework */ = { + isa = PBXReferenceProxy; + fileType = wrapper.framework; + path = RequestKit.framework; + remoteRef = 66C063241FCD95C200920667 /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + 66C063271FCD95C200920667 /* RequestKit.framework */ = { + isa = PBXReferenceProxy; + fileType = wrapper.framework; + path = RequestKit.framework; + remoteRef = 66C063261FCD95C200920667 /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + 66C063291FCD95C200920667 /* RequestKit MacTests.xctest */ = { + isa = PBXReferenceProxy; + fileType = wrapper.cfbundle; + path = "RequestKit MacTests.xctest"; + remoteRef = 66C063281FCD95C200920667 /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; +/* End PBXReferenceProxy section */ + /* Begin PBXResourcesBuildPhase section */ 234F4BA71BDDE31A00A58EF7 /* Resources */ = { isa = PBXResourcesBuildPhase; @@ -893,6 +1034,26 @@ target = 23CAF27D1C7AB60C005011C4 /* OctoKit Mac */; targetProxy = 23CAF2891C7AB60D005011C4 /* PBXContainerItemProxy */; }; + 66C0632F1FCD95E700920667 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = RequestKit; + targetProxy = 66C0632E1FCD95E700920667 /* PBXContainerItemProxy */; + }; + 66C063311FCD95EB00920667 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = "RequestKit tvOS"; + targetProxy = 66C063301FCD95EB00920667 /* PBXContainerItemProxy */; + }; + 66C063331FCD95EF00920667 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = "RequestKit Mac"; + targetProxy = 66C063321FCD95EF00920667 /* PBXContainerItemProxy */; + }; + 66C063351FCD95F500920667 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = "RequestKit watchOS"; + targetProxy = 66C063341FCD95F500920667 /* PBXContainerItemProxy */; + }; /* End PBXTargetDependency section */ /* Begin XCBuildConfiguration section */ diff --git a/OctoKit/Follow.swift b/OctoKit/Follow.swift index 8090a7e1..84435bbc 100644 --- a/OctoKit/Follow.swift +++ b/OctoKit/Follow.swift @@ -10,13 +10,12 @@ public extension Octokit { */ public func myFollowers(_ session: RequestKitURLSession = URLSession.shared, completion: @escaping (_ response: Response<[User]>) -> Void) -> URLSessionDataTaskProtocol? { let router = FollowRouter.readAuthenticatedFollowers(configuration) - return router.loadJSON(session, expectedResultType: [[String: AnyObject]].self) { json, error in + return router.load(session, expectedResultType: [User].self) { users, error in if let error = error { completion(Response.failure(error)) } else { - if let json = json { - let parsedUsers = json.map { User($0) } - completion(Response.success(parsedUsers)) + if let users = users { + completion(Response.success(users)) } } } @@ -30,13 +29,12 @@ public extension Octokit { */ public func followers(_ session: RequestKitURLSession = URLSession.shared, name: String, completion: @escaping (_ response: Response<[User]>) -> Void) -> URLSessionDataTaskProtocol? { let router = FollowRouter.readFollowers(name, configuration) - return router.loadJSON(session, expectedResultType: [[String: AnyObject]].self) { json, error in + return router.load(session, expectedResultType: [User].self) { users, error in if let error = error { completion(Response.failure(error)) } else { - if let json = json { - let parsedUsers = json.map { User($0) } - completion(Response.success(parsedUsers)) + if let users = users { + completion(Response.success(users)) } } } @@ -49,13 +47,12 @@ public extension Octokit { */ public func myFollowing(_ session: RequestKitURLSession = URLSession.shared, completion: @escaping (_ response: Response<[User]>) -> Void) -> URLSessionDataTaskProtocol? { let router = FollowRouter.readAuthenticatedFollowing(configuration) - return router.loadJSON(session, expectedResultType: [[String: AnyObject]].self) { json, error in + return router.load(session, expectedResultType: [User].self) { users, error in if let error = error { completion(Response.failure(error)) } else { - if let json = json { - let parsedUsers = json.map { User($0) } - completion(.success(parsedUsers)) + if let users = users { + completion(.success(users)) } } } @@ -69,13 +66,12 @@ public extension Octokit { */ public func following(_ session: RequestKitURLSession = URLSession.shared, name: String, completion: @escaping (_ response: Response<[User]>) -> Void) -> URLSessionDataTaskProtocol? { let router = FollowRouter.readFollowing(name, configuration) - return router.loadJSON(session, expectedResultType: [[String: AnyObject]].self) { json, error in + return router.load(session, expectedResultType: [User].self) { users, error in if let error = error { completion(Response.failure(error)) } else { - if let json = json { - let parsedUsers = json.map { User($0) } - completion(Response.success(parsedUsers)) + if let users = users { + completion(Response.success(users)) } } } diff --git a/OctoKit/Issue.swift b/OctoKit/Issue.swift index 4f8877b5..45c31103 100644 --- a/OctoKit/Issue.swift +++ b/OctoKit/Issue.swift @@ -3,14 +3,14 @@ import RequestKit // MARK: model -public enum Openness: String { +public enum Openness: String, Codable { case Open = "open" case Closed = "closed" case All = "all" } -@objc open class Issue: NSObject { - @objc open var id: Int +@objc open class Issue: NSObject, Codable { + @objc open private(set) var id: Int = 01 @objc open var url: URL? @objc open var repositoryURL: URL? @objc open var labelsURL: URL? @@ -27,51 +27,33 @@ public enum Openness: String { @objc open var milestone: Milestone? open var locked: Bool? open var comments: Int? - @objc open var closedAt: Date? - @objc open var createdAt: Date? - @objc open var updatedAt: Date? + @objc open var closedAt: Time? + @objc open var createdAt: Time? + @objc open var updatedAt: Time? @objc open var closedBy: User? - - @objc public init(_ json: [String: AnyObject]) { - if let id = json["id"] as? Int { - self.id = id - if let urlString = json["url"] as? String, let url = URL(string: urlString) { - self.url = url - } - if let urlString = json["repository_url"] as? String, let url = URL(string: urlString) { - repositoryURL = url - } - if let urlString = json["labels_url"] as? String, let url = URL(string: urlString) { - labelsURL = url - } - if let urlString = json["comments_url"] as? String, let url = URL(string: urlString) { - commentsURL = url - } - if let urlString = json["events_url"] as? String, let url = URL(string: urlString) { - eventsURL = url - } - if let urlString = json["html_url"] as? String, let url = URL(string: urlString) { - htmlURL = url - } - number = json["number"] as? Int - state = Openness(rawValue: json["state"] as? String ?? "") - title = json["title"] as? String - body = json["body"] as? String - user = User(json["user"] as? [String: AnyObject] ?? [:]) - if let labelDictionaries = json["labels"] as? [[String: AnyObject]] { - labels = labelDictionaries.flatMap { Label($0) } - } - assignee = User(json["assignee"] as? [String: AnyObject] ?? [:]) - milestone = Milestone(json["milestone"] as? [String: AnyObject] ?? [:]) - locked = json["locked"] as? Bool - comments = json["comments"] as? Int - closedAt = Time.rfc3339Date(json["closed_at"] as? String) - createdAt = Time.rfc3339Date(json["created_at"] as? String) - updatedAt = Time.rfc3339Date(json["updated_at"] as? String) - closedBy = User(json["closed_by"] as? [String: AnyObject] ?? [:]) - } else { - id = -1 - } + + enum CodingKeys: String, CodingKey { + case id + case url + case repositoryURL = "repository_url" + case labelsURL = "labels_url" + case commentsURL = "comments_url" + case eventsURL = "events_url" + case htmlURL = "html_url" + case number + case state + case title + case body + case user + case labels + case assignee + case milestone + case locked + case comments + case closedAt = "closed_at" + case createdAt = "created_at" + case updatedAt = "updated_at" + case closedBy = "closed_by" } } @@ -89,13 +71,12 @@ public extension Octokit { */ public func myIssues(_ session: RequestKitURLSession = URLSession.shared, state: Openness = .Open, page: String = "1", perPage: String = "100", completion: @escaping (_ response: Response<[Issue]>) -> Void) -> URLSessionDataTaskProtocol? { let router = IssueRouter.readAuthenticatedIssues(configuration, page, perPage, state) - return router.loadJSON(session, expectedResultType: [[String: AnyObject]].self) { json, error in + return router.load(session, expectedResultType: [Issue].self) { issues, error in if let error = error { completion(Response.failure(error)) } else { - if let json = json { - let parsedIssues = json.map { Issue($0) } - completion(Response.success(parsedIssues)) + if let issues = issues { + completion(Response.success(issues)) } } } @@ -111,12 +92,11 @@ public extension Octokit { */ public func issue(_ session: RequestKitURLSession = URLSession.shared, owner: String, repository: String, number: Int, completion: @escaping (_ response: Response) -> Void) -> URLSessionDataTaskProtocol? { let router = IssueRouter.readIssue(configuration, owner, repository, number) - return router.loadJSON(session, expectedResultType: [String: AnyObject].self) { json, error in + return router.load(session, expectedResultType: Issue.self) { issue, error in if let error = error { completion(Response.failure(error)) } else { - if let json = json { - let issue = Issue(json) + if let issue = issue { completion(Response.success(issue)) } } @@ -135,13 +115,12 @@ public extension Octokit { */ public func issues(_ session: RequestKitURLSession = URLSession.shared, owner: String, repository: String, state: Openness = .Open, page: String = "1", perPage: String = "100", completion: @escaping (_ response: Response<[Issue]>) -> Void) -> URLSessionDataTaskProtocol? { let router = IssueRouter.readIssues(configuration, owner, repository, page, perPage, state) - return router.loadJSON(session, expectedResultType: [[String: AnyObject]].self) { json, error in + return router.load(session, expectedResultType: [Issue].self) { issues, error in if let error = error { completion(Response.failure(error)) } else { - if let json = json { - let parsedIssues = json.map { Issue($0) } - completion(Response.success(parsedIssues)) + if let issues = issues { + completion(Response.success(issues)) } } } @@ -159,12 +138,11 @@ public extension Octokit { */ public func postIssue(_ session: RequestKitURLSession = URLSession.shared, owner: String, repository: String, title: String, body: String? = nil, assignee: String? = nil, completion: @escaping (_ response: Response) -> Void) -> URLSessionDataTaskProtocol? { let router = IssueRouter.postIssue(configuration, owner, repository, title, body, assignee) - return router.postJSON(session, expectedResultType: [String: AnyObject].self) { json, error in + return router.post(session, expectedResultType: Issue.self) { issue, error in if let error = error { completion(Response.failure(error)) } else { - if let json = json { - let issue = Issue(json) + if let issue = issue { completion(Response.success(issue)) } } @@ -185,12 +163,11 @@ public extension Octokit { */ public func patchIssue(_ session: RequestKitURLSession = URLSession.shared, owner: String, repository: String, number: Int, title: String? = nil, body: String? = nil, assignee: String? = nil, state: Openness? = nil, completion: @escaping (_ response: Response) -> Void) -> URLSessionDataTaskProtocol? { let router = IssueRouter.patchIssue(configuration, owner, repository, number, title, body, assignee, state) - return router.postJSON(session, expectedResultType: [String: AnyObject].self) { json, error in + return router.post(session, expectedResultType: Issue.self) { issue, error in if let error = error { completion(Response.failure(error)) } else { - if let json = json { - let issue = Issue(json) + if let issue = issue { completion(Response.success(issue)) } } diff --git a/OctoKit/Label.swift b/OctoKit/Label.swift index 7eed9817..fec701a2 100644 --- a/OctoKit/Label.swift +++ b/OctoKit/Label.swift @@ -22,22 +22,8 @@ extension Color { } } -@objc open class Label: NSObject { +@objc open class Label: NSObject, Codable { @objc open var url: URL? @objc open var name: String? - #if os(OSX) - open var color: NSColor? - #elseif os(iOS) || os(tvOS) || os(watchOS) - @objc public var color: UIColor? - #endif - - @objc public init(_ json: [String: AnyObject]) { - if let urlString = json["url"] as? String, let url = URL(string: urlString) { - self.url = url - } - name = json["name"] as? String - if let colorString = json["color"] as? String { - color = Color(hexTriplet: colorString) - } - } + @objc open var color: String? } diff --git a/OctoKit/Milestone.swift b/OctoKit/Milestone.swift index 7e3ce1c0..b39bbb93 100644 --- a/OctoKit/Milestone.swift +++ b/OctoKit/Milestone.swift @@ -1,10 +1,10 @@ import Foundation -@objc open class Milestone: NSObject { +@objc open class Milestone: NSObject, Codable { @objc open var url: URL? @objc open var htmlURL: URL? @objc open var labelsURL: URL? - @objc open var id: Int + @objc open private(set) var id: Int = -1 open var number: Int? open var state: Openness? @objc open var title: String? @@ -12,33 +12,26 @@ import Foundation @objc open var creator: User? open var openIssues: Int? open var closedIssues: Int? - @objc open var createdAt: Date? - @objc open var updatedAt: Date? - @objc open var closedAt: Date? - @objc open var dueOn: Date? - - @objc public init?(_ json: [String: AnyObject]) { - if let id = json["id"] as? Int { - if let urlString = json["html_url"] as? String, let url = URL(string: urlString) { - htmlURL = url - } - if let urlString = json["labels_url"] as? String, let url = URL(string: urlString) { - labelsURL = url - } - self.id = id - number = json["number"] as? Int - state = Openness(rawValue: json["state"] as? String ?? "") - title = json["title"] as? String - milestoneDescription = json["description"] as? String - creator = User(json["creator"] as? [String: AnyObject] ?? [:]) - openIssues = json["open_issues"] as? Int - closedIssues = json["closed_issues"] as? Int - createdAt = Time.rfc3339Date(json["created_at"] as? String) - updatedAt = Time.rfc3339Date(json["updated_at"] as? String) - closedAt = Time.rfc3339Date(json["closed_at"] as? String) - dueOn = Time.rfc3339Date(json["due_on"] as? String) - } else { - id = -1 - } + @objc open var createdAt: Time? + @objc open var updatedAt: Time? + @objc open var closedAt: Time? + @objc open var dueOn: Time? + + enum CodingKeys: String, CodingKey { + case id + case url + case htmlURL = "html_url" + case labelsURL = "labels_url" + case number + case state + case title + case milestoneDescription = "description" + case creator + case openIssues = "open_issues" + case closedIssues = "closed_issues" + case createdAt = "created_at" + case updatedAt = "updated_at" + case closedAt = "closed_at" + case dueOn = "due_on" } } diff --git a/OctoKit/PullRequest.swift b/OctoKit/PullRequest.swift index 4c1b8a47..69b0c3d3 100644 --- a/OctoKit/PullRequest.swift +++ b/OctoKit/PullRequest.swift @@ -69,14 +69,14 @@ import RequestKit title = json["title"] as? String body = json["body"] as? String - assignee = User(json["assignee"] as? [String: AnyObject] ?? [:]) - milestone = Milestone(json["milestone"] as? [String: AnyObject] ?? [:]) +// assignee = User(json["assignee"] as? [String: AnyObject] ?? [:]) +// milestone = Milestone(json["milestone"] as? [String: AnyObject] ?? [:]) locked = json["locked"] as? Bool - closedAt = Time.rfc3339Date(json["closed_at"] as? String) - createdAt = Time.rfc3339Date(json["created_at"] as? String) - updatedAt = Time.rfc3339Date(json["updated_at"] as? String) - mergedAt = Time.rfc3339Date(json["merged_at"] as? String) +// closedAt = Time.rfc3339Date(json["closed_at"] as? String) +// createdAt = Time.rfc3339Date(json["created_at"] as? String) +// updatedAt = Time.rfc3339Date(json["updated_at"] as? String) +// mergedAt = Time.rfc3339Date(json["merged_at"] as? String) } else { id = -1 } diff --git a/OctoKit/Repositories.swift b/OctoKit/Repositories.swift index 0221d774..4f11ddbb 100644 --- a/OctoKit/Repositories.swift +++ b/OctoKit/Repositories.swift @@ -3,41 +3,35 @@ import RequestKit // MARK: model -@objc open class Repository: NSObject { - @objc open let id: Int - @objc open let owner: User +@objc open class Repository: NSObject, Codable { + @objc open private(set) var id: Int = -1 + @objc open private(set) var owner = User() @objc open var name: String? @objc open var fullName: String? - @objc open var isPrivate: Bool + @objc open private(set) var isPrivate: Bool = false @objc open var repositoryDescription: String? - open var isFork: Bool? + @objc open private(set) var isFork: Bool = false @objc open var gitURL: String? @objc open var sshURL: String? @objc open var cloneURL: String? @objc open var htmlURL: String? - @objc open var size: Int - @objc open var lastPush: Date? + @objc open private(set) var size: Int = -1 +// @objc open var lastPush: Date? - @objc public init(_ json: [String: AnyObject]) { - owner = User(json["owner"] as? [String: AnyObject] ?? [:]) - if let id = json["id"] as? Int { - self.id = id - name = json["name"] as? String - fullName = json["full_name"] as? String - isPrivate = json["private"] as? Bool ?? false - repositoryDescription = json["description"] as? String - isFork = json["fork"] as? Bool - gitURL = json["git_url"] as? String - sshURL = json["ssh_url"] as? String - cloneURL = json["clone_url"] as? String - htmlURL = json["html_url"] as? String - size = json["size"] as? Int ?? 0 - lastPush = Time.rfc3339Date(json["pushed_at"] as? String) - } else { - id = -1 - isPrivate = false - size = 0 - } + enum CodingKeys: String, CodingKey { + case id + case owner + case name + case fullName = "full_name" + case isPrivate = "private" + case repositoryDescription = "description" + case isFork = "fork" + case gitURL = "git_url" + case sshURL = "ssh_url" + case cloneURL = "clone_url" + case htmlURL = "html_url" + case size +// case lastPush = "pushed_at" } } @@ -57,13 +51,12 @@ public extension Octokit { let router = (owner != nil) ? RepositoryRouter.readRepositories(configuration, owner!, page, perPage) : RepositoryRouter.readAuthenticatedRepositories(configuration, page, perPage) - return router.loadJSON(session, expectedResultType: [[String: AnyObject]].self) { json, error in + return router.load(session, expectedResultType: [Repository].self) { repos, error in if let error = error { completion(Response.failure(error)) } - if let json = json { - let repos = json.map { Repository($0) } + if let repos = repos { completion(Response.success(repos)) } } @@ -78,12 +71,11 @@ public extension Octokit { */ public func repository(_ session: RequestKitURLSession = URLSession.shared, owner: String, name: String, completion: @escaping (_ response: Response) -> Void) -> URLSessionDataTaskProtocol? { let router = RepositoryRouter.readRepository(configuration, owner, name) - return router.loadJSON(session, expectedResultType: [String: AnyObject].self) { json, error in + return router.load(session, expectedResultType: Repository.self) { repo, error in if let error = error { completion(Response.failure(error)) } else { - if let json = json { - let repo = Repository(json) + if let repo = repo { completion(Response.success(repo)) } } diff --git a/OctoKit/Stars.swift b/OctoKit/Stars.swift index bed3524d..88adcf80 100644 --- a/OctoKit/Stars.swift +++ b/OctoKit/Stars.swift @@ -11,13 +11,12 @@ public extension Octokit { */ public func stars(_ session: RequestKitURLSession = URLSession.shared, name: String, completion: @escaping (_ response: Response<[Repository]>) -> Void) -> URLSessionDataTaskProtocol? { let router = StarsRouter.readStars(name, configuration) - return router.loadJSON(session, expectedResultType: [[String: AnyObject]].self) { json, error in + return router.load(session, expectedResultType: [Repository].self) { repos, error in if let error = error { completion(Response.failure(error)) } else { - if let json = json { - let parsedStars = json.map { Repository($0) } - completion(Response.success(parsedStars)) + if let repos = repos { + completion(Response.success(repos)) } } } @@ -30,13 +29,12 @@ public extension Octokit { */ public func myStars(_ session: RequestKitURLSession = URLSession.shared, completion: @escaping (_ response: Response<[Repository]>) -> Void) -> URLSessionDataTaskProtocol? { let router = StarsRouter.readAuthenticatedStars(configuration) - return router.loadJSON(session, expectedResultType: [[String: AnyObject]].self) { json, error in + return router.loadJSON(session, expectedResultType: [Repository].self) { repos, error in if let error = error { completion(Response.failure(error)) } else { - if let json = json { - let parsedStars = json.map { Repository($0) } - completion(Response.success(parsedStars)) + if let repos = repos { + completion(Response.success(repos)) } } } diff --git a/OctoKit/Time.swift b/OctoKit/Time.swift index 5ef2918e..b3b2ee7d 100644 --- a/OctoKit/Time.swift +++ b/OctoKit/Time.swift @@ -1,6 +1,7 @@ import Foundation -struct Time { +@objc public class Time: NSObject, Codable { + private(set) var string: String? = nil /** A date formatter for RFC 3339 style timestamps. Uses POSIX locale and GMT timezone so that date values are parsed as absolutes. @@ -21,7 +22,7 @@ struct Time { - parameter string: The string representation of the date - returns: An `NSDate` with a successful parse, otherwise `nil` */ - static func rfc3339Date(_ string: String?) -> Date? { + @objc func rfc3339Date() -> Date? { guard let string = string else { return nil } return Time.rfc3339DateFormatter.date(from: string) } diff --git a/OctoKit/User.swift b/OctoKit/User.swift index e4f8cc13..98d01496 100644 --- a/OctoKit/User.swift +++ b/OctoKit/User.swift @@ -3,8 +3,8 @@ import RequestKit // MARK: model -@objc open class User: NSObject { - @objc open let id: Int +@objc open class User: NSObject, Codable { + @objc open internal(set) var id: Int = -1 @objc open var login: String? @objc open var avatarURL: String? @objc open var gravatarID: String? @@ -18,24 +18,20 @@ import RequestKit open var numberOfPublicGists: Int? open var numberOfPrivateRepos: Int? - @objc public init(_ json: [String: AnyObject]) { - if let id = json["id"] as? Int { - self.id = id - login = json["login"] as? String - avatarURL = json["avatar_url"] as? String - gravatarID = json["gravatar_id"] as? String - type = json["type"] as? String - name = json["name"] as? String - company = json["company"] as? String - blog = json["blog"] as? String - location = json["location"] as? String - email = json["email"] as? String - numberOfPublicRepos = json["public_repos"] as? Int - numberOfPublicGists = json["public_gists"] as? Int - numberOfPrivateRepos = json["total_private_repos"] as? Int - } else { - id = -1 - } + enum CodingKeys: String, CodingKey { + case id + case login + case avatarURL = "avatar_url" + case gravatarID = "gravatar_id" + case type + case name + case company + case blog + case location + case email + case numberOfPublicRepos = "public_repos" + case numberOfPublicGists = "public_gists" + case numberOfPrivateRepos = "total_private_repos" } } @@ -51,13 +47,12 @@ public extension Octokit { */ public func user(_ session: RequestKitURLSession = URLSession.shared, name: String, completion: @escaping (_ response: Response) -> Void) -> URLSessionDataTaskProtocol? { let router = UserRouter.readUser(name, self.configuration) - return router.loadJSON(session, expectedResultType: [String: AnyObject].self) { json, error in + return router.load(session, expectedResultType: User.self) { user, error in if let error = error { completion(Response.failure(error)) } else { - if let json = json { - let parsedUser = User(json) - completion(Response.success(parsedUser)) + if let user = user { + completion(Response.success(user)) } } } @@ -70,13 +65,12 @@ public extension Octokit { */ public func me(_ session: RequestKitURLSession = URLSession.shared, completion: @escaping (_ response: Response) -> Void) -> URLSessionDataTaskProtocol? { let router = UserRouter.readAuthenticatedUser(self.configuration) - return router.loadJSON(session, expectedResultType: [String: AnyObject].self) { json, error in + return router.load(session, expectedResultType: User.self) { user, error in if let error = error { completion(Response.failure(error)) } else { - if let json = json { - let parsedUser = User(json) - completion(Response.success(parsedUser)) + if let user = user { + completion(Response.success(user)) } } } diff --git a/OctoKitTests/RepositoryTests.swift b/OctoKitTests/RepositoryTests.swift index 34979389..7f6dff91 100644 --- a/OctoKitTests/RepositoryTests.swift +++ b/OctoKitTests/RepositoryTests.swift @@ -132,7 +132,7 @@ class RepositoryTests: XCTestCase { // MARK: Model Tests func testUserParsingFullRepository() { - let subject = Repository(Helper.JSONFromFile("repo") as! [String: AnyObject]) + let subject = Helper.codableFromFile("repo", type: Repository.self) XCTAssertEqual(subject.owner.login, "mietzmithut") XCTAssertEqual(subject.owner.id, 4672699) diff --git a/OctoKitTests/TestHelper.swift b/OctoKitTests/TestHelper.swift index 71aa59e5..53e23177 100644 --- a/OctoKitTests/TestHelper.swift +++ b/OctoKitTests/TestHelper.swift @@ -19,4 +19,11 @@ internal class Helper { options: JSONSerialization.ReadingOptions.mutableContainers) return dict! } + + internal class func codableFromFile(_ name: String, type: T.Type) -> T where T: Codable { + let bundle = Bundle(for: self) + let path = bundle.path(forResource: name, ofType: "json")! + let data = try! Data(contentsOf: URL(fileURLWithPath: path)) + return try! JSONDecoder().decode(T.self, from: data) + } } diff --git a/OctoKitTests/UserTests.swift b/OctoKitTests/UserTests.swift index d121d42e..fd11aff1 100644 --- a/OctoKitTests/UserTests.swift +++ b/OctoKitTests/UserTests.swift @@ -68,7 +68,7 @@ class UserTests: XCTestCase { // MARK: Model Tests func testUserParsingFullUser() { - let subject = User(Helper.JSONFromFile("user_me") as! [String: AnyObject]) + let subject = Helper.codableFromFile("user_me", type: User.self) XCTAssertEqual(subject.login, "pietbrauer") XCTAssertEqual(subject.id, 759730) XCTAssertEqual(subject.avatarURL, "https://avatars.githubusercontent.com/u/759730?v=3") @@ -85,19 +85,19 @@ class UserTests: XCTestCase { } func testUserParsingMinimalUser() { - let subject = User(Helper.JSONFromFile("user_mietzmithut") as! [String: AnyObject]) - XCTAssertEqual(subject.login!, "mietzmithut") + let subject = Helper.codableFromFile("user_mietzmithut", type: User.self) + XCTAssertEqual(subject.login, "mietzmithut") XCTAssertEqual(subject.id, 4672699) - XCTAssertEqual(subject.avatarURL!, "https://avatars.githubusercontent.com/u/4672699?v=3") - XCTAssertEqual(subject.gravatarID!, "") - XCTAssertEqual(subject.type!, "User") - XCTAssertEqual(subject.name!, "Julia Kallenberg") - XCTAssertEqual(subject.company!, "") - XCTAssertEqual(subject.blog!, "") - XCTAssertEqual(subject.location!, "Hamburg") - XCTAssertEqual(subject.email!, "") - XCTAssertEqual(subject.numberOfPublicRepos!, 7) - XCTAssertEqual(subject.numberOfPublicGists!, 0) + XCTAssertEqual(subject.avatarURL, "https://avatars.githubusercontent.com/u/4672699?v=3") + XCTAssertEqual(subject.gravatarID, "") + XCTAssertEqual(subject.type, "User") + XCTAssertEqual(subject.name, "Julia Kallenberg") + XCTAssertEqual(subject.company, "") + XCTAssertEqual(subject.blog, "") + XCTAssertEqual(subject.location, "Hamburg") + XCTAssertEqual(subject.email, "") + XCTAssertEqual(subject.numberOfPublicRepos, 7) + XCTAssertEqual(subject.numberOfPublicGists, 0) XCTAssertNil(subject.numberOfPrivateRepos) } } From 7a4de2cb37302f7501c4237db2ad7f6db07eff55 Mon Sep 17 00:00:00 2001 From: Piet Brauer Date: Thu, 30 Nov 2017 18:20:12 +0100 Subject: [PATCH 118/302] Update Issues to be codable --- OctoKit/Issue.swift | 6 +++--- OctoKit/Milestone.swift | 8 ++++---- OctoKit/Time.swift | 25 +++++++++++-------------- OctoKitTests/Fixtures/issue.json | 4 ++-- OctoKitTests/Fixtures/issues.json | 28 ++++++++++++++-------------- OctoKitTests/IssueTests.swift | 6 +++--- 6 files changed, 37 insertions(+), 40 deletions(-) diff --git a/OctoKit/Issue.swift b/OctoKit/Issue.swift index 45c31103..143820e8 100644 --- a/OctoKit/Issue.swift +++ b/OctoKit/Issue.swift @@ -27,9 +27,9 @@ public enum Openness: String, Codable { @objc open var milestone: Milestone? open var locked: Bool? open var comments: Int? - @objc open var closedAt: Time? - @objc open var createdAt: Time? - @objc open var updatedAt: Time? + @objc open var closedAt: String? + @objc open var createdAt: String? + @objc open var updatedAt: String? @objc open var closedBy: User? enum CodingKeys: String, CodingKey { diff --git a/OctoKit/Milestone.swift b/OctoKit/Milestone.swift index b39bbb93..5f52cabe 100644 --- a/OctoKit/Milestone.swift +++ b/OctoKit/Milestone.swift @@ -12,10 +12,10 @@ import Foundation @objc open var creator: User? open var openIssues: Int? open var closedIssues: Int? - @objc open var createdAt: Time? - @objc open var updatedAt: Time? - @objc open var closedAt: Time? - @objc open var dueOn: Time? + @objc open var createdAt: String? + @objc open var updatedAt: String? + @objc open var closedAt: String? + @objc open var dueOn: String? enum CodingKeys: String, CodingKey { case id diff --git a/OctoKit/Time.swift b/OctoKit/Time.swift index b3b2ee7d..86f18394 100644 --- a/OctoKit/Time.swift +++ b/OctoKit/Time.swift @@ -1,14 +1,12 @@ import Foundation -@objc public class Time: NSObject, Codable { - private(set) var string: String? = nil - +public extension String { /** - A date formatter for RFC 3339 style timestamps. Uses POSIX locale and GMT timezone so that date values are parsed as absolutes. - - [https://tools.ietf.org/html/rfc3339](https://tools.ietf.org/html/rfc3339) - - [https://developer.apple.com/library/mac/qa/qa1480/_index.html](https://developer.apple.com/library/mac/qa/qa1480/_index.html) - - [https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/DataFormatting/Articles/dfDateFormatting10_4.html](https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/DataFormatting/Articles/dfDateFormatting10_4.html) - */ + A date formatter for RFC 3339 style timestamps. Uses POSIX locale and GMT timezone so that date values are parsed as absolutes. + - [https://tools.ietf.org/html/rfc3339](https://tools.ietf.org/html/rfc3339) + - [https://developer.apple.com/library/mac/qa/qa1480/_index.html](https://developer.apple.com/library/mac/qa/qa1480/_index.html) + - [https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/DataFormatting/Articles/dfDateFormatting10_4.html](https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/DataFormatting/Articles/dfDateFormatting10_4.html) + */ fileprivate static var rfc3339DateFormatter: DateFormatter = { let formatter = DateFormatter() formatter.dateFormat = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'" @@ -18,12 +16,11 @@ import Foundation }() /** - Parses RFC 3339 date strings into NSDate - - parameter string: The string representation of the date - - returns: An `NSDate` with a successful parse, otherwise `nil` + Parses RFC 3339 date strings into NSDate + - parameter string: The string representation of the date + - returns: An `NSDate` with a successful parse, otherwise `nil` */ - @objc func rfc3339Date() -> Date? { - guard let string = string else { return nil } - return Time.rfc3339DateFormatter.date(from: string) + func rfc3339Date() -> Date? { + return String.rfc3339DateFormatter.date(from: self) } } diff --git a/OctoKitTests/Fixtures/issue.json b/OctoKitTests/Fixtures/issue.json index 700915f1..1f543812 100644 --- a/OctoKitTests/Fixtures/issue.json +++ b/OctoKitTests/Fixtures/issue.json @@ -2,7 +2,7 @@ "id": 1, "url": "https://api.github.com/repos/octocat/Hello-World/issues/1347", "repository_url": "https://api.github.com/repos/octocat/Hello-World", - "labels_url": "https://api.github.com/repos/octocat/Hello-World/issues/1347/labels{/name}", + "labels_url": "https://api.github.com/repos/octocat/Hello-World/issues/1347/labels", "comments_url": "https://api.github.com/repos/octocat/Hello-World/issues/1347/comments", "events_url": "https://api.github.com/repos/octocat/Hello-World/issues/1347/events", "html_url": "https://github.com/octocat/Hello-World/issues/1347", @@ -101,4 +101,4 @@ "closed_at": null, "created_at": "2011-04-22T13:33:48Z", "updated_at": "2011-04-22T13:33:48Z" -} \ No newline at end of file +} diff --git a/OctoKitTests/Fixtures/issues.json b/OctoKitTests/Fixtures/issues.json index 7046abff..7d45ec23 100644 --- a/OctoKitTests/Fixtures/issues.json +++ b/OctoKitTests/Fixtures/issues.json @@ -3,7 +3,7 @@ "id": 1, "url": "https://api.github.com/repos/octocat/Hello-World/issues/1347", "repository_url": "https://api.github.com/repos/octocat/Hello-World", - "labels_url": "https://api.github.com/repos/octocat/Hello-World/issues/1347/labels{/name}", + "labels_url": "https://api.github.com/repos/octocat/Hello-World/issues/1347/labels", "comments_url": "https://api.github.com/repos/octocat/Hello-World/issues/1347/comments", "events_url": "https://api.github.com/repos/octocat/Hello-World/issues/1347/events", "html_url": "https://github.com/octocat/Hello-World/issues/1347", @@ -19,13 +19,13 @@ "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/octocat", "followers_url": "https://api.github.com/users/octocat/followers", - "following_url": "https://api.github.com/users/octocat/following{/other_user}", - "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", - "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", + "following_url": "https://api.github.com/users/octocat/following", + "gists_url": "https://api.github.com/users/octocat/gists", + "starred_url": "https://api.github.com/users/octocat/starred", "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", "organizations_url": "https://api.github.com/users/octocat/orgs", "repos_url": "https://api.github.com/users/octocat/repos", - "events_url": "https://api.github.com/users/octocat/events{/privacy}", + "events_url": "https://api.github.com/users/octocat/events", "received_events_url": "https://api.github.com/users/octocat/received_events", "type": "User", "site_admin": false @@ -45,13 +45,13 @@ "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/octocat", "followers_url": "https://api.github.com/users/octocat/followers", - "following_url": "https://api.github.com/users/octocat/following{/other_user}", - "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", - "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", + "following_url": "https://api.github.com/users/octocat/following", + "gists_url": "https://api.github.com/users/octocat/gists", + "starred_url": "https://api.github.com/users/octocat/starred", "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", "organizations_url": "https://api.github.com/users/octocat/orgs", "repos_url": "https://api.github.com/users/octocat/repos", - "events_url": "https://api.github.com/users/octocat/events{/privacy}", + "events_url": "https://api.github.com/users/octocat/events", "received_events_url": "https://api.github.com/users/octocat/received_events", "type": "User", "site_admin": false @@ -73,13 +73,13 @@ "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/octocat", "followers_url": "https://api.github.com/users/octocat/followers", - "following_url": "https://api.github.com/users/octocat/following{/other_user}", - "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", - "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", + "following_url": "https://api.github.com/users/octocat/following", + "gists_url": "https://api.github.com/users/octocat/gists", + "starred_url": "https://api.github.com/users/octocat/starred", "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", "organizations_url": "https://api.github.com/users/octocat/orgs", "repos_url": "https://api.github.com/users/octocat/repos", - "events_url": "https://api.github.com/users/octocat/events{/privacy}", + "events_url": "https://api.github.com/users/octocat/events", "received_events_url": "https://api.github.com/users/octocat/received_events", "type": "User", "site_admin": false @@ -103,4 +103,4 @@ "created_at": "2011-04-22T13:33:48Z", "updated_at": "2011-04-22T13:33:48Z" } -] \ No newline at end of file +] diff --git a/OctoKitTests/IssueTests.swift b/OctoKitTests/IssueTests.swift index 8ec2bfd8..42de30c1 100644 --- a/OctoKitTests/IssueTests.swift +++ b/OctoKitTests/IssueTests.swift @@ -11,8 +11,8 @@ class IssueTests: XCTestCase { switch response { case .success(let issues): XCTAssertEqual(issues.count, 1) - case .failure: - XCTAssert(false, "should not get an error") + case .failure(let error): + XCTAssertNil(error) } } XCTAssertNotNil(task) @@ -36,7 +36,7 @@ class IssueTests: XCTestCase { // MARK: Model Tests func testParsingIssue() { - let subject = Issue(Helper.JSONFromFile("issue") as! [String: AnyObject]) + let subject = Helper.codableFromFile("issue", type: Issue.self) XCTAssertEqual(subject.user?.login, "octocat") XCTAssertEqual(subject.user?.id, 1) From 353f0e324e7cee007cbb730c5e5bc103573f9fd7 Mon Sep 17 00:00:00 2001 From: Piet Brauer Date: Thu, 30 Nov 2017 18:28:36 +0100 Subject: [PATCH 119/302] Update PullRequests to Swift 4 --- OctoKit/PullRequest.swift | 97 ++++++++++------------------- OctoKitTests/PullRequestTests.swift | 8 +-- 2 files changed, 37 insertions(+), 68 deletions(-) diff --git a/OctoKit/PullRequest.swift b/OctoKit/PullRequest.swift index 69b0c3d3..b3e325e8 100644 --- a/OctoKit/PullRequest.swift +++ b/OctoKit/PullRequest.swift @@ -1,9 +1,9 @@ import Foundation import RequestKit -@objc open class PullRequest: NSObject { +@objc open class PullRequest: NSObject, Codable { - @objc open var id: Int + @objc private(set) open var id: Int = -1 @objc open var url: URL? @objc open var htmlURL: URL? @@ -25,61 +25,34 @@ import RequestKit @objc open var milestone: Milestone? open var locked: Bool? - @objc open var createdAt: Date? - @objc open var updatedAt: Date? - @objc open var closedAt: Date? - @objc open var mergedAt: Date? + @objc open var createdAt: String? + @objc open var updatedAt: String? + @objc open var closedAt: String? + @objc open var mergedAt: String? @objc open var user: User? - @objc public init(_ json: [String: AnyObject]) { - if let id = json["id"] as? Int { - self.id = id - - if let urlString = json["url"] as? String, let url = URL(string: urlString) { - self.url = url - } - if let diffURL = json["diff_url"] as? String, let url = URL(string: diffURL) { - self.diffURL = url - } - if let patchURL = json["patch_url"] as? String, let url = URL(string: patchURL) { - self.patchURL = url - } - if let issueURL = json["issue_url"] as? String, let url = URL(string: issueURL) { - self.patchURL = url - } - if let commitsURL = json["commits_url"] as? String, let url = URL(string: commitsURL) { - self.commitsURL = url - } - if let reviewCommentsURL = json["review_comments_url"] as? String, - let url = URL(string: reviewCommentsURL) { - self.reviewCommentsURL = url - } - if let reviewCommentURL = json["review_comment_url"] as? String, let url = URL(string: reviewCommentURL) { - self.reviewCommentURL = url - } - if let commentsURL = json["comments_url"] as? String, let url = URL(string: commentsURL) { - self.commentsURL = url - } - if let statusesURL = json["statuses_url"] as? String, let url = URL(string: statusesURL) { - self.statusesURL = url - } - number = json["number"] as? Int - state = Openness(rawValue: json["state"] as? String ?? "") - title = json["title"] as? String - body = json["body"] as? String - -// assignee = User(json["assignee"] as? [String: AnyObject] ?? [:]) -// milestone = Milestone(json["milestone"] as? [String: AnyObject] ?? [:]) - - locked = json["locked"] as? Bool -// closedAt = Time.rfc3339Date(json["closed_at"] as? String) -// createdAt = Time.rfc3339Date(json["created_at"] as? String) -// updatedAt = Time.rfc3339Date(json["updated_at"] as? String) -// mergedAt = Time.rfc3339Date(json["merged_at"] as? String) - } else { - id = -1 - } + enum CodingKeys: String, CodingKey { + case id + case url + case diffURL = "diff_url" + case patchURL = "patch_url" + case issueURL = "issue_url" + case commitsURL = "commits_url" + case reviewCommentsURL = "review_comments_url" + case commentsURL = "comments_url" + case statusesURL = "statuses_url" + case number + case state + case title + case body + case assignee + case milestone + case locked + case closedAt = "closed_at" + case createdAt = "created_at" + case updatedAt = "updated_at" + case mergedAt = "merged_at" } } @@ -102,13 +75,12 @@ public extension Octokit { completion: @escaping (_ response: Response) -> Void) -> URLSessionDataTaskProtocol? { let router = PullRequestRouter.readPullRequest(configuration, owner, repository, "\(number)") - return router.loadJSON(session, expectedResultType: [String: AnyObject].self) { json, error in + return router.load(session, expectedResultType: PullRequest.self) { pullRequest, error in if let error = error { completion(Response.failure(error)) } else { - if let json = json { - let parsedPullRequest = PullRequest(json) - completion(Response.success(parsedPullRequest)) + if let pullRequest = pullRequest { + completion(Response.success(pullRequest)) } } } @@ -134,15 +106,12 @@ public extension Octokit { completion: @escaping (_ response: Response<[PullRequest]>) -> Void) -> URLSessionDataTaskProtocol? { let router = PullRequestRouter.readPullRequests(configuration, owner, repository, base, state, sort, direction) - return router.loadJSON(session, expectedResultType: [[String: AnyObject]].self) { json, error in + return router.load(session, expectedResultType: [PullRequest].self) { pullRequests, error in if let error = error { completion(Response.failure(error)) } else { - if let json = json { - let parsedPullRequest = json.map { - PullRequest($0) - } - completion(Response.success(parsedPullRequest)) + if let pullRequests = pullRequests { + completion(Response.success(pullRequests)) } } } diff --git a/OctoKitTests/PullRequestTests.swift b/OctoKitTests/PullRequestTests.swift index 1a961b31..58f6c1b0 100644 --- a/OctoKitTests/PullRequestTests.swift +++ b/OctoKitTests/PullRequestTests.swift @@ -16,8 +16,8 @@ class PullRequeastTests: XCTestCase { XCTAssertEqual(pullRequests.id, 1) XCTAssertEqual(pullRequests.title, "new-feature") XCTAssertEqual(pullRequests.body, "Please pull these awesome changes") - case .failure: - XCTAssert(false, "should not get an error") + case .failure(let error): + XCTAssertNil(error) } } XCTAssertNotNil(task) @@ -37,8 +37,8 @@ class PullRequeastTests: XCTestCase { XCTAssertEqual(pullRequests.count, 1) XCTAssertEqual(pullRequests.first?.title, "new-feature") XCTAssertEqual(pullRequests.first?.body, "Please pull these awesome changes") - case .failure: - XCTAssert(false, "should not get an error") + case .failure(let error): + XCTAssertNil(error) } } XCTAssertNotNil(task) From 1c3313f0b4d74775a779afb85c2375100630a07a Mon Sep 17 00:00:00 2001 From: Piet Brauer Date: Thu, 30 Nov 2017 18:40:22 +0100 Subject: [PATCH 120/302] Remove local RequestKit --- Cartfile | 2 +- Cartfile.resolved | 2 +- OctoKit.xcodeproj/project.pbxproj | 199 +++--------------------------- 3 files changed, 18 insertions(+), 185 deletions(-) diff --git a/Cartfile b/Cartfile index d1915c36..563ce06f 100644 --- a/Cartfile +++ b/Cartfile @@ -1 +1 @@ -github "nerdishbynature/RequestKit" ~>2.0 +github "nerdishbynature/RequestKit" "swift-4" diff --git a/Cartfile.resolved b/Cartfile.resolved index 7b711263..6e8b6025 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1 +1 @@ -github "nerdishbynature/RequestKit" "2.0.2" +github "nerdishbynature/RequestKit" "dc8c8170ed37618d1f2c693195c119e9aa0b205e" diff --git a/OctoKit.xcodeproj/project.pbxproj b/OctoKit.xcodeproj/project.pbxproj index 4403b709..4b6fbe0e 100644 --- a/OctoKit.xcodeproj/project.pbxproj +++ b/OctoKit.xcodeproj/project.pbxproj @@ -7,6 +7,10 @@ objects = { /* Begin PBXBuildFile section */ + 230B589C1FD079C7000FE68A /* RequestKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 230B589B1FD079C7000FE68A /* RequestKit.framework */; }; + 230B589E1FD079D5000FE68A /* RequestKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 230B589D1FD079D5000FE68A /* RequestKit.framework */; }; + 230B58A01FD079E2000FE68A /* RequestKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 230B589F1FD079E2000FE68A /* RequestKit.framework */; }; + 230B58A21FD079ED000FE68A /* RequestKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 230B58A11FD079ED000FE68A /* RequestKit.framework */; }; 234F4BAE1BDDE31A00A58EF7 /* OctoKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 239BE7C91B8C47A100D2CE22 /* OctoKit.framework */; }; 234F4BD01BDDE3F900A58EF7 /* ConfigurationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 234F4BC91BDDE3F900A58EF7 /* ConfigurationTests.swift */; }; 234F4BD21BDDE3F900A58EF7 /* OctokitSwiftTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 234F4BCB1BDDE3F900A58EF7 /* OctokitSwiftTests.swift */; }; @@ -89,10 +93,6 @@ 23F6434F1C7AEF70000427B3 /* user_repos.json in Resources */ = {isa = PBXBuildFile; fileRef = 234F4BDC1BDDE44600A58EF7 /* user_repos.json */; }; 23F643501C7AEF72000427B3 /* users.json in Resources */ = {isa = PBXBuildFile; fileRef = E7EE59DF1BE139FD0012E3D2 /* users.json */; }; 23F643511C7AEF73000427B3 /* users.json in Resources */ = {isa = PBXBuildFile; fileRef = E7EE59DF1BE139FD0012E3D2 /* users.json */; }; - 66C0632A1FCD95CE00920667 /* RequestKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 66C0631D1FCD95C200920667 /* RequestKit.framework */; }; - 66C0632B1FCD95D200920667 /* RequestKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 66C063211FCD95C200920667 /* RequestKit.framework */; }; - 66C0632C1FCD95D900920667 /* RequestKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 66C063271FCD95C200920667 /* RequestKit.framework */; }; - 66C0632D1FCD95E000920667 /* RequestKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 66C063251FCD95C200920667 /* RequestKit.framework */; }; BF8C711C2C6B42F9F323FCFE /* pull_requests.json in Resources */ = {isa = PBXBuildFile; fileRef = BF8C79B71035B425F7748392 /* pull_requests.json */; }; BF8C716EB8D5CA2CBBA745CB /* pull_request.json in Resources */ = {isa = PBXBuildFile; fileRef = BF8C77314F563A710F11E2F6 /* pull_request.json */; }; BF8C719220F02AC04EF3D137 /* PullRequestTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF8C76EB002802C14A08F63E /* PullRequestTests.swift */; }; @@ -161,83 +161,6 @@ remoteGlobalIDString = 23CAF27D1C7AB60C005011C4; remoteInfo = "OctoKit Mac"; }; - 66C0631C1FCD95C200920667 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 66C063121FCD95C200920667 /* RequestKit.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 234F4C1C1BDDF64300A58EF7; - remoteInfo = RequestKit; - }; - 66C0631E1FCD95C200920667 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 66C063121FCD95C200920667 /* RequestKit.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 234F4C261BDDF64300A58EF7; - remoteInfo = RequestKitTests; - }; - 66C063201FCD95C200920667 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 66C063121FCD95C200920667 /* RequestKit.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 233743001C7981A800013492; - remoteInfo = "RequestKit tvOS"; - }; - 66C063221FCD95C200920667 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 66C063121FCD95C200920667 /* RequestKit.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 2337434D1C79833A00013492; - remoteInfo = "RequestKit tvTests"; - }; - 66C063241FCD95C200920667 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 66C063121FCD95C200920667 /* RequestKit.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 2337430D1C7981D700013492; - remoteInfo = "RequestKit watchOS"; - }; - 66C063261FCD95C200920667 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 66C063121FCD95C200920667 /* RequestKit.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 2337431A1C7981E700013492; - remoteInfo = "RequestKit Mac"; - }; - 66C063281FCD95C200920667 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 66C063121FCD95C200920667 /* RequestKit.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 2337433E1C79832700013492; - remoteInfo = "RequestKit MacTests"; - }; - 66C0632E1FCD95E700920667 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 66C063121FCD95C200920667 /* RequestKit.xcodeproj */; - proxyType = 1; - remoteGlobalIDString = 234F4C1B1BDDF64300A58EF7; - remoteInfo = RequestKit; - }; - 66C063301FCD95EB00920667 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 66C063121FCD95C200920667 /* RequestKit.xcodeproj */; - proxyType = 1; - remoteGlobalIDString = 233742FF1C7981A800013492; - remoteInfo = "RequestKit tvOS"; - }; - 66C063321FCD95EF00920667 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 66C063121FCD95C200920667 /* RequestKit.xcodeproj */; - proxyType = 1; - remoteGlobalIDString = 233743191C7981E700013492; - remoteInfo = "RequestKit Mac"; - }; - 66C063341FCD95F500920667 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 66C063121FCD95C200920667 /* RequestKit.xcodeproj */; - proxyType = 1; - remoteGlobalIDString = 2337430C1C7981D700013492; - remoteInfo = "RequestKit watchOS"; - }; /* End PBXContainerItemProxy section */ /* Begin PBXCopyFilesBuildPhase section */ @@ -274,6 +197,10 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 230B589B1FD079C7000FE68A /* RequestKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = RequestKit.framework; path = Carthage/Build/iOS/RequestKit.framework; sourceTree = ""; }; + 230B589D1FD079D5000FE68A /* RequestKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = RequestKit.framework; path = Carthage/Build/tvOS/RequestKit.framework; sourceTree = ""; }; + 230B589F1FD079E2000FE68A /* RequestKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = RequestKit.framework; path = Carthage/Build/Mac/RequestKit.framework; sourceTree = ""; }; + 230B58A11FD079ED000FE68A /* RequestKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = RequestKit.framework; path = Carthage/Build/watchOS/RequestKit.framework; sourceTree = ""; }; 234F4BA91BDDE31A00A58EF7 /* OctoKitTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = OctoKitTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 234F4BAD1BDDE31A00A58EF7 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 234F4BC91BDDE3F900A58EF7 /* ConfigurationTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConfigurationTests.swift; sourceTree = ""; }; @@ -305,7 +232,6 @@ 23CAF29A1C7AB619005011C4 /* OctoKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = OctoKit.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 23F6433C1C7AEEB6000427B3 /* Nocilla.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Nocilla.framework; path = Carthage/Build/tvOS/Nocilla.framework; sourceTree = ""; }; 23F643421C7AEF2F000427B3 /* Nocilla.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Nocilla.framework; path = Carthage/Build/Mac/Nocilla.framework; sourceTree = ""; }; - 66C063121FCD95C200920667 /* RequestKit.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RequestKit.xcodeproj; path = ../RequestKit/RequestKit.xcodeproj; sourceTree = ""; }; BF8C72B985869B84F46B4E9D /* Parameters.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Parameters.swift; sourceTree = ""; }; BF8C73E0EF3CEEBDEA68DD5E /* PullRequest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PullRequest.swift; sourceTree = ""; }; BF8C76EB002802C14A08F63E /* PullRequestTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PullRequestTests.swift; sourceTree = ""; }; @@ -338,7 +264,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 66C0632A1FCD95CE00920667 /* RequestKit.framework in Frameworks */, + 230B589C1FD079C7000FE68A /* RequestKit.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -346,7 +272,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 66C0632B1FCD95D200920667 /* RequestKit.framework in Frameworks */, + 230B589E1FD079D5000FE68A /* RequestKit.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -362,7 +288,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 66C0632C1FCD95D900920667 /* RequestKit.framework in Frameworks */, + 230B58A01FD079E2000FE68A /* RequestKit.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -378,7 +304,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 66C0632D1FCD95E000920667 /* RequestKit.framework in Frameworks */, + 230B58A21FD079ED000FE68A /* RequestKit.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -453,24 +379,13 @@ name = "Supporting Files"; sourceTree = ""; }; - 66C063131FCD95C200920667 /* Products */ = { - isa = PBXGroup; - children = ( - 66C0631D1FCD95C200920667 /* RequestKit.framework */, - 66C0631F1FCD95C200920667 /* RequestKitTests.xctest */, - 66C063211FCD95C200920667 /* RequestKit.framework */, - 66C063231FCD95C200920667 /* RequestKit tvTests.xctest */, - 66C063251FCD95C200920667 /* RequestKit.framework */, - 66C063271FCD95C200920667 /* RequestKit.framework */, - 66C063291FCD95C200920667 /* RequestKit MacTests.xctest */, - ); - name = Products; - sourceTree = ""; - }; B975D5A3F8B0384EFB0C5863 /* Frameworks */ = { isa = PBXGroup; children = ( - 66C063121FCD95C200920667 /* RequestKit.xcodeproj */, + 230B589B1FD079C7000FE68A /* RequestKit.framework */, + 230B589D1FD079D5000FE68A /* RequestKit.framework */, + 230B589F1FD079E2000FE68A /* RequestKit.framework */, + 230B58A11FD079ED000FE68A /* RequestKit.framework */, 23F643421C7AEF2F000427B3 /* Nocilla.framework */, 23F6433C1C7AEEB6000427B3 /* Nocilla.framework */, 23B2679C1BDDDBBE003887E3 /* Nocilla.framework */, @@ -571,7 +486,6 @@ buildRules = ( ); dependencies = ( - 66C0632F1FCD95E700920667 /* PBXTargetDependency */, ); name = OctoKit; productName = OctoKit; @@ -590,7 +504,6 @@ buildRules = ( ); dependencies = ( - 66C063311FCD95EB00920667 /* PBXTargetDependency */, ); name = "OctoKit tvOS"; productName = "OctoKit tvOS"; @@ -628,7 +541,6 @@ buildRules = ( ); dependencies = ( - 66C063331FCD95EF00920667 /* PBXTargetDependency */, ); name = "OctoKit Mac"; productName = "OctoKit Mac"; @@ -666,7 +578,6 @@ buildRules = ( ); dependencies = ( - 66C063351FCD95F500920667 /* PBXTargetDependency */, ); name = "OctoKit watchOS"; productName = "OctoKit watchOS"; @@ -724,12 +635,6 @@ mainGroup = F01C6F2B1A6429CC0072FA44; productRefGroup = F01C6F351A6429CC0072FA44 /* Products */; projectDirPath = ""; - projectReferences = ( - { - ProductGroup = 66C063131FCD95C200920667 /* Products */; - ProjectRef = 66C063121FCD95C200920667 /* RequestKit.xcodeproj */; - }, - ); projectRoot = ""; targets = ( 239BE7C81B8C47A100D2CE22 /* OctoKit */, @@ -743,58 +648,6 @@ }; /* End PBXProject section */ -/* Begin PBXReferenceProxy section */ - 66C0631D1FCD95C200920667 /* RequestKit.framework */ = { - isa = PBXReferenceProxy; - fileType = wrapper.framework; - path = RequestKit.framework; - remoteRef = 66C0631C1FCD95C200920667 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 66C0631F1FCD95C200920667 /* RequestKitTests.xctest */ = { - isa = PBXReferenceProxy; - fileType = wrapper.cfbundle; - path = RequestKitTests.xctest; - remoteRef = 66C0631E1FCD95C200920667 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 66C063211FCD95C200920667 /* RequestKit.framework */ = { - isa = PBXReferenceProxy; - fileType = wrapper.framework; - path = RequestKit.framework; - remoteRef = 66C063201FCD95C200920667 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 66C063231FCD95C200920667 /* RequestKit tvTests.xctest */ = { - isa = PBXReferenceProxy; - fileType = wrapper.cfbundle; - path = "RequestKit tvTests.xctest"; - remoteRef = 66C063221FCD95C200920667 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 66C063251FCD95C200920667 /* RequestKit.framework */ = { - isa = PBXReferenceProxy; - fileType = wrapper.framework; - path = RequestKit.framework; - remoteRef = 66C063241FCD95C200920667 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 66C063271FCD95C200920667 /* RequestKit.framework */ = { - isa = PBXReferenceProxy; - fileType = wrapper.framework; - path = RequestKit.framework; - remoteRef = 66C063261FCD95C200920667 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 66C063291FCD95C200920667 /* RequestKit MacTests.xctest */ = { - isa = PBXReferenceProxy; - fileType = wrapper.cfbundle; - path = "RequestKit MacTests.xctest"; - remoteRef = 66C063281FCD95C200920667 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; -/* End PBXReferenceProxy section */ - /* Begin PBXResourcesBuildPhase section */ 234F4BA71BDDE31A00A58EF7 /* Resources */ = { isa = PBXResourcesBuildPhase; @@ -1034,26 +887,6 @@ target = 23CAF27D1C7AB60C005011C4 /* OctoKit Mac */; targetProxy = 23CAF2891C7AB60D005011C4 /* PBXContainerItemProxy */; }; - 66C0632F1FCD95E700920667 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - name = RequestKit; - targetProxy = 66C0632E1FCD95E700920667 /* PBXContainerItemProxy */; - }; - 66C063311FCD95EB00920667 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - name = "RequestKit tvOS"; - targetProxy = 66C063301FCD95EB00920667 /* PBXContainerItemProxy */; - }; - 66C063331FCD95EF00920667 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - name = "RequestKit Mac"; - targetProxy = 66C063321FCD95EF00920667 /* PBXContainerItemProxy */; - }; - 66C063351FCD95F500920667 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - name = "RequestKit watchOS"; - targetProxy = 66C063341FCD95F500920667 /* PBXContainerItemProxy */; - }; /* End PBXTargetDependency section */ /* Begin XCBuildConfiguration section */ From 07377220bdb18f2439d4eeb7e1c43745f619a32d Mon Sep 17 00:00:00 2001 From: Piet Brauer Date: Wed, 6 Dec 2017 17:09:57 +0100 Subject: [PATCH 121/302] Use `load` --- OctoKit/Stars.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OctoKit/Stars.swift b/OctoKit/Stars.swift index 88adcf80..cfa444fa 100644 --- a/OctoKit/Stars.swift +++ b/OctoKit/Stars.swift @@ -29,7 +29,7 @@ public extension Octokit { */ public func myStars(_ session: RequestKitURLSession = URLSession.shared, completion: @escaping (_ response: Response<[Repository]>) -> Void) -> URLSessionDataTaskProtocol? { let router = StarsRouter.readAuthenticatedStars(configuration) - return router.loadJSON(session, expectedResultType: [Repository].self) { repos, error in + return router.load(session, expectedResultType: [Repository].self) { repos, error in if let error = error { completion(Response.failure(error)) } else { From f99fcd5cb992732376b32f00cad10404b56f75d3 Mon Sep 17 00:00:00 2001 From: Piet Brauer Date: Wed, 6 Dec 2017 17:16:14 +0100 Subject: [PATCH 122/302] Update RequestKit --- Cartfile.resolved | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cartfile.resolved b/Cartfile.resolved index 6e8b6025..7c15b769 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1 +1 @@ -github "nerdishbynature/RequestKit" "dc8c8170ed37618d1f2c693195c119e9aa0b205e" +github "nerdishbynature/RequestKit" "c706faace4f88b4253990f86e8f560f822ef957f" From f5c80cfc26e2f6977cd000a2b28a14103d5382b9 Mon Sep 17 00:00:00 2001 From: Piet Brauer Date: Wed, 6 Dec 2017 17:16:29 +0100 Subject: [PATCH 123/302] Update to Xcode 9.2 --- .travis.yml | 10 +-- Gemfile.lock | 126 +++++++++++++++--------------- OctoKit.xcodeproj/project.pbxproj | 56 +++++++------ fastlane/.env.default | 6 +- fastlane/.env.ios93 | 2 +- fastlane/.env.tvos92 | 2 +- 6 files changed, 109 insertions(+), 93 deletions(-) diff --git a/.travis.yml b/.travis.yml index 36fb3f89..8e4fa4c6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ language: objective-c -osx_image: xcode8.3 +osx_image: xcode9.2 sudo: false env: global: @@ -8,13 +8,13 @@ env: - FASTLANE_LANE=ci_commit matrix: include: - - osx_image: xcode8.3 + - osx_image: xcode9.2 env: FASTLANE_LANE=code_coverage FASTLANE_ENV=default - - osx_image: xcode8.3 + - osx_image: xcode9.2 env: FASTLANE_ENV=ios93 - - osx_image: xcode8.3 + - osx_image: xcode9.2 env: FASTLANE_ENV=tvos92 - - osx_image: xcode8.3 + - osx_image: xcode9.2 env: FASTLANE_ENV=osx before_install: - make install diff --git a/Gemfile.lock b/Gemfile.lock index 17664523..66a31bbd 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,16 +1,16 @@ GEM remote: https://rubygems.org/ specs: - CFPropertyList (2.3.5) - activesupport (4.2.8) + CFPropertyList (2.3.6) + activesupport (4.2.10) i18n (~> 0.7) minitest (~> 5.1) thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) - addressable (2.5.1) - public_suffix (~> 2.0, >= 2.0.2) + addressable (2.5.2) + public_suffix (>= 2.0.2, < 4.0) babosa (1.0.2) - claide (1.0.1) + claide (1.0.2) clamp (0.6.5) cocoapods (1.1.1) activesupport (>= 4.0.2, < 5) @@ -45,36 +45,40 @@ GEM netrc (= 0.7.8) cocoapods-try (1.1.0) colored (1.2) - commander-fastlane (4.4.4) + colored2 (3.1.2) + commander-fastlane (4.4.5) highline (~> 1.7.2) - domain_name (0.5.20170223) + concurrent-ruby (1.0.5) + declarative (0.0.10) + declarative-option (0.1.0) + domain_name (0.5.20170404) unf (>= 0.0.5, < 1.0.0) - dotenv (2.2.0) + dotenv (2.2.1) escape (0.0.4) - excon (0.55.0) - faraday (0.11.0) + excon (0.60.0) + faraday (0.13.1) multipart-post (>= 1.2, < 3) faraday-cookie_jar (0.0.6) faraday (>= 0.7.4) http-cookie (~> 1.0.0) - faraday_middleware (0.11.0.1) + faraday_middleware (0.12.2) faraday (>= 0.7.4, < 1.0) - fastimage (2.1.0) - fastlane (2.24.0) - activesupport (< 5) + fastimage (2.1.1) + fastlane (2.70.3) + CFPropertyList (>= 2.3, < 3.0.0) addressable (>= 2.3, < 3.0.0) babosa (>= 1.0.2, < 2.0.0) bundler (>= 1.12.0, < 2.0.0) colored - commander-fastlane (>= 4.4.0, < 5.0.0) + commander-fastlane (>= 4.4.5, < 5.0.0) dotenv (>= 2.1.1, < 3.0.0) excon (>= 0.45.0, < 1.0.0) faraday (~> 0.9) faraday-cookie_jar (~> 0.0.6) faraday_middleware (~> 0.9) - fastimage (>= 1.6) + fastimage (>= 2.1.0, < 3.0.0) gh_inspector (>= 1.0.1, < 2.0.0) - google-api-client (~> 0.9.2) + google-api-client (>= 0.13.1, < 0.14.0) highline (>= 1.7.2, < 2.0.0) json (< 3.0.0) mini_magick (~> 4.5.1) @@ -82,57 +86,56 @@ GEM multi_xml (~> 0.5) multipart-post (~> 2.0.0) plist (>= 3.1.0, < 4.0.0) + public_suffix (~> 2.0.0) rubyzip (>= 1.1.0, < 2.0.0) security (= 0.1.3) slack-notifier (>= 1.3, < 2.0.0) terminal-notifier (>= 1.6.2, < 2.0.0) terminal-table (>= 1.4.5, < 2.0.0) - tty-screen (~> 0.5.0) + tty-screen (~> 0.6.3) word_wrap (~> 1.0.0) - xcodeproj (>= 0.20, < 2.0.0) + xcodeproj (>= 1.5.2, < 2.0.0) xcpretty (>= 0.2.4, < 1.0.0) xcpretty-travis-formatter (>= 0.0.3) fourflusher (2.0.1) fuzzy_match (2.0.4) gh_inspector (1.0.3) - google-api-client (0.9.28) - addressable (~> 2.3) + google-api-client (0.13.6) + addressable (~> 2.5, >= 2.5.1) googleauth (~> 0.5) - httpclient (~> 2.7) - hurley (~> 0.1) - memoist (~> 0.11) - mime-types (>= 1.6) - representable (~> 2.3.0) - retriable (~> 2.0) - googleauth (0.5.1) - faraday (~> 0.9) - jwt (~> 1.4) + httpclient (>= 2.8.1, < 3.0) + mime-types (~> 3.0) + representable (~> 3.0) + retriable (>= 2.0, < 4.0) + googleauth (0.6.2) + faraday (~> 0.12) + jwt (>= 1.4, < 3.0) logging (~> 2.0) memoist (~> 0.12) multi_json (~> 1.11) os (~> 0.9) signet (~> 0.7) - highline (1.7.8) + highline (1.7.10) http-cookie (1.0.3) domain_name (~> 0.5) httpclient (2.8.3) - hurley (0.2) - i18n (0.8.1) - json (2.0.3) + i18n (0.9.1) + concurrent-ruby (~> 1.0) + json (2.1.0) jwt (1.5.6) little-plugger (1.1.4) - logging (2.2.0) + logging (2.2.2) little-plugger (~> 1.1) multi_json (~> 1.10) - memoist (0.15.0) + memoist (0.16.0) mime-types (3.1) mime-types-data (~> 3.2015) mime-types-data (3.2016.0521) mini_magick (4.5.1) mini_portile2 (2.1.0) - minitest (5.10.1) + minitest (5.10.3) molinillo (0.5.5) - multi_json (1.12.1) + multi_json (1.12.2) multi_xml (0.6.0) multipart-post (2.0.0) nanaimo (0.2.3) @@ -141,18 +144,20 @@ GEM nokogiri (1.6.8.1) mini_portile2 (~> 2.1.0) os (0.9.6) - plist (3.2.0) + plist (3.4.0) public_suffix (2.0.5) - representable (2.3.0) - uber (~> 0.0.7) - retriable (2.1.0) - rouge (1.11.1) + representable (3.0.4) + declarative (< 0.1.0) + declarative-option (< 0.2.0) + uber (< 0.2.0) + retriable (3.1.1) + rouge (2.0.7) rubyzip (1.2.1) security (0.1.3) - signet (0.7.3) + signet (0.8.1) addressable (~> 2.3) faraday (~> 0.9) - jwt (~> 1.5) + jwt (>= 1.5, < 3.0) multi_json (~> 1.10) slack-notifier (1.5.1) slather (2.3.0) @@ -160,28 +165,27 @@ GEM clamp (~> 0.6) nokogiri (~> 1.6.3) xcodeproj (>= 0.20, < 2.0.0) - terminal-notifier (1.7.1) - terminal-table (1.7.3) - unicode-display_width (~> 1.1.1) + terminal-notifier (1.8.0) + terminal-table (1.8.0) + unicode-display_width (~> 1.1, >= 1.1.1) thread_safe (0.3.6) - tty-screen (0.5.0) - tzinfo (1.2.3) + tty-screen (0.6.3) + tzinfo (1.2.4) thread_safe (~> 0.1) - uber (0.0.15) + uber (0.1.0) unf (0.1.4) unf_ext - unf_ext (0.0.7.2) - unicode-display_width (1.1.3) + unf_ext (0.0.7.4) + unicode-display_width (1.3.0) word_wrap (1.0.0) - xcodeproj (1.4.2) + xcodeproj (1.5.4) CFPropertyList (~> 2.3.3) - activesupport (>= 3) - claide (>= 1.0.1, < 2.0) - colored (~> 1.2) + claide (>= 1.0.2, < 2.0) + colored2 (~> 3.1) nanaimo (~> 0.2.3) - xcpretty (0.2.4) - rouge (~> 1.8) - xcpretty-travis-formatter (0.0.4) + xcpretty (0.2.8) + rouge (~> 2.0.7) + xcpretty-travis-formatter (1.0.0) xcpretty (~> 0.2, >= 0.0.7) PLATFORMS @@ -193,4 +197,4 @@ DEPENDENCIES slather (~> 2.0) BUNDLED WITH - 1.13.6 + 1.16.0 diff --git a/OctoKit.xcodeproj/project.pbxproj b/OctoKit.xcodeproj/project.pbxproj index 4b6fbe0e..4b1fab71 100644 --- a/OctoKit.xcodeproj/project.pbxproj +++ b/OctoKit.xcodeproj/project.pbxproj @@ -11,6 +11,9 @@ 230B589E1FD079D5000FE68A /* RequestKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 230B589D1FD079D5000FE68A /* RequestKit.framework */; }; 230B58A01FD079E2000FE68A /* RequestKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 230B589F1FD079E2000FE68A /* RequestKit.framework */; }; 230B58A21FD079ED000FE68A /* RequestKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 230B58A11FD079ED000FE68A /* RequestKit.framework */; }; + 2343596F1FED332300DEA02A /* OctoKit.framework in Carthage embed */ = {isa = PBXBuildFile; fileRef = 23CAF2621C7AB5FB005011C4 /* OctoKit.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + 234359701FED338900DEA02A /* OctoKit.framework in Carthage embed */ = {isa = PBXBuildFile; fileRef = 239BE7C91B8C47A100D2CE22 /* OctoKit.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + 234359711FED339300DEA02A /* OctoKit.framework in Carthage embed */ = {isa = PBXBuildFile; fileRef = 23CAF27E1C7AB60C005011C4 /* OctoKit.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 234F4BAE1BDDE31A00A58EF7 /* OctoKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 239BE7C91B8C47A100D2CE22 /* OctoKit.framework */; }; 234F4BD01BDDE3F900A58EF7 /* ConfigurationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 234F4BC91BDDE3F900A58EF7 /* ConfigurationTests.swift */; }; 234F4BD21BDDE3F900A58EF7 /* OctokitSwiftTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 234F4BCB1BDDE3F900A58EF7 /* OctokitSwiftTests.swift */; }; @@ -170,6 +173,7 @@ dstPath = ""; dstSubfolderSpec = 10; files = ( + 234359701FED338900DEA02A /* OctoKit.framework in Carthage embed */, ); name = "Carthage embed"; runOnlyForDeploymentPostprocessing = 0; @@ -180,6 +184,7 @@ dstPath = ""; dstSubfolderSpec = 10; files = ( + 2343596F1FED332300DEA02A /* OctoKit.framework in Carthage embed */, ); name = "Carthage embed"; runOnlyForDeploymentPostprocessing = 0; @@ -190,6 +195,7 @@ dstPath = ""; dstSubfolderSpec = 10; files = ( + 234359711FED339300DEA02A /* OctoKit.framework in Carthage embed */, ); name = "Carthage embed"; runOnlyForDeploymentPostprocessing = 0; @@ -598,6 +604,7 @@ 234F4BA81BDDE31A00A58EF7 = { CreatedOnToolsVersion = 7.1; LastSwiftMigration = 0910; + ProvisioningStyle = Manual; }; 239BE7C81B8C47A100D2CE22 = { CreatedOnToolsVersion = 6.4; @@ -610,6 +617,7 @@ }; 23CAF26A1C7AB5FC005011C4 = { CreatedOnToolsVersion = 7.2.1; + ProvisioningStyle = Manual; }; 23CAF27D1C7AB60C005011C4 = { CreatedOnToolsVersion = 7.2.1; @@ -893,17 +901,19 @@ 234F4BB21BDDE31A00A58EF7 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + CODE_SIGN_STYLE = Manual; DEBUG_INFORMATION_FORMAT = dwarf; + DEVELOPMENT_TEAM = ""; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/Carthage/Build/iOS", ); GCC_NO_COMMON_BLOCKS = YES; INFOPLIST_FILE = OctoKitTests/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 9.1; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks $(FRAMEWORK_SEARCH_PATHS)"; PRODUCT_BUNDLE_IDENTIFIER = com.nerdishbynature.OctoKitTests; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_VERSION = 4.0; }; name = Debug; @@ -911,18 +921,20 @@ 234F4BB31BDDE31A00A58EF7 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + CODE_SIGN_STYLE = Manual; COPY_PHASE_STRIP = NO; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + DEVELOPMENT_TEAM = ""; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/Carthage/Build/iOS", ); GCC_NO_COMMON_BLOCKS = YES; INFOPLIST_FILE = OctoKitTests/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 9.1; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks $(FRAMEWORK_SEARCH_PATHS)"; PRODUCT_BUNDLE_IDENTIFIER = com.nerdishbynature.OctoKitTests; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; SWIFT_VERSION = 4.0; }; @@ -949,7 +961,7 @@ "$(inherited)", ); INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 10.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; @@ -978,7 +990,7 @@ ); GCC_NO_COMMON_BLOCKS = YES; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 10.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; @@ -1009,7 +1021,6 @@ SDKROOT = appletvos; SKIP_INSTALL = YES; TARGETED_DEVICE_FAMILY = 3; - TVOS_DEPLOYMENT_TARGET = 9.0; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; }; @@ -1037,7 +1048,6 @@ SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; TARGETED_DEVICE_FAMILY = 3; - TVOS_DEPLOYMENT_TARGET = 9.0; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; }; @@ -1046,38 +1056,42 @@ 23CAF2751C7AB5FC005011C4 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + CODE_SIGN_STYLE = Manual; DEBUG_INFORMATION_FORMAT = dwarf; + DEVELOPMENT_TEAM = ""; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/Carthage/Build/tvOS", ); GCC_NO_COMMON_BLOCKS = YES; INFOPLIST_FILE = OctoKitTests/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks $(FRAMEWORK_SEARCH_PATHS)"; PRODUCT_BUNDLE_IDENTIFIER = "com.nerdishbynature.OctoKit-tvOSTests"; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; SDKROOT = appletvos; - TVOS_DEPLOYMENT_TARGET = 9.1; }; name = Debug; }; 23CAF2761C7AB5FC005011C4 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + CODE_SIGN_STYLE = Manual; COPY_PHASE_STRIP = NO; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + DEVELOPMENT_TEAM = ""; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/Carthage/Build/tvOS", ); GCC_NO_COMMON_BLOCKS = YES; INFOPLIST_FILE = OctoKitTests/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks $(FRAMEWORK_SEARCH_PATHS)"; PRODUCT_BUNDLE_IDENTIFIER = "com.nerdishbynature.OctoKit-tvOSTests"; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; SDKROOT = appletvos; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - TVOS_DEPLOYMENT_TARGET = 9.1; }; name = Release; }; @@ -1100,7 +1114,7 @@ GCC_NO_COMMON_BLOCKS = YES; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; - MACOSX_DEPLOYMENT_TARGET = 10.10; + MACOSX_DEPLOYMENT_TARGET = 10.12; SDKROOT = macosx; SKIP_INSTALL = YES; SWIFT_VERSION = 3.0; @@ -1129,7 +1143,7 @@ GCC_NO_COMMON_BLOCKS = YES; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; - MACOSX_DEPLOYMENT_TARGET = 10.10; + MACOSX_DEPLOYMENT_TARGET = 10.12; SDKROOT = macosx; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; @@ -1151,8 +1165,7 @@ ); GCC_NO_COMMON_BLOCKS = YES; INFOPLIST_FILE = OctoKitTests/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; - MACOSX_DEPLOYMENT_TARGET = 10.11; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks $(FRAMEWORK_SEARCH_PATHS)"; PRODUCT_BUNDLE_IDENTIFIER = "com.nerdishbynature.OctoKit-MacTests"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = macosx; @@ -1173,8 +1186,7 @@ ); GCC_NO_COMMON_BLOCKS = YES; INFOPLIST_FILE = OctoKitTests/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; - MACOSX_DEPLOYMENT_TARGET = 10.11; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks $(FRAMEWORK_SEARCH_PATHS)"; PRODUCT_BUNDLE_IDENTIFIER = "com.nerdishbynature.OctoKit-MacTests"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = macosx; @@ -1206,7 +1218,7 @@ TARGETED_DEVICE_FAMILY = 4; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; - WATCHOS_DEPLOYMENT_TARGET = 2.1; + WATCHOS_DEPLOYMENT_TARGET = 3.0; }; name = Debug; }; @@ -1235,7 +1247,7 @@ TARGETED_DEVICE_FAMILY = 4; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; - WATCHOS_DEPLOYMENT_TARGET = 2.1; + WATCHOS_DEPLOYMENT_TARGET = 3.0; }; name = Release; }; @@ -1284,7 +1296,7 @@ GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; INFOPLIST_FILE = OctoKit/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 8.1; + IPHONEOS_DEPLOYMENT_TARGET = 10.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; PRODUCT_BUNDLE_IDENTIFIER = com.nerdishbynature.OctoKit; @@ -1333,7 +1345,7 @@ GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; INFOPLIST_FILE = OctoKit/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 8.1; + IPHONEOS_DEPLOYMENT_TARGET = 10.0; MTL_ENABLE_DEBUG_INFO = NO; PRODUCT_BUNDLE_IDENTIFIER = com.nerdishbynature.OctoKit; PRODUCT_NAME = OctoKit; diff --git a/fastlane/.env.default b/fastlane/.env.default index 7374bf0d..72237e49 100644 --- a/fastlane/.env.default +++ b/fastlane/.env.default @@ -1,6 +1,6 @@ -AF_IOS_SDK=iphonesimulator10.3 -AF_MAC_SDK=macosx10.12 -AF_TVOS_SDK=appletvsimulator10.2 +AF_IOS_SDK=iphonesimulator11.2 +AF_MAC_SDK=macosx10.13 +AF_TVOS_SDK=appletvsimulator11.2 AF_CONFIGURATION=Release diff --git a/fastlane/.env.ios93 b/fastlane/.env.ios93 index f9fe2be3..ef3ef60e 100644 --- a/fastlane/.env.ios93 +++ b/fastlane/.env.ios93 @@ -1,3 +1,3 @@ SCAN_DEVICE="iPhone 6s" -SCAN_SDK=iphonesimulator10.3 +SCAN_SDK=iphonesimulator11.2 EXAMPLE_DESTINATION="platform=iOS Simulator,name=iPhone 6s" diff --git a/fastlane/.env.tvos92 b/fastlane/.env.tvos92 index 2b1cc591..2232fded 100644 --- a/fastlane/.env.tvos92 +++ b/fastlane/.env.tvos92 @@ -1,5 +1,5 @@ SCAN_SCHEME=$AF_TVOS_FRAMEWORK_SCHEME -SCAN_DEVICE="Apple TV 1080p" +SCAN_DEVICE="Apple TV" SCAN_SDK=$AF_TVOS_SDK EXAMPLE_SCHEME=$AF_TVOS_EXAMPLE_SCHEME From 21db568546c6beb83d939b5a4b68de5c1c86601a Mon Sep 17 00:00:00 2001 From: Piet Brauer Date: Fri, 22 Dec 2017 10:22:31 +0100 Subject: [PATCH 124/302] Use custom dateDecodingStrategy --- Cartfile.resolved | 2 +- OctoKit/Issue.swift | 12 ++++++------ OctoKit/Milestone.swift | 8 ++++---- OctoKit/PullRequest.swift | 12 ++++++------ OctoKit/Repositories.swift | 8 ++++---- OctoKit/Stars.swift | 4 ++-- OctoKit/Time.swift | 13 ++----------- OctoKitTests/TestHelper.swift | 5 ++++- 8 files changed, 29 insertions(+), 35 deletions(-) diff --git a/Cartfile.resolved b/Cartfile.resolved index 7c15b769..955a4e2c 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1 +1 @@ -github "nerdishbynature/RequestKit" "c706faace4f88b4253990f86e8f560f822ef957f" +github "nerdishbynature/RequestKit" "39c65fcbd4c505617fa78911b4d3a05d2bc8b057" diff --git a/OctoKit/Issue.swift b/OctoKit/Issue.swift index 143820e8..92ee68a3 100644 --- a/OctoKit/Issue.swift +++ b/OctoKit/Issue.swift @@ -27,9 +27,9 @@ public enum Openness: String, Codable { @objc open var milestone: Milestone? open var locked: Bool? open var comments: Int? - @objc open var closedAt: String? - @objc open var createdAt: String? - @objc open var updatedAt: String? + @objc open var closedAt: Date? + @objc open var createdAt: Date? + @objc open var updatedAt: Date? @objc open var closedBy: User? enum CodingKeys: String, CodingKey { @@ -71,7 +71,7 @@ public extension Octokit { */ public func myIssues(_ session: RequestKitURLSession = URLSession.shared, state: Openness = .Open, page: String = "1", perPage: String = "100", completion: @escaping (_ response: Response<[Issue]>) -> Void) -> URLSessionDataTaskProtocol? { let router = IssueRouter.readAuthenticatedIssues(configuration, page, perPage, state) - return router.load(session, expectedResultType: [Issue].self) { issues, error in + return router.load(session, dateDecodingStrategy: .formatted(Time.rfc3339DateFormatter), expectedResultType: [Issue].self) { issues, error in if let error = error { completion(Response.failure(error)) } else { @@ -92,7 +92,7 @@ public extension Octokit { */ public func issue(_ session: RequestKitURLSession = URLSession.shared, owner: String, repository: String, number: Int, completion: @escaping (_ response: Response) -> Void) -> URLSessionDataTaskProtocol? { let router = IssueRouter.readIssue(configuration, owner, repository, number) - return router.load(session, expectedResultType: Issue.self) { issue, error in + return router.load(session, dateDecodingStrategy: .formatted(Time.rfc3339DateFormatter), expectedResultType: Issue.self) { issue, error in if let error = error { completion(Response.failure(error)) } else { @@ -115,7 +115,7 @@ public extension Octokit { */ public func issues(_ session: RequestKitURLSession = URLSession.shared, owner: String, repository: String, state: Openness = .Open, page: String = "1", perPage: String = "100", completion: @escaping (_ response: Response<[Issue]>) -> Void) -> URLSessionDataTaskProtocol? { let router = IssueRouter.readIssues(configuration, owner, repository, page, perPage, state) - return router.load(session, expectedResultType: [Issue].self) { issues, error in + return router.load(session, dateDecodingStrategy: .formatted(Time.rfc3339DateFormatter), expectedResultType: [Issue].self) { issues, error in if let error = error { completion(Response.failure(error)) } else { diff --git a/OctoKit/Milestone.swift b/OctoKit/Milestone.swift index 5f52cabe..a1bb53c2 100644 --- a/OctoKit/Milestone.swift +++ b/OctoKit/Milestone.swift @@ -12,10 +12,10 @@ import Foundation @objc open var creator: User? open var openIssues: Int? open var closedIssues: Int? - @objc open var createdAt: String? - @objc open var updatedAt: String? - @objc open var closedAt: String? - @objc open var dueOn: String? + @objc open var createdAt: Date? + @objc open var updatedAt: Date? + @objc open var closedAt: Date? + @objc open var dueOn: Date? enum CodingKeys: String, CodingKey { case id diff --git a/OctoKit/PullRequest.swift b/OctoKit/PullRequest.swift index b3e325e8..0217253e 100644 --- a/OctoKit/PullRequest.swift +++ b/OctoKit/PullRequest.swift @@ -25,10 +25,10 @@ import RequestKit @objc open var milestone: Milestone? open var locked: Bool? - @objc open var createdAt: String? - @objc open var updatedAt: String? - @objc open var closedAt: String? - @objc open var mergedAt: String? + @objc open var createdAt: Date? + @objc open var updatedAt: Date? + @objc open var closedAt: Date? + @objc open var mergedAt: Date? @objc open var user: User? @@ -75,7 +75,7 @@ public extension Octokit { completion: @escaping (_ response: Response) -> Void) -> URLSessionDataTaskProtocol? { let router = PullRequestRouter.readPullRequest(configuration, owner, repository, "\(number)") - return router.load(session, expectedResultType: PullRequest.self) { pullRequest, error in + return router.load(session, dateDecodingStrategy: .formatted(Time.rfc3339DateFormatter), expectedResultType: PullRequest.self) { pullRequest, error in if let error = error { completion(Response.failure(error)) } else { @@ -106,7 +106,7 @@ public extension Octokit { completion: @escaping (_ response: Response<[PullRequest]>) -> Void) -> URLSessionDataTaskProtocol? { let router = PullRequestRouter.readPullRequests(configuration, owner, repository, base, state, sort, direction) - return router.load(session, expectedResultType: [PullRequest].self) { pullRequests, error in + return router.load(session, dateDecodingStrategy: .formatted(Time.rfc3339DateFormatter), expectedResultType: [PullRequest].self) { pullRequests, error in if let error = error { completion(Response.failure(error)) } else { diff --git a/OctoKit/Repositories.swift b/OctoKit/Repositories.swift index 4f11ddbb..1412f080 100644 --- a/OctoKit/Repositories.swift +++ b/OctoKit/Repositories.swift @@ -16,7 +16,7 @@ import RequestKit @objc open var cloneURL: String? @objc open var htmlURL: String? @objc open private(set) var size: Int = -1 -// @objc open var lastPush: Date? + @objc open var lastPush: Date? enum CodingKeys: String, CodingKey { case id @@ -31,7 +31,7 @@ import RequestKit case cloneURL = "clone_url" case htmlURL = "html_url" case size -// case lastPush = "pushed_at" + case lastPush = "pushed_at" } } @@ -51,7 +51,7 @@ public extension Octokit { let router = (owner != nil) ? RepositoryRouter.readRepositories(configuration, owner!, page, perPage) : RepositoryRouter.readAuthenticatedRepositories(configuration, page, perPage) - return router.load(session, expectedResultType: [Repository].self) { repos, error in + return router.load(session, dateDecodingStrategy: .formatted(Time.rfc3339DateFormatter), expectedResultType: [Repository].self) { repos, error in if let error = error { completion(Response.failure(error)) } @@ -71,7 +71,7 @@ public extension Octokit { */ public func repository(_ session: RequestKitURLSession = URLSession.shared, owner: String, name: String, completion: @escaping (_ response: Response) -> Void) -> URLSessionDataTaskProtocol? { let router = RepositoryRouter.readRepository(configuration, owner, name) - return router.load(session, expectedResultType: Repository.self) { repo, error in + return router.load(session, dateDecodingStrategy: .formatted(Time.rfc3339DateFormatter), expectedResultType: Repository.self) { repo, error in if let error = error { completion(Response.failure(error)) } else { diff --git a/OctoKit/Stars.swift b/OctoKit/Stars.swift index cfa444fa..d2be8d42 100644 --- a/OctoKit/Stars.swift +++ b/OctoKit/Stars.swift @@ -11,7 +11,7 @@ public extension Octokit { */ public func stars(_ session: RequestKitURLSession = URLSession.shared, name: String, completion: @escaping (_ response: Response<[Repository]>) -> Void) -> URLSessionDataTaskProtocol? { let router = StarsRouter.readStars(name, configuration) - return router.load(session, expectedResultType: [Repository].self) { repos, error in + return router.load(session, dateDecodingStrategy: .formatted(Time.rfc3339DateFormatter), expectedResultType: [Repository].self) { repos, error in if let error = error { completion(Response.failure(error)) } else { @@ -29,7 +29,7 @@ public extension Octokit { */ public func myStars(_ session: RequestKitURLSession = URLSession.shared, completion: @escaping (_ response: Response<[Repository]>) -> Void) -> URLSessionDataTaskProtocol? { let router = StarsRouter.readAuthenticatedStars(configuration) - return router.load(session, expectedResultType: [Repository].self) { repos, error in + return router.load(session, dateDecodingStrategy: .formatted(Time.rfc3339DateFormatter), expectedResultType: [Repository].self) { repos, error in if let error = error { completion(Response.failure(error)) } else { diff --git a/OctoKit/Time.swift b/OctoKit/Time.swift index 86f18394..bc32198f 100644 --- a/OctoKit/Time.swift +++ b/OctoKit/Time.swift @@ -1,26 +1,17 @@ import Foundation -public extension String { +public struct Time { /** A date formatter for RFC 3339 style timestamps. Uses POSIX locale and GMT timezone so that date values are parsed as absolutes. - [https://tools.ietf.org/html/rfc3339](https://tools.ietf.org/html/rfc3339) - [https://developer.apple.com/library/mac/qa/qa1480/_index.html](https://developer.apple.com/library/mac/qa/qa1480/_index.html) - [https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/DataFormatting/Articles/dfDateFormatting10_4.html](https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/DataFormatting/Articles/dfDateFormatting10_4.html) */ - fileprivate static var rfc3339DateFormatter: DateFormatter = { + public static var rfc3339DateFormatter: DateFormatter = { let formatter = DateFormatter() formatter.dateFormat = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'" formatter.locale = Locale(identifier: "en_US_POSIX") formatter.timeZone = TimeZone(secondsFromGMT: 0) return formatter }() - - /** - Parses RFC 3339 date strings into NSDate - - parameter string: The string representation of the date - - returns: An `NSDate` with a successful parse, otherwise `nil` - */ - func rfc3339Date() -> Date? { - return String.rfc3339DateFormatter.date(from: self) - } } diff --git a/OctoKitTests/TestHelper.swift b/OctoKitTests/TestHelper.swift index 53e23177..3ee921c5 100644 --- a/OctoKitTests/TestHelper.swift +++ b/OctoKitTests/TestHelper.swift @@ -1,4 +1,5 @@ import Foundation +import OctoKit internal class Helper { internal class func stringFromFile(_ name: String) -> String? { @@ -24,6 +25,8 @@ internal class Helper { let bundle = Bundle(for: self) let path = bundle.path(forResource: name, ofType: "json")! let data = try! Data(contentsOf: URL(fileURLWithPath: path)) - return try! JSONDecoder().decode(T.self, from: data) + let decoder = JSONDecoder() + decoder.dateDecodingStrategy = .formatted(Time.rfc3339DateFormatter) + return try! decoder.decode(T.self, from: data) } } From a0c4f8bc2c48ec725a0e95a56ad75f33fd4bdf1b Mon Sep 17 00:00:00 2001 From: Piet Brauer Date: Fri, 22 Dec 2017 11:09:02 +0100 Subject: [PATCH 125/302] Fix default id --- OctoKit/Issue.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OctoKit/Issue.swift b/OctoKit/Issue.swift index 92ee68a3..4d0594a4 100644 --- a/OctoKit/Issue.swift +++ b/OctoKit/Issue.swift @@ -10,7 +10,7 @@ public enum Openness: String, Codable { } @objc open class Issue: NSObject, Codable { - @objc open private(set) var id: Int = 01 + @objc open private(set) var id: Int = -1 @objc open var url: URL? @objc open var repositoryURL: URL? @objc open var labelsURL: URL? From e3be8522d10e7dc88da0230941b92a7a2fb03060 Mon Sep 17 00:00:00 2001 From: Piet Brauer Date: Fri, 22 Dec 2017 14:22:00 +0100 Subject: [PATCH 126/302] Update RequestKit to 2.1.0 --- Cartfile | 2 +- Cartfile.resolved | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cartfile b/Cartfile index 563ce06f..68459103 100644 --- a/Cartfile +++ b/Cartfile @@ -1 +1 @@ -github "nerdishbynature/RequestKit" "swift-4" +github "nerdishbynature/RequestKit" == 2.1.0 diff --git a/Cartfile.resolved b/Cartfile.resolved index 955a4e2c..d812108f 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1 +1 @@ -github "nerdishbynature/RequestKit" "39c65fcbd4c505617fa78911b4d3a05d2bc8b057" +github "nerdishbynature/RequestKit" "2.1.0" From d8e5855851fe531fc0eeb9bb8e36044bfdf7893d Mon Sep 17 00:00:00 2001 From: Piet Brauer Date: Tue, 27 Mar 2018 10:24:14 +0200 Subject: [PATCH 127/302] Bump version --- OctoKit.swift.podspec | 2 +- OctoKit/Info.plist | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/OctoKit.swift.podspec b/OctoKit.swift.podspec index 2ba94b91..507d695d 100644 --- a/OctoKit.swift.podspec +++ b/OctoKit.swift.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "OctoKit.swift" - s.version = "0.7.4" + s.version = "0.8.0" s.summary = "A Swift API Client for GitHub and GitHub Enterprise" s.description = <<-DESC You are looking at the A Swift API Client for GitHub and GitHub Enterprise. diff --git a/OctoKit/Info.plist b/OctoKit/Info.plist index 342a2465..5d7827c2 100644 --- a/OctoKit/Info.plist +++ b/OctoKit/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 0.7.4 + 0.8.0 CFBundleSignature ???? CFBundleVersion From 433a449d33d48761418d9d42d73ad1eead44dbe7 Mon Sep 17 00:00:00 2001 From: Piet Brauer Date: Tue, 27 Mar 2018 10:29:41 +0200 Subject: [PATCH 128/302] Bump swift version --- .swift-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.swift-version b/.swift-version index 9f55b2cc..5186d070 100644 --- a/.swift-version +++ b/.swift-version @@ -1 +1 @@ -3.0 +4.0 From a584a601461fbb5afe1d3b86dd92e0ae30ee35d1 Mon Sep 17 00:00:00 2001 From: Haris Khaliq Date: Sat, 13 Oct 2018 22:37:52 -0400 Subject: [PATCH 129/302] Fallback to Fixtures if path does not exist --- OctoKitTests/TestHelper.swift | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/OctoKitTests/TestHelper.swift b/OctoKitTests/TestHelper.swift index 3ee921c5..06b88c39 100644 --- a/OctoKitTests/TestHelper.swift +++ b/OctoKitTests/TestHelper.swift @@ -22,8 +22,15 @@ internal class Helper { } internal class func codableFromFile(_ name: String, type: T.Type) -> T where T: Codable { + var path: String let bundle = Bundle(for: self) - let path = bundle.path(forResource: name, ofType: "json")! + if let bundlePath = bundle.path(forResource: name, ofType: "json") { + path = bundlePath + } + else { + let bundle = Bundle(path: "Fixtures") + path = bundle!.path(forResource: name, ofType: "json")! + } let data = try! Data(contentsOf: URL(fileURLWithPath: path)) let decoder = JSONDecoder() decoder.dateDecodingStrategy = .formatted(Time.rfc3339DateFormatter) From 9960d4418f958fa44d8eef50ea584ef2305b3de3 Mon Sep 17 00:00:00 2001 From: Haris Khaliq Date: Sat, 13 Oct 2018 22:39:37 -0400 Subject: [PATCH 130/302] Add Package.swift to support PM --- .gitignore | 4 ++++ Package.swift | 29 +++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 Package.swift diff --git a/.gitignore b/.gitignore index 83e7347c..5d807f66 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,7 @@ fastlane/report.xml Pods/ Carthage/ Checkouts/ + +# Swift PM +.build +Package.resolved diff --git a/Package.swift b/Package.swift new file mode 100644 index 00000000..cc64d653 --- /dev/null +++ b/Package.swift @@ -0,0 +1,29 @@ +// swift-tools-version:4.2 +// The swift-tools-version declares the minimum version of Swift required to build this package. + +import PackageDescription + +let package = Package( + name: "OctoKit", + + products: [ + .library( + name: "OctoKit", + targets: ["OctoKit"]), + ], + dependencies: [ + .package(url: "https://github.com/shkhaliq/RequestKit", .branch("support-for-swift4")), + ], + targets: [ + .target( + name: "OctoKit", + dependencies: ["RequestKit"], + path: ".", + sources: ["OctoKit"]), + .testTarget( + name: "OctoKitTests", + dependencies: ["OctoKit"], + path: "OctoKitTests", + sources: ["."]), + ] +) From 427edf43b3a6fce4d7b3c3e80813f636ef668534 Mon Sep 17 00:00:00 2001 From: Haris Khaliq Date: Mon, 15 Oct 2018 20:35:19 -0400 Subject: [PATCH 131/302] Update path to Package.swift --- .travis.yml | 1 + OctoKitTests/TestHelper.swift | 2 +- Package.swift | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8e4fa4c6..c4550eba 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,6 +22,7 @@ script: - set -o pipefail - bundle exec fastlane $FASTLANE_LANE configuration:Debug --env $FASTLANE_ENV - bundle exec fastlane $FASTLANE_LANE configuration:Release --env $FASTLANE_ENV + - swift test after_success: - if [ "$FASTLANE_LANE" == "code_coverage" ]; then make post_coverage; diff --git a/OctoKitTests/TestHelper.swift b/OctoKitTests/TestHelper.swift index 06b88c39..f6b7ae82 100644 --- a/OctoKitTests/TestHelper.swift +++ b/OctoKitTests/TestHelper.swift @@ -28,7 +28,7 @@ internal class Helper { path = bundlePath } else { - let bundle = Bundle(path: "Fixtures") + let bundle = Bundle(path: "OctoKitTests/Fixtures") path = bundle!.path(forResource: name, ofType: "json")! } let data = try! Data(contentsOf: URL(fileURLWithPath: path)) diff --git a/Package.swift b/Package.swift index cc64d653..c3fa7662 100644 --- a/Package.swift +++ b/Package.swift @@ -12,7 +12,7 @@ let package = Package( targets: ["OctoKit"]), ], dependencies: [ - .package(url: "https://github.com/shkhaliq/RequestKit", .branch("support-for-swift4")), + .package(url: "https://github.com/nerdishbynature/RequestKit.git", .branch("master")), ], targets: [ .target( From c748dc9ca0216ca7d498be209f36e932f23bf1f0 Mon Sep 17 00:00:00 2001 From: Haris Khaliq Date: Mon, 15 Oct 2018 21:49:34 -0400 Subject: [PATCH 132/302] Remove swift test from travis.yml --- .travis.yml | 1 - Package.swift | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index c4550eba..8e4fa4c6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,7 +22,6 @@ script: - set -o pipefail - bundle exec fastlane $FASTLANE_LANE configuration:Debug --env $FASTLANE_ENV - bundle exec fastlane $FASTLANE_LANE configuration:Release --env $FASTLANE_ENV - - swift test after_success: - if [ "$FASTLANE_LANE" == "code_coverage" ]; then make post_coverage; diff --git a/Package.swift b/Package.swift index c3fa7662..15d9431d 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:4.2 +// swift-tools-version:4.0 // The swift-tools-version declares the minimum version of Swift required to build this package. import PackageDescription From 00ad2e3831be2b4569fb4cc6b66647729d44c632 Mon Sep 17 00:00:00 2001 From: Haris Khaliq Date: Mon, 15 Oct 2018 22:05:00 -0400 Subject: [PATCH 133/302] Add installation steps in README --- README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/README.md b/README.md index d237101a..64768a70 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,24 @@ # Octokit.swift [![Build Status](https://travis-ci.org/nerdishbynature/octokit.swift.svg?branch=master)](https://travis-ci.org/nerdishbynature/octokit.swift) +[![CocoaPods](https://img.shields.io/cocoapods/v/OctoKit.swift.svg)](https://cocoapods.org/pods/OctoKit.swift) [![codecov.io](https://codecov.io/github/nerdishbynature/octokit.swift/coverage.svg?branch=master)](https://codecov.io/github/nerdishbynature/octokit.swift?branch=master) +## Installation + +- **Using [Swift Package Manager](https://swift.org/package-manager)**: + + ```swift + import PackageDescription + + let package = Package( + name: "MyAwesomeApp", + dependencies: [ + .Package(url: "https://github.com/nerdishbynature/octokit.swift", from: "0.8.0"), + ] + ) + ``` + ## Authentication Octokit supports both, Github and Github Enterprise. From 38daf5512614522380691e9499d1185a88de1201 Mon Sep 17 00:00:00 2001 From: Haris Khaliq Date: Sat, 20 Oct 2018 23:03:53 -0400 Subject: [PATCH 134/302] PR Comments - remove indetentation --- README.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 64768a70..7cd8ed15 100644 --- a/README.md +++ b/README.md @@ -8,16 +8,16 @@ - **Using [Swift Package Manager](https://swift.org/package-manager)**: - ```swift - import PackageDescription - - let package = Package( - name: "MyAwesomeApp", - dependencies: [ - .Package(url: "https://github.com/nerdishbynature/octokit.swift", from: "0.8.0"), - ] - ) - ``` +```swift +import PackageDescription + +let package = Package( + name: "MyAwesomeApp", + dependencies: [ + .Package(url: "https://github.com/nerdishbynature/octokit.swift", from: "0.8.0"), + ] + ) +``` ## Authentication From 4270fdc8215511e92ccd7687f576b1d570da84df Mon Sep 17 00:00:00 2001 From: Haris Khaliq Date: Mon, 29 Oct 2018 09:51:59 -0400 Subject: [PATCH 135/302] Update requestKit version number --- Package.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Package.swift b/Package.swift index 15d9431d..b655d852 100644 --- a/Package.swift +++ b/Package.swift @@ -12,7 +12,7 @@ let package = Package( targets: ["OctoKit"]), ], dependencies: [ - .package(url: "https://github.com/nerdishbynature/RequestKit.git", .branch("master")), + .package(url: "https://github.com/nerdishbynature/RequestKit.git", .exact("2.3.0")), ], targets: [ .target( From ea7dfd503ce843c070294c85aa9c118da35eedb2 Mon Sep 17 00:00:00 2001 From: Franco Meloni Date: Mon, 12 Nov 2018 12:25:11 +0000 Subject: [PATCH 136/302] Make Octokit build with Linux (#69) * Remove not used Color extension * Duplicate Models to compile also with Linux * Added allTests property to make the tests executable also on Linux * Updated .travis.yml to use also Linux * Renamed travis scripts * Use the correct Script folder name * Updated permissions for travis scripts * Use swift version 4.2 on Linux * Added LinuxMain.swift * Try to make swift find LinuxMain file * Update LinuxMain permissions * Reverse 21892d66deb6e75fccdadae40f56b13209a312ae * Updated macos install script * install bundler on macos * Use SPM default test location to make it find LinuxMain.swift * Fixed defaultTestSuite compilation issue for macOS and tvOS * Set correct path to the Tests info.plist * Don't use Bundle(for:) on Linux * Not use the Bundle at all on Linux * Make tests compile * Remove all the other Bundle(for:) calls on Linux * Fix: Use resourceName * Find files also on Fixtures folder * Remove objc compatibility * Remove spaces from User.swift file --- .travis.yml | 22 ++++--- OctoKit.xcodeproj/project.pbxproj | 15 ++--- .../xcshareddata/IDEWorkspaceChecks.plist | 8 +++ OctoKit/Issue.swift | 36 ++++++------ OctoKit/Label.swift | 32 ++-------- OctoKit/Milestone.swift | 24 ++++---- OctoKit/PullRequest.swift | 58 +++++++++---------- OctoKit/Repositories.swift | 31 +++++----- OctoKit/User.swift | 23 ++++---- OctoKitTests/OctokitSwiftTests.swift | 17 ------ OctoKitTests/TestHelper.swift | 39 ------------- Package.swift | 4 +- Script/travis-install-linux | 4 ++ Script/travis-install-macos | 4 ++ Script/travis-script-linux | 3 + Script/travis-script-macos | 4 ++ Tests/LinuxMain.swift | 4 ++ .../OctoKitTests}/ConfigurationTests.swift | 23 ++++++++ .../OctoKitTests}/Fixtures/issue.json | 0 .../OctoKitTests}/Fixtures/issues.json | 0 .../OctoKitTests}/Fixtures/public_key.json | 0 .../OctoKitTests}/Fixtures/repo.json | 0 .../OctoKitTests}/Fixtures/user_me.json | 0 .../Fixtures/user_mietzmithut.json | 0 .../OctoKitTests}/Fixtures/user_repos.json | 0 .../OctoKitTests}/FollowTests.swift | 25 ++++++++ .../OctoKitTests}/Info.plist | 0 .../OctoKitTests}/IssueTests.swift | 20 +++++++ .../OctoKitTests}/OctoKitURLTestSession.swift | 0 Tests/OctoKitTests/OctokitSwiftTests.swift | 36 ++++++++++++ .../OctoKitTests}/PublicKeyTests.swift | 18 ++++++ .../OctoKitTests}/PullRequestTests.swift | 21 ++++++- .../OctoKitTests}/RepositoryTests.swift | 26 +++++++++ .../OctoKitTests}/StarsTests.swift | 21 +++++++ Tests/OctoKitTests/TestHelper.swift | 58 +++++++++++++++++++ .../OctoKitTests}/UserTests.swift | 23 ++++++++ Tests/OctoKitTests/XCTestManifests.swift | 24 ++++++++ .../OctoKitTests}/pull_request.json | 0 .../OctoKitTests}/pull_requests.json | 0 .../OctoKitTests}/users.json | 0 40 files changed, 432 insertions(+), 191 deletions(-) create mode 100644 OctoKit.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist delete mode 100644 OctoKitTests/OctokitSwiftTests.swift delete mode 100644 OctoKitTests/TestHelper.swift create mode 100755 Script/travis-install-linux create mode 100755 Script/travis-install-macos create mode 100755 Script/travis-script-linux create mode 100755 Script/travis-script-macos create mode 100755 Tests/LinuxMain.swift rename {OctoKitTests => Tests/OctoKitTests}/ConfigurationTests.swift (68%) rename {OctoKitTests => Tests/OctoKitTests}/Fixtures/issue.json (100%) rename {OctoKitTests => Tests/OctoKitTests}/Fixtures/issues.json (100%) rename {OctoKitTests => Tests/OctoKitTests}/Fixtures/public_key.json (100%) rename {OctoKitTests => Tests/OctoKitTests}/Fixtures/repo.json (100%) rename {OctoKitTests => Tests/OctoKitTests}/Fixtures/user_me.json (100%) rename {OctoKitTests => Tests/OctoKitTests}/Fixtures/user_mietzmithut.json (100%) rename {OctoKitTests => Tests/OctoKitTests}/Fixtures/user_repos.json (100%) rename {OctoKitTests => Tests/OctoKitTests}/FollowTests.swift (82%) rename {OctoKitTests => Tests/OctoKitTests}/Info.plist (100%) rename {OctoKitTests => Tests/OctoKitTests}/IssueTests.swift (71%) rename {OctoKitTests => Tests/OctoKitTests}/OctoKitURLTestSession.swift (100%) create mode 100644 Tests/OctoKitTests/OctokitSwiftTests.swift rename {OctoKitTests => Tests/OctoKitTests}/PublicKeyTests.swift (54%) rename {OctoKitTests => Tests/OctoKitTests}/PullRequestTests.swift (70%) rename {OctoKitTests => Tests/OctoKitTests}/RepositoryTests.swift (84%) rename {OctoKitTests => Tests/OctoKitTests}/StarsTests.swift (74%) create mode 100644 Tests/OctoKitTests/TestHelper.swift rename {OctoKitTests => Tests/OctoKitTests}/UserTests.swift (81%) create mode 100644 Tests/OctoKitTests/XCTestManifests.swift rename {OctoKitTests => Tests/OctoKitTests}/pull_request.json (100%) rename {OctoKitTests => Tests/OctoKitTests}/pull_requests.json (100%) rename {OctoKitTests => Tests/OctoKitTests}/users.json (100%) diff --git a/.travis.yml b/.travis.yml index 8e4fa4c6..120c597f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,4 @@ -language: objective-c +language: generic osx_image: xcode9.2 sudo: false env: @@ -8,20 +8,24 @@ env: - FASTLANE_LANE=ci_commit matrix: include: - - osx_image: xcode9.2 + - os: osx env: FASTLANE_LANE=code_coverage FASTLANE_ENV=default - - osx_image: xcode9.2 + - os: osx env: FASTLANE_ENV=ios93 - - osx_image: xcode9.2 + - os: osx env: FASTLANE_ENV=tvos92 - - osx_image: xcode9.2 + - os: osx env: FASTLANE_ENV=osx + - os: linux + sudo: required + dist: trusty + env: SWIFT_VERSION=4.2 before_install: - - make install + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then ./Script/travis-install-linux; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then ./Script/travis-install-macos; fi script: - - set -o pipefail - - bundle exec fastlane $FASTLANE_LANE configuration:Debug --env $FASTLANE_ENV - - bundle exec fastlane $FASTLANE_LANE configuration:Release --env $FASTLANE_ENV + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then ./Script/travis-script-linux; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then ./Script/travis-script-macos; fi after_success: - if [ "$FASTLANE_LANE" == "code_coverage" ]; then make post_coverage; diff --git a/OctoKit.xcodeproj/project.pbxproj b/OctoKit.xcodeproj/project.pbxproj index 4b1fab71..9b53ebe0 100644 --- a/OctoKit.xcodeproj/project.pbxproj +++ b/OctoKit.xcodeproj/project.pbxproj @@ -334,7 +334,8 @@ 234F4BAD1BDDE31A00A58EF7 /* Info.plist */, BF8C76EB002802C14A08F63E /* PullRequestTests.swift */, ); - path = OctoKitTests; + name = OctoKitTests; + path = Tests/OctoKitTests; sourceTree = ""; }; 234F4BD71BDDE40400A58EF7 /* Fixtures */ = { @@ -909,7 +910,7 @@ "$(PROJECT_DIR)/Carthage/Build/iOS", ); GCC_NO_COMMON_BLOCKS = YES; - INFOPLIST_FILE = OctoKitTests/Info.plist; + INFOPLIST_FILE = Tests/OctoKitTests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks $(FRAMEWORK_SEARCH_PATHS)"; PRODUCT_BUNDLE_IDENTIFIER = com.nerdishbynature.OctoKitTests; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -930,7 +931,7 @@ "$(PROJECT_DIR)/Carthage/Build/iOS", ); GCC_NO_COMMON_BLOCKS = YES; - INFOPLIST_FILE = OctoKitTests/Info.plist; + INFOPLIST_FILE = Tests/OctoKitTests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks $(FRAMEWORK_SEARCH_PATHS)"; PRODUCT_BUNDLE_IDENTIFIER = com.nerdishbynature.OctoKitTests; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -1064,7 +1065,7 @@ "$(PROJECT_DIR)/Carthage/Build/tvOS", ); GCC_NO_COMMON_BLOCKS = YES; - INFOPLIST_FILE = OctoKitTests/Info.plist; + INFOPLIST_FILE = Tests/OctoKitTests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks $(FRAMEWORK_SEARCH_PATHS)"; PRODUCT_BUNDLE_IDENTIFIER = "com.nerdishbynature.OctoKit-tvOSTests"; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -1085,7 +1086,7 @@ "$(PROJECT_DIR)/Carthage/Build/tvOS", ); GCC_NO_COMMON_BLOCKS = YES; - INFOPLIST_FILE = OctoKitTests/Info.plist; + INFOPLIST_FILE = Tests/OctoKitTests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks $(FRAMEWORK_SEARCH_PATHS)"; PRODUCT_BUNDLE_IDENTIFIER = "com.nerdishbynature.OctoKit-tvOSTests"; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -1164,7 +1165,7 @@ "$(PROJECT_DIR)/Carthage/Build/Mac", ); GCC_NO_COMMON_BLOCKS = YES; - INFOPLIST_FILE = OctoKitTests/Info.plist; + INFOPLIST_FILE = Tests/OctoKitTests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks $(FRAMEWORK_SEARCH_PATHS)"; PRODUCT_BUNDLE_IDENTIFIER = "com.nerdishbynature.OctoKit-MacTests"; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -1185,7 +1186,7 @@ "$(PROJECT_DIR)/Carthage/Build/Mac", ); GCC_NO_COMMON_BLOCKS = YES; - INFOPLIST_FILE = OctoKitTests/Info.plist; + INFOPLIST_FILE = Tests/OctoKitTests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks $(FRAMEWORK_SEARCH_PATHS)"; PRODUCT_BUNDLE_IDENTIFIER = "com.nerdishbynature.OctoKit-MacTests"; PRODUCT_NAME = "$(TARGET_NAME)"; diff --git a/OctoKit.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/OctoKit.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 00000000..18d98100 --- /dev/null +++ b/OctoKit.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/OctoKit/Issue.swift b/OctoKit/Issue.swift index 4d0594a4..d8b32bf8 100644 --- a/OctoKit/Issue.swift +++ b/OctoKit/Issue.swift @@ -9,28 +9,28 @@ public enum Openness: String, Codable { case All = "all" } -@objc open class Issue: NSObject, Codable { - @objc open private(set) var id: Int = -1 - @objc open var url: URL? - @objc open var repositoryURL: URL? - @objc open var labelsURL: URL? - @objc open var commentsURL: URL? - @objc open var eventsURL: URL? - @objc open var htmlURL: URL? +open class Issue: Codable { + open private(set) var id: Int = -1 + open var url: URL? + open var repositoryURL: URL? + open var labelsURL: URL? + open var commentsURL: URL? + open var eventsURL: URL? + open var htmlURL: URL? open var number: Int? open var state: Openness? - @objc open var title: String? - @objc open var body: String? - @objc open var user: User? - @objc open var labels: [Label]? - @objc open var assignee: User? - @objc open var milestone: Milestone? + open var title: String? + open var body: String? + open var user: User? + open var labels: [Label]? + open var assignee: User? + open var milestone: Milestone? open var locked: Bool? open var comments: Int? - @objc open var closedAt: Date? - @objc open var createdAt: Date? - @objc open var updatedAt: Date? - @objc open var closedBy: User? + open var closedAt: Date? + open var createdAt: Date? + open var updatedAt: Date? + open var closedBy: User? enum CodingKeys: String, CodingKey { case id diff --git a/OctoKit/Label.swift b/OctoKit/Label.swift index fec701a2..27270ac3 100644 --- a/OctoKit/Label.swift +++ b/OctoKit/Label.swift @@ -1,29 +1,7 @@ -#if os(OSX) - import Cocoa - typealias Color = NSColor -#elseif os(iOS) || os(tvOS) || os(watchOS) - import UIKit - typealias Color = UIColor -#endif +import Foundation -extension Color { - @objc convenience init?(hexTriplet hex: String) { - var hexChars = Substring(hex) - let red = Int(String(hex.prefix(2)), radix: 16) - hexChars = hexChars.dropFirst(2) - let green = Int(String(hexChars.prefix(2)), radix: 16) - hexChars = hexChars.dropFirst(2) - let blue = Int(String(hexChars), radix: 16) - if let red = red, let green = green, let blue = blue { - self.init(red: CGFloat(red) / 255.0, green: CGFloat(green) / 255.0, blue: CGFloat(blue) / 255.0, alpha: 1) - } else { - return nil - } - } -} - -@objc open class Label: NSObject, Codable { - @objc open var url: URL? - @objc open var name: String? - @objc open var color: String? +open class Label: Codable { + open var url: URL? + open var name: String? + open var color: String? } diff --git a/OctoKit/Milestone.swift b/OctoKit/Milestone.swift index a1bb53c2..63ad464f 100644 --- a/OctoKit/Milestone.swift +++ b/OctoKit/Milestone.swift @@ -1,21 +1,21 @@ import Foundation -@objc open class Milestone: NSObject, Codable { - @objc open var url: URL? - @objc open var htmlURL: URL? - @objc open var labelsURL: URL? - @objc open private(set) var id: Int = -1 +open class Milestone: Codable { + open var url: URL? + open var htmlURL: URL? + open var labelsURL: URL? + open private(set) var id: Int = -1 open var number: Int? open var state: Openness? - @objc open var title: String? - @objc open var milestoneDescription: String? - @objc open var creator: User? + open var title: String? + open var milestoneDescription: String? + open var creator: User? open var openIssues: Int? open var closedIssues: Int? - @objc open var createdAt: Date? - @objc open var updatedAt: Date? - @objc open var closedAt: Date? - @objc open var dueOn: Date? + open var createdAt: Date? + open var updatedAt: Date? + open var closedAt: Date? + open var dueOn: Date? enum CodingKeys: String, CodingKey { case id diff --git a/OctoKit/PullRequest.swift b/OctoKit/PullRequest.swift index 0217253e..43c4e456 100644 --- a/OctoKit/PullRequest.swift +++ b/OctoKit/PullRequest.swift @@ -1,37 +1,36 @@ import Foundation import RequestKit -@objc open class PullRequest: NSObject, Codable { - - @objc private(set) open var id: Int = -1 - @objc open var url: URL? - - @objc open var htmlURL: URL? - @objc open var diffURL: URL? - @objc open var patchURL: URL? - @objc open var issueURL: URL? - @objc open var commitsURL: URL? - @objc open var reviewCommentsURL: URL? - @objc open var reviewCommentURL: URL? - @objc open var commentsURL: URL? - @objc open var statusesURL: URL? - +open class PullRequest: Codable { + private(set) open var id: Int = -1 + open var url: URL? + + open var htmlURL: URL? + open var diffURL: URL? + open var patchURL: URL? + open var issueURL: URL? + open var commitsURL: URL? + open var reviewCommentsURL: URL? + open var reviewCommentURL: URL? + open var commentsURL: URL? + open var statusesURL: URL? + + open var title: String? + open var body: String? + + open var assignee: User? + open var milestone: Milestone? + + open var locked: Bool? + open var createdAt: Date? + open var updatedAt: Date? + open var closedAt: Date? + open var mergedAt: Date? + + open var user: User? open var number: Int? open var state: Openness? - @objc open var title: String? - @objc open var body: String? - - @objc open var assignee: User? - @objc open var milestone: Milestone? - - open var locked: Bool? - @objc open var createdAt: Date? - @objc open var updatedAt: Date? - @objc open var closedAt: Date? - @objc open var mergedAt: Date? - - @objc open var user: User? - + enum CodingKeys: String, CodingKey { case id case url @@ -56,6 +55,7 @@ import RequestKit } } + // MARK: Request public extension Octokit { diff --git a/OctoKit/Repositories.swift b/OctoKit/Repositories.swift index 1412f080..b718e926 100644 --- a/OctoKit/Repositories.swift +++ b/OctoKit/Repositories.swift @@ -2,22 +2,21 @@ import Foundation import RequestKit // MARK: model - -@objc open class Repository: NSObject, Codable { - @objc open private(set) var id: Int = -1 - @objc open private(set) var owner = User() - @objc open var name: String? - @objc open var fullName: String? - @objc open private(set) var isPrivate: Bool = false - @objc open var repositoryDescription: String? - @objc open private(set) var isFork: Bool = false - @objc open var gitURL: String? - @objc open var sshURL: String? - @objc open var cloneURL: String? - @objc open var htmlURL: String? - @objc open private(set) var size: Int = -1 - @objc open var lastPush: Date? - +open class Repository: Codable { + open private(set) var id: Int = -1 + open private(set) var owner = User() + open var name: String? + open var fullName: String? + open private(set) var isPrivate: Bool = false + open var repositoryDescription: String? + open private(set) var isFork: Bool = false + open var gitURL: String? + open var sshURL: String? + open var cloneURL: String? + open var htmlURL: String? + open private(set) var size: Int = -1 + open var lastPush: Date? + enum CodingKeys: String, CodingKey { case id case owner diff --git a/OctoKit/User.swift b/OctoKit/User.swift index 98d01496..43e0fae3 100644 --- a/OctoKit/User.swift +++ b/OctoKit/User.swift @@ -2,18 +2,17 @@ import Foundation import RequestKit // MARK: model - -@objc open class User: NSObject, Codable { - @objc open internal(set) var id: Int = -1 - @objc open var login: String? - @objc open var avatarURL: String? - @objc open var gravatarID: String? - @objc open var type: String? - @objc open var name: String? - @objc open var company: String? - @objc open var blog: String? - @objc open var location: String? - @objc open var email: String? +open class User: Codable { + open internal(set) var id: Int = -1 + open var login: String? + open var avatarURL: String? + open var gravatarID: String? + open var type: String? + open var name: String? + open var company: String? + open var blog: String? + open var location: String? + open var email: String? open var numberOfPublicRepos: Int? open var numberOfPublicGists: Int? open var numberOfPrivateRepos: Int? diff --git a/OctoKitTests/OctokitSwiftTests.swift b/OctoKitTests/OctokitSwiftTests.swift deleted file mode 100644 index 216f7382..00000000 --- a/OctoKitTests/OctokitSwiftTests.swift +++ /dev/null @@ -1,17 +0,0 @@ -import XCTest -import OctoKit - -let enterpriseURL = "https://enterprise.myserver.com" - -class OctokitSwiftTests: XCTestCase { - func testOctokitInitializerWithEmptyConfig() { - let subject = Octokit() - XCTAssertEqual(subject.configuration.apiEndpoint, "https://api.github.com") - } - - func testOctokitInitializerWithConfig() { - let config = TokenConfiguration("12345", url: enterpriseURL) - let subject = Octokit(config) - XCTAssertEqual(subject.configuration.apiEndpoint, "https://enterprise.myserver.com") - } -} diff --git a/OctoKitTests/TestHelper.swift b/OctoKitTests/TestHelper.swift deleted file mode 100644 index f6b7ae82..00000000 --- a/OctoKitTests/TestHelper.swift +++ /dev/null @@ -1,39 +0,0 @@ -import Foundation -import OctoKit - -internal class Helper { - internal class func stringFromFile(_ name: String) -> String? { - let bundle = Bundle(for: self) - let path = bundle.path(forResource: name, ofType: "json") - if let path = path { - let string = try? String(contentsOfFile: path, encoding: String.Encoding.utf8) - return string - } - return nil - } - - internal class func JSONFromFile(_ name: String) -> Any { - let bundle = Bundle(for: self) - let path = bundle.path(forResource: name, ofType: "json")! - let data = try! Data(contentsOf: URL(fileURLWithPath: path)) - let dict: Any? = try? JSONSerialization.jsonObject(with: data, - options: JSONSerialization.ReadingOptions.mutableContainers) - return dict! - } - - internal class func codableFromFile(_ name: String, type: T.Type) -> T where T: Codable { - var path: String - let bundle = Bundle(for: self) - if let bundlePath = bundle.path(forResource: name, ofType: "json") { - path = bundlePath - } - else { - let bundle = Bundle(path: "OctoKitTests/Fixtures") - path = bundle!.path(forResource: name, ofType: "json")! - } - let data = try! Data(contentsOf: URL(fileURLWithPath: path)) - let decoder = JSONDecoder() - decoder.dateDecodingStrategy = .formatted(Time.rfc3339DateFormatter) - return try! decoder.decode(T.self, from: data) - } -} diff --git a/Package.swift b/Package.swift index b655d852..0a568582 100644 --- a/Package.swift +++ b/Package.swift @@ -22,8 +22,6 @@ let package = Package( sources: ["OctoKit"]), .testTarget( name: "OctoKitTests", - dependencies: ["OctoKit"], - path: "OctoKitTests", - sources: ["."]), + dependencies: ["OctoKit"]), ] ) diff --git a/Script/travis-install-linux b/Script/travis-install-linux new file mode 100755 index 00000000..c56970e0 --- /dev/null +++ b/Script/travis-install-linux @@ -0,0 +1,4 @@ +#!/usr/bin/env bash +set -e + # See: https://github.com/kylef/swiftenv/wiki/Travis-CI +curl -sL https://gist.github.com/kylef/5c0475ff02b7c7671d2a/raw/621ef9b29bbb852fdfd2e10ed147b321d792c1e4/swiftenv-install.sh | bash \ No newline at end of file diff --git a/Script/travis-install-macos b/Script/travis-install-macos new file mode 100755 index 00000000..ad59d3da --- /dev/null +++ b/Script/travis-install-macos @@ -0,0 +1,4 @@ +#!/usr/bin/env sh +sudo gem install bundler +bundle install +make install \ No newline at end of file diff --git a/Script/travis-script-linux b/Script/travis-script-linux new file mode 100755 index 00000000..3204a13b --- /dev/null +++ b/Script/travis-script-linux @@ -0,0 +1,3 @@ +#!/usr/bin/env sh + . ~/.swiftenv/init +swift test \ No newline at end of file diff --git a/Script/travis-script-macos b/Script/travis-script-macos new file mode 100755 index 00000000..e791403d --- /dev/null +++ b/Script/travis-script-macos @@ -0,0 +1,4 @@ +#!/usr/bin/env sh + set -o pipefail +bundle exec fastlane $FASTLANE_LANE configuration:Debug --env $FASTLANE_ENV +bundle exec fastlane $FASTLANE_LANE configuration:Release --env $FASTLANE_ENV \ No newline at end of file diff --git a/Tests/LinuxMain.swift b/Tests/LinuxMain.swift new file mode 100755 index 00000000..09659844 --- /dev/null +++ b/Tests/LinuxMain.swift @@ -0,0 +1,4 @@ +import XCTest +@testable import OctoKitTests + +XCTMain(OctoKitTests.allTests()) \ No newline at end of file diff --git a/OctoKitTests/ConfigurationTests.swift b/Tests/OctoKitTests/ConfigurationTests.swift similarity index 68% rename from OctoKitTests/ConfigurationTests.swift rename to Tests/OctoKitTests/ConfigurationTests.swift index 60514ecc..508d015d 100644 --- a/OctoKitTests/ConfigurationTests.swift +++ b/Tests/OctoKitTests/ConfigurationTests.swift @@ -3,6 +3,16 @@ import Foundation import OctoKit class ConfigurationTests: XCTestCase { + static var allTests = [ + ("testTokenConfiguration", testTokenConfiguration), + ("testEnterpriseTokenConfiguration", testEnterpriseTokenConfiguration), + ("testOAuthConfiguration", testOAuthConfiguration), + ("testOAuthTokenConfiguration", testOAuthTokenConfiguration), + ("testAccessTokenFromResponse", testAccessTokenFromResponse), + ("testHandleOpenURL", testHandleOpenURL), + ("testLinuxTestSuiteIncludesAllTests", testLinuxTestSuiteIncludesAllTests) + ] + func testTokenConfiguration() { let subject = TokenConfiguration("12345") XCTAssertEqual(subject.accessToken, "12345") @@ -48,4 +58,17 @@ class ConfigurationTests: XCTestCase { XCTAssertEqual(token, "017ec60f4a182") XCTAssertTrue(session.wasCalled) } + + func testLinuxTestSuiteIncludesAllTests() { + #if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) + let thisClass = type(of: self) + let linuxCount = thisClass.allTests.count + #if os(iOS) + let darwinCount = thisClass.defaultTestSuite.tests.count + #else + let darwinCount = thisClass.defaultTestSuite().tests.count + #endif + XCTAssertEqual(linuxCount, darwinCount, "\(darwinCount - linuxCount) tests are missing from allTests") + #endif + } } diff --git a/OctoKitTests/Fixtures/issue.json b/Tests/OctoKitTests/Fixtures/issue.json similarity index 100% rename from OctoKitTests/Fixtures/issue.json rename to Tests/OctoKitTests/Fixtures/issue.json diff --git a/OctoKitTests/Fixtures/issues.json b/Tests/OctoKitTests/Fixtures/issues.json similarity index 100% rename from OctoKitTests/Fixtures/issues.json rename to Tests/OctoKitTests/Fixtures/issues.json diff --git a/OctoKitTests/Fixtures/public_key.json b/Tests/OctoKitTests/Fixtures/public_key.json similarity index 100% rename from OctoKitTests/Fixtures/public_key.json rename to Tests/OctoKitTests/Fixtures/public_key.json diff --git a/OctoKitTests/Fixtures/repo.json b/Tests/OctoKitTests/Fixtures/repo.json similarity index 100% rename from OctoKitTests/Fixtures/repo.json rename to Tests/OctoKitTests/Fixtures/repo.json diff --git a/OctoKitTests/Fixtures/user_me.json b/Tests/OctoKitTests/Fixtures/user_me.json similarity index 100% rename from OctoKitTests/Fixtures/user_me.json rename to Tests/OctoKitTests/Fixtures/user_me.json diff --git a/OctoKitTests/Fixtures/user_mietzmithut.json b/Tests/OctoKitTests/Fixtures/user_mietzmithut.json similarity index 100% rename from OctoKitTests/Fixtures/user_mietzmithut.json rename to Tests/OctoKitTests/Fixtures/user_mietzmithut.json diff --git a/OctoKitTests/Fixtures/user_repos.json b/Tests/OctoKitTests/Fixtures/user_repos.json similarity index 100% rename from OctoKitTests/Fixtures/user_repos.json rename to Tests/OctoKitTests/Fixtures/user_repos.json diff --git a/OctoKitTests/FollowTests.swift b/Tests/OctoKitTests/FollowTests.swift similarity index 82% rename from OctoKitTests/FollowTests.swift rename to Tests/OctoKitTests/FollowTests.swift index ceb81eab..440cc125 100644 --- a/OctoKitTests/FollowTests.swift +++ b/Tests/OctoKitTests/FollowTests.swift @@ -2,6 +2,18 @@ import XCTest import OctoKit class FollowTests: XCTestCase { + static var allTests = [ + ("testGetMyFollowers", testGetMyFollowers), + ("testFailToGetMyFollowers", testFailToGetMyFollowers), + ("testGetUsersFollowers", testGetUsersFollowers), + ("testFailToGetUsersFollowers", testFailToGetUsersFollowers), + ("testGetMyFollowing", testGetMyFollowing), + ("testFailToGetMyFollowing", testFailToGetMyFollowing), + ("testGetUsersFollowing", testGetUsersFollowing), + ("testFailToGetUsersFollowing", testFailToGetUsersFollowing), + ("testLinuxTestSuiteIncludesAllTests", testLinuxTestSuiteIncludesAllTests) + ] + func testGetMyFollowers() { let config = TokenConfiguration("12345") let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/user/followers?access_token=12345", expectedHTTPMethod: "GET", jsonFile: "users", statusCode: 200) @@ -121,4 +133,17 @@ class FollowTests: XCTestCase { XCTAssertNotNil(task) XCTAssertTrue(session.wasCalled) } + + func testLinuxTestSuiteIncludesAllTests() { + #if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) + let thisClass = type(of: self) + let linuxCount = thisClass.allTests.count + #if os(iOS) + let darwinCount = thisClass.defaultTestSuite.tests.count + #else + let darwinCount = thisClass.defaultTestSuite().tests.count + #endif + XCTAssertEqual(linuxCount, darwinCount, "\(darwinCount - linuxCount) tests are missing from allTests") + #endif + } } diff --git a/OctoKitTests/Info.plist b/Tests/OctoKitTests/Info.plist similarity index 100% rename from OctoKitTests/Info.plist rename to Tests/OctoKitTests/Info.plist diff --git a/OctoKitTests/IssueTests.swift b/Tests/OctoKitTests/IssueTests.swift similarity index 71% rename from OctoKitTests/IssueTests.swift rename to Tests/OctoKitTests/IssueTests.swift index 42de30c1..b4f5ab77 100644 --- a/OctoKitTests/IssueTests.swift +++ b/Tests/OctoKitTests/IssueTests.swift @@ -2,6 +2,13 @@ import XCTest import OctoKit class IssueTests: XCTestCase { + static var allTests = [ + ("testGetMyIssues", testGetMyIssues), + ("testGetIssue", testGetIssue), + ("testParsingIssue", testParsingIssue), + ("testLinuxTestSuiteIncludesAllTests", testLinuxTestSuiteIncludesAllTests) + ] + // MARK: Actual Request tests func testGetMyIssues() { @@ -47,4 +54,17 @@ class IssueTests: XCTestCase { XCTAssertEqual(subject.state, Openness.Open) XCTAssertEqual(subject.locked, false) } + + func testLinuxTestSuiteIncludesAllTests() { + #if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) + let thisClass = type(of: self) + let linuxCount = thisClass.allTests.count + #if os(iOS) + let darwinCount = thisClass.defaultTestSuite.tests.count + #else + let darwinCount = thisClass.defaultTestSuite().tests.count + #endif + XCTAssertEqual(linuxCount, darwinCount, "\(darwinCount - linuxCount) tests are missing from allTests") + #endif + } } diff --git a/OctoKitTests/OctoKitURLTestSession.swift b/Tests/OctoKitTests/OctoKitURLTestSession.swift similarity index 100% rename from OctoKitTests/OctoKitURLTestSession.swift rename to Tests/OctoKitTests/OctoKitURLTestSession.swift diff --git a/Tests/OctoKitTests/OctokitSwiftTests.swift b/Tests/OctoKitTests/OctokitSwiftTests.swift new file mode 100644 index 00000000..73c08072 --- /dev/null +++ b/Tests/OctoKitTests/OctokitSwiftTests.swift @@ -0,0 +1,36 @@ +import XCTest +import OctoKit + +let enterpriseURL = "https://enterprise.myserver.com" + +class OctokitSwiftTests: XCTestCase { + static var allTests = [ + ("testOctokitInitializerWithEmptyConfig", testOctokitInitializerWithEmptyConfig), + ("testOctokitInitializerWithConfig", testOctokitInitializerWithConfig), + ("testLinuxTestSuiteIncludesAllTests", testLinuxTestSuiteIncludesAllTests) + ] + + func testOctokitInitializerWithEmptyConfig() { + let subject = Octokit() + XCTAssertEqual(subject.configuration.apiEndpoint, "https://api.github.com") + } + + func testOctokitInitializerWithConfig() { + let config = TokenConfiguration("12345", url: enterpriseURL) + let subject = Octokit(config) + XCTAssertEqual(subject.configuration.apiEndpoint, "https://enterprise.myserver.com") + } + + func testLinuxTestSuiteIncludesAllTests() { + #if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) + let thisClass = type(of: self) + let linuxCount = thisClass.allTests.count + #if os(iOS) + let darwinCount = thisClass.defaultTestSuite.tests.count + #else + let darwinCount = thisClass.defaultTestSuite().tests.count + #endif + XCTAssertEqual(linuxCount, darwinCount, "\(darwinCount - linuxCount) tests are missing from allTests") + #endif + } +} diff --git a/OctoKitTests/PublicKeyTests.swift b/Tests/OctoKitTests/PublicKeyTests.swift similarity index 54% rename from OctoKitTests/PublicKeyTests.swift rename to Tests/OctoKitTests/PublicKeyTests.swift index d88e9a51..65c038d3 100644 --- a/OctoKitTests/PublicKeyTests.swift +++ b/Tests/OctoKitTests/PublicKeyTests.swift @@ -3,6 +3,11 @@ import RequestKit import OctoKit class PublicKeyTests: XCTestCase { + static var allTests = [ + ("testPostPublicKey", testPostPublicKey), + ("testLinuxTestSuiteIncludesAllTests", testLinuxTestSuiteIncludesAllTests) + ] + // MARK: Actual Request tests func testPostPublicKey() { @@ -19,4 +24,17 @@ class PublicKeyTests: XCTestCase { XCTAssertNotNil(task) XCTAssertTrue(session.wasCalled) } + + func testLinuxTestSuiteIncludesAllTests() { + #if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) + let thisClass = type(of: self) + let linuxCount = thisClass.allTests.count + #if os(iOS) + let darwinCount = thisClass.defaultTestSuite.tests.count + #else + let darwinCount = thisClass.defaultTestSuite().tests.count + #endif + XCTAssertEqual(linuxCount, darwinCount, "\(darwinCount - linuxCount) tests are missing from allTests") + #endif + } } diff --git a/OctoKitTests/PullRequestTests.swift b/Tests/OctoKitTests/PullRequestTests.swift similarity index 70% rename from OctoKitTests/PullRequestTests.swift rename to Tests/OctoKitTests/PullRequestTests.swift index 58f6c1b0..dcd2479e 100644 --- a/OctoKitTests/PullRequestTests.swift +++ b/Tests/OctoKitTests/PullRequestTests.swift @@ -1,8 +1,13 @@ import XCTest import OctoKit -class PullRequeastTests: XCTestCase { - +class PullRequestTests: XCTestCase { + static var allTests = [ + ("testGetPullRequest", testGetPullRequest), + ("testGetPullRequests", testGetPullRequests), + ("testLinuxTestSuiteIncludesAllTests", testLinuxTestSuiteIncludesAllTests) + ] + func testGetPullRequest() { let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/repos/octocat/Hello-World/pulls/1", expectedHTTPMethod: "GET", @@ -45,4 +50,16 @@ class PullRequeastTests: XCTestCase { XCTAssertTrue(session.wasCalled) } + func testLinuxTestSuiteIncludesAllTests() { + #if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) + let thisClass = type(of: self) + let linuxCount = thisClass.allTests.count + #if os(iOS) + let darwinCount = thisClass.defaultTestSuite.tests.count + #else + let darwinCount = thisClass.defaultTestSuite().tests.count + #endif + XCTAssertEqual(linuxCount, darwinCount, "\(darwinCount - linuxCount) tests are missing from allTests") + #endif + } } diff --git a/OctoKitTests/RepositoryTests.swift b/Tests/OctoKitTests/RepositoryTests.swift similarity index 84% rename from OctoKitTests/RepositoryTests.swift rename to Tests/OctoKitTests/RepositoryTests.swift index 7f6dff91..39f1ef6e 100644 --- a/OctoKitTests/RepositoryTests.swift +++ b/Tests/OctoKitTests/RepositoryTests.swift @@ -2,6 +2,19 @@ import XCTest import OctoKit class RepositoryTests: XCTestCase { + static var allTests = [ + ("testGetRepositories", testGetRepositories), + ("testGetRepositoriesEnterprise", testGetRepositoriesEnterprise), + ("testGetAuthenticatedRepositories", testGetAuthenticatedRepositories), + ("testGetAuthenticatedRepositoriesEnterprise", testGetAuthenticatedRepositoriesEnterprise), + ("testFailToGetRepositories", testFailToGetRepositories), + ("testGetRepository", testGetRepository), + ("testGetRepositoryEnterprise", testGetRepositoryEnterprise), + ("testFailToGetRepository", testFailToGetRepository), + ("testUserParsingFullRepository", testUserParsingFullRepository), + ("testLinuxTestSuiteIncludesAllTests", testLinuxTestSuiteIncludesAllTests) + ] + // MARK: Actual Request tests func testGetRepositories() { @@ -147,4 +160,17 @@ class RepositoryTests: XCTestCase { XCTAssertEqual(subject.cloneURL, "https://github.com/mietzmithut/Test.git") XCTAssertEqual(subject.size, 132) } + + func testLinuxTestSuiteIncludesAllTests() { + #if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) + let thisClass = type(of: self) + let linuxCount = thisClass.allTests.count + #if os(iOS) + let darwinCount = thisClass.defaultTestSuite.tests.count + #else + let darwinCount = thisClass.defaultTestSuite().tests.count + #endif + XCTAssertEqual(linuxCount, darwinCount, "\(darwinCount - linuxCount) tests are missing from allTests") + #endif + } } diff --git a/OctoKitTests/StarsTests.swift b/Tests/OctoKitTests/StarsTests.swift similarity index 74% rename from OctoKitTests/StarsTests.swift rename to Tests/OctoKitTests/StarsTests.swift index 11c43158..34002c86 100644 --- a/OctoKitTests/StarsTests.swift +++ b/Tests/OctoKitTests/StarsTests.swift @@ -2,6 +2,14 @@ import XCTest import OctoKit class StarsTests: XCTestCase { + static var allTests = [ + ("testGetStarredRepositories", testGetStarredRepositories), + ("testFailToGetStarredRepositories", testFailToGetStarredRepositories), + ("testGetUsersStarredRepositories", testGetUsersStarredRepositories), + ("testFailToGetUsersStarredRepositories", testFailToGetUsersStarredRepositories), + ("testLinuxTestSuiteIncludesAllTests", testLinuxTestSuiteIncludesAllTests) + ] + // MARK: Actual Request tests func testGetStarredRepositories() { @@ -63,4 +71,17 @@ class StarsTests: XCTestCase { XCTAssertNotNil(task) XCTAssertTrue(session.wasCalled) } + + func testLinuxTestSuiteIncludesAllTests() { + #if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) + let thisClass = type(of: self) + let linuxCount = thisClass.allTests.count + #if os(iOS) + let darwinCount = thisClass.defaultTestSuite.tests.count + #else + let darwinCount = thisClass.defaultTestSuite().tests.count + #endif + XCTAssertEqual(linuxCount, darwinCount, "\(darwinCount - linuxCount) tests are missing from allTests") + #endif + } } diff --git a/Tests/OctoKitTests/TestHelper.swift b/Tests/OctoKitTests/TestHelper.swift new file mode 100644 index 00000000..3ecab43c --- /dev/null +++ b/Tests/OctoKitTests/TestHelper.swift @@ -0,0 +1,58 @@ +import Foundation +import OctoKit + +internal class Helper { + internal class func stringFromFile(_ name: String) -> String? { + let path = jsonFilePath(resourceName: name) + + let string = try? String(contentsOfFile: path, encoding: String.Encoding.utf8) + return string + } + + internal class func JSONFromFile(_ name: String) -> Any { + let path = jsonFilePath(resourceName: name) + let data = try! Data(contentsOf: URL(fileURLWithPath: path)) + let dict: Any? = try? JSONSerialization.jsonObject(with: data, + options: JSONSerialization.ReadingOptions.mutableContainers) + return dict! + } + + internal class func codableFromFile(_ name: String, type: T.Type) -> T where T: Codable { + var path: String + let bundlePath = jsonFilePath(resourceName: name) + if FileManager.default.fileExists(atPath: bundlePath) { + path = bundlePath + } + else { + path = jsonFixturesFilePath(resourceName: name) + } + let data = try! Data(contentsOf: URL(fileURLWithPath: path)) + let decoder = JSONDecoder() + decoder.dateDecodingStrategy = .formatted(Time.rfc3339DateFormatter) + return try! decoder.decode(T.self, from: data) + } + + private class func jsonFilePath(resourceName: String) -> String { + #if os(Linux) + let currentDirectoryPath = FileManager.default.currentDirectoryPath + let path = currentDirectoryPath + "/Tests/OctoKitTests/" + resourceName + ".json" + #else + let bundle = Bundle(for: self) + let path = bundle.path(forResource: resourceName, ofType: "json")! + #endif + + return path + } + + private class func jsonFixturesFilePath(resourceName: String) -> String { + #if os(Linux) + let currentDirectoryPath = FileManager.default.currentDirectoryPath + let path = currentDirectoryPath + "/Tests/OctoKitTests/Fixtures/" + resourceName + ".json" + #else + let bundle = Bundle(path: "OctoKitTests/Fixtures") + let path = bundle!.path(forResource: resourceName, ofType: "json")! + #endif + + return path + } +} diff --git a/OctoKitTests/UserTests.swift b/Tests/OctoKitTests/UserTests.swift similarity index 81% rename from OctoKitTests/UserTests.swift rename to Tests/OctoKitTests/UserTests.swift index fd11aff1..3ffa2a87 100644 --- a/OctoKitTests/UserTests.swift +++ b/Tests/OctoKitTests/UserTests.swift @@ -2,6 +2,16 @@ import XCTest import OctoKit class UserTests: XCTestCase { + static var allTests = [ + ("testGetUser", testGetUser), + ("testFailingToGetUser", testFailingToGetUser), + ("testGettingAuthenticatedUser", testGettingAuthenticatedUser), + ("testFailToGetAuthenticatedUser", testFailToGetAuthenticatedUser), + ("testUserParsingFullUser", testUserParsingFullUser), + ("testUserParsingMinimalUser", testUserParsingMinimalUser), + ("testLinuxTestSuiteIncludesAllTests", testLinuxTestSuiteIncludesAllTests) + ] + // MARK: Actual Request tests func testGetUser() { @@ -100,4 +110,17 @@ class UserTests: XCTestCase { XCTAssertEqual(subject.numberOfPublicGists, 0) XCTAssertNil(subject.numberOfPrivateRepos) } + + func testLinuxTestSuiteIncludesAllTests() { + #if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) + let thisClass = type(of: self) + let linuxCount = thisClass.allTests.count + #if os(iOS) + let darwinCount = thisClass.defaultTestSuite.tests.count + #else + let darwinCount = thisClass.defaultTestSuite().tests.count + #endif + XCTAssertEqual(linuxCount, darwinCount, "\(darwinCount - linuxCount) tests are missing from allTests") + #endif + } } diff --git a/Tests/OctoKitTests/XCTestManifests.swift b/Tests/OctoKitTests/XCTestManifests.swift new file mode 100644 index 00000000..0eaa50e6 --- /dev/null +++ b/Tests/OctoKitTests/XCTestManifests.swift @@ -0,0 +1,24 @@ +// +// XCTestManifests.swift +// OctoKitTests +// +// Created by Franco Meloni on 07/11/2018. +// + +import XCTest + +#if !(os(macOS) || os(iOS) || os(tvOS) || os(watchOS)) +public func allTests() -> [XCTestCaseEntry] { + return [ + testCase(ConfigurationTests.allTests), + testCase(FollowTests.allTests), + testCase(IssueTests.allTests), + testCase(OctokitSwiftTests.allTests), + testCase(PublicKeyTests.allTests), + testCase(PullRequestTests.allTests), + testCase(RepositoryTests.allTests), + testCase(StarsTests.allTests), + testCase(UserTests.allTests) + ] +} +#endif diff --git a/OctoKitTests/pull_request.json b/Tests/OctoKitTests/pull_request.json similarity index 100% rename from OctoKitTests/pull_request.json rename to Tests/OctoKitTests/pull_request.json diff --git a/OctoKitTests/pull_requests.json b/Tests/OctoKitTests/pull_requests.json similarity index 100% rename from OctoKitTests/pull_requests.json rename to Tests/OctoKitTests/pull_requests.json diff --git a/OctoKitTests/users.json b/Tests/OctoKitTests/users.json similarity index 100% rename from OctoKitTests/users.json rename to Tests/OctoKitTests/users.json From 49d092698b0285cb92f44b345e61e4cce4312557 Mon Sep 17 00:00:00 2001 From: Orta Therox Date: Mon, 12 Nov 2018 17:20:35 -0500 Subject: [PATCH 137/302] Allow GitHub API calls to be discarded --- OctoKit/Follow.swift | 4 ++++ OctoKit/Issue.swift | 5 +++++ OctoKit/PullRequest.swift | 2 ++ OctoKit/Repositories.swift | 2 ++ OctoKit/Stars.swift | 2 ++ OctoKit/User.swift | 2 ++ 6 files changed, 17 insertions(+) diff --git a/OctoKit/Follow.swift b/OctoKit/Follow.swift index 84435bbc..98d379fe 100644 --- a/OctoKit/Follow.swift +++ b/OctoKit/Follow.swift @@ -8,6 +8,7 @@ public extension Octokit { - parameter session: RequestKitURLSession, defaults to NSURLSession.sharedSession() - parameter completion: Callback for the outcome of the fetch. */ + @discardableResult public func myFollowers(_ session: RequestKitURLSession = URLSession.shared, completion: @escaping (_ response: Response<[User]>) -> Void) -> URLSessionDataTaskProtocol? { let router = FollowRouter.readAuthenticatedFollowers(configuration) return router.load(session, expectedResultType: [User].self) { users, error in @@ -27,6 +28,7 @@ public extension Octokit { - parameter name: Name of the user - parameter completion: Callback for the outcome of the fetch. */ + @discardableResult public func followers(_ session: RequestKitURLSession = URLSession.shared, name: String, completion: @escaping (_ response: Response<[User]>) -> Void) -> URLSessionDataTaskProtocol? { let router = FollowRouter.readFollowers(name, configuration) return router.load(session, expectedResultType: [User].self) { users, error in @@ -45,6 +47,7 @@ public extension Octokit { - parameter session: RequestKitURLSession, defaults to NSURLSession.sharedSession() - parameter completion: Callback for the outcome of the fetch. */ + @discardableResult public func myFollowing(_ session: RequestKitURLSession = URLSession.shared, completion: @escaping (_ response: Response<[User]>) -> Void) -> URLSessionDataTaskProtocol? { let router = FollowRouter.readAuthenticatedFollowing(configuration) return router.load(session, expectedResultType: [User].self) { users, error in @@ -64,6 +67,7 @@ public extension Octokit { - parameter name: The name of the user - parameter completion: Callback for the outcome of the fetch. */ + @discardableResult public func following(_ session: RequestKitURLSession = URLSession.shared, name: String, completion: @escaping (_ response: Response<[User]>) -> Void) -> URLSessionDataTaskProtocol? { let router = FollowRouter.readFollowing(name, configuration) return router.load(session, expectedResultType: [User].self) { users, error in diff --git a/OctoKit/Issue.swift b/OctoKit/Issue.swift index d8b32bf8..bc37aa5d 100644 --- a/OctoKit/Issue.swift +++ b/OctoKit/Issue.swift @@ -69,6 +69,7 @@ public extension Octokit { - parameter perPage: Number of issues per page. `100` by default. - parameter completion: Callback for the outcome of the fetch. */ + @discardableResult public func myIssues(_ session: RequestKitURLSession = URLSession.shared, state: Openness = .Open, page: String = "1", perPage: String = "100", completion: @escaping (_ response: Response<[Issue]>) -> Void) -> URLSessionDataTaskProtocol? { let router = IssueRouter.readAuthenticatedIssues(configuration, page, perPage, state) return router.load(session, dateDecodingStrategy: .formatted(Time.rfc3339DateFormatter), expectedResultType: [Issue].self) { issues, error in @@ -90,6 +91,7 @@ public extension Octokit { - parameter number: The number of the issue. - parameter completion: Callback for the outcome of the fetch. */ + @discardableResult public func issue(_ session: RequestKitURLSession = URLSession.shared, owner: String, repository: String, number: Int, completion: @escaping (_ response: Response) -> Void) -> URLSessionDataTaskProtocol? { let router = IssueRouter.readIssue(configuration, owner, repository, number) return router.load(session, dateDecodingStrategy: .formatted(Time.rfc3339DateFormatter), expectedResultType: Issue.self) { issue, error in @@ -113,6 +115,7 @@ public extension Octokit { - parameter perPage: Number of issues per page. `100` by default. - parameter completion: Callback for the outcome of the fetch. */ + @discardableResult public func issues(_ session: RequestKitURLSession = URLSession.shared, owner: String, repository: String, state: Openness = .Open, page: String = "1", perPage: String = "100", completion: @escaping (_ response: Response<[Issue]>) -> Void) -> URLSessionDataTaskProtocol? { let router = IssueRouter.readIssues(configuration, owner, repository, page, perPage, state) return router.load(session, dateDecodingStrategy: .formatted(Time.rfc3339DateFormatter), expectedResultType: [Issue].self) { issues, error in @@ -136,6 +139,7 @@ public extension Octokit { - parameter assignee: The name of the user to assign the issue to. This parameter is ignored if the user lacks push access to the repository. - parameter completion: Callback for the issue that is created. */ + @discardableResult public func postIssue(_ session: RequestKitURLSession = URLSession.shared, owner: String, repository: String, title: String, body: String? = nil, assignee: String? = nil, completion: @escaping (_ response: Response) -> Void) -> URLSessionDataTaskProtocol? { let router = IssueRouter.postIssue(configuration, owner, repository, title, body, assignee) return router.post(session, expectedResultType: Issue.self) { issue, error in @@ -161,6 +165,7 @@ public extension Octokit { - parameter state: Whether the issue is open or closed. - parameter completion: Callback for the issue that is created. */ + @discardableResult public func patchIssue(_ session: RequestKitURLSession = URLSession.shared, owner: String, repository: String, number: Int, title: String? = nil, body: String? = nil, assignee: String? = nil, state: Openness? = nil, completion: @escaping (_ response: Response) -> Void) -> URLSessionDataTaskProtocol? { let router = IssueRouter.patchIssue(configuration, owner, repository, number, title, body, assignee, state) return router.post(session, expectedResultType: Issue.self) { issue, error in diff --git a/OctoKit/PullRequest.swift b/OctoKit/PullRequest.swift index 43c4e456..ec59b18c 100644 --- a/OctoKit/PullRequest.swift +++ b/OctoKit/PullRequest.swift @@ -68,6 +68,7 @@ public extension Octokit { - parameter number: The number of the PR to fetch. - parameter completion: Callback for the outcome of the fetch. */ + @discardableResult public func pullRequest(_ session: RequestKitURLSession = URLSession.shared, owner: String, repository: String, @@ -96,6 +97,7 @@ public extension Octokit { - parameter direction: The direction of the sort. - parameter completion: Callback for the outcome of the fetch. */ + @discardableResult public func pullRequests(_ session: RequestKitURLSession = URLSession.shared, owner: String, repository: String, diff --git a/OctoKit/Repositories.swift b/OctoKit/Repositories.swift index b718e926..106ecfa2 100644 --- a/OctoKit/Repositories.swift +++ b/OctoKit/Repositories.swift @@ -46,6 +46,7 @@ public extension Octokit { - parameter perPage: Number of repositories per page. `100` by default. - parameter completion: Callback for the outcome of the fetch. */ + @discardableResult public func repositories(_ session: RequestKitURLSession = URLSession.shared, owner: String? = nil, page: String = "1", perPage: String = "100", completion: @escaping (_ response: Response<[Repository]>) -> Void) -> URLSessionDataTaskProtocol? { let router = (owner != nil) ? RepositoryRouter.readRepositories(configuration, owner!, page, perPage) @@ -68,6 +69,7 @@ public extension Octokit { - parameter name: The name of the repository to fetch. - parameter completion: Callback for the outcome of the fetch. */ + @discardableResult public func repository(_ session: RequestKitURLSession = URLSession.shared, owner: String, name: String, completion: @escaping (_ response: Response) -> Void) -> URLSessionDataTaskProtocol? { let router = RepositoryRouter.readRepository(configuration, owner, name) return router.load(session, dateDecodingStrategy: .formatted(Time.rfc3339DateFormatter), expectedResultType: Repository.self) { repo, error in diff --git a/OctoKit/Stars.swift b/OctoKit/Stars.swift index d2be8d42..9dc4617c 100644 --- a/OctoKit/Stars.swift +++ b/OctoKit/Stars.swift @@ -9,6 +9,7 @@ public extension Octokit { - parameter name: The user who starred repositories. - parameter completion: Callback for the outcome of the fetch. */ + @discardableResult public func stars(_ session: RequestKitURLSession = URLSession.shared, name: String, completion: @escaping (_ response: Response<[Repository]>) -> Void) -> URLSessionDataTaskProtocol? { let router = StarsRouter.readStars(name, configuration) return router.load(session, dateDecodingStrategy: .formatted(Time.rfc3339DateFormatter), expectedResultType: [Repository].self) { repos, error in @@ -27,6 +28,7 @@ public extension Octokit { - parameter session: RequestKitURLSession, defaults to NSURLSession.sharedSession() - parameter completion: Callback for the outcome of the fetch. */ + @discardableResult public func myStars(_ session: RequestKitURLSession = URLSession.shared, completion: @escaping (_ response: Response<[Repository]>) -> Void) -> URLSessionDataTaskProtocol? { let router = StarsRouter.readAuthenticatedStars(configuration) return router.load(session, dateDecodingStrategy: .formatted(Time.rfc3339DateFormatter), expectedResultType: [Repository].self) { repos, error in diff --git a/OctoKit/User.swift b/OctoKit/User.swift index 43e0fae3..2344fb72 100644 --- a/OctoKit/User.swift +++ b/OctoKit/User.swift @@ -44,6 +44,7 @@ public extension Octokit { - parameter name: The name of the user or organization. - parameter completion: Callback for the outcome of the fetch. */ + @discardableResult public func user(_ session: RequestKitURLSession = URLSession.shared, name: String, completion: @escaping (_ response: Response) -> Void) -> URLSessionDataTaskProtocol? { let router = UserRouter.readUser(name, self.configuration) return router.load(session, expectedResultType: User.self) { user, error in @@ -62,6 +63,7 @@ public extension Octokit { - parameter session: RequestKitURLSession, defaults to NSURLSession.sharedSession() - parameter completion: Callback for the outcome of the fetch. */ + @discardableResult public func me(_ session: RequestKitURLSession = URLSession.shared, completion: @escaping (_ response: Response) -> Void) -> URLSessionDataTaskProtocol? { let router = UserRouter.readAuthenticatedUser(self.configuration) return router.load(session, expectedResultType: User.self) { user, error in From 5b02cdc209baf3896ca6f9a54b6dba578bd28580 Mon Sep 17 00:00:00 2001 From: Daniel Spindelbauer Date: Sun, 2 Dec 2018 18:06:05 +0000 Subject: [PATCH 138/302] Fixed GitHub spelling --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 7cd8ed15..02a8752b 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ let package = Package( ## Authentication -Octokit supports both, Github and Github Enterprise. +Octokit supports both, GitHub and GitHub Enterprise. Authentication is handled using Configurations. There are two types of Configurations, `TokenConfiguration` and `OAuthConfiguration`. @@ -38,7 +38,7 @@ You can initialize a new config for `github.com` as follows: let config = TokenConfiguration(token: "12345") ``` -or for Github Enterprise +or for GitHub Enterprise ```swift let config = TokenConfiguration("12345", url: "https://github.example.com/api/v3/") @@ -69,7 +69,7 @@ let config = OAuthConfiguration(token: "", secret: "", secret: "", scopes: ["repo", "read:org"]) From 891ba6de2f5cbd9eed3ac278f0787fc9a3fdbc86 Mon Sep 17 00:00:00 2001 From: Petr Pavlik Date: Tue, 11 Dec 2018 23:56:58 +0100 Subject: [PATCH 139/302] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 02a8752b..efa75eed 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ import PackageDescription let package = Package( name: "MyAwesomeApp", dependencies: [ - .Package(url: "https://github.com/nerdishbynature/octokit.swift", from: "0.8.0"), + .package(url: "https://github.com/nerdishbynature/octokit.swift", from: "0.9.0"), ] ) ``` From 2bf66aacea15628cdc17c51525bf09e0f34fdab5 Mon Sep 17 00:00:00 2001 From: stephen yao Date: Tue, 22 Jan 2019 08:00:31 +1100 Subject: [PATCH 140/302] Fixed an issue where the PullRequest htmlURL was always nil due to incorrect mapping from the JSON received --- OctoKit/PullRequest.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/OctoKit/PullRequest.swift b/OctoKit/PullRequest.swift index ec59b18c..507bf88a 100644 --- a/OctoKit/PullRequest.swift +++ b/OctoKit/PullRequest.swift @@ -41,6 +41,7 @@ open class PullRequest: Codable { case reviewCommentsURL = "review_comments_url" case commentsURL = "comments_url" case statusesURL = "statuses_url" + case htmlURL = "html_url" case number case state case title From 39a1707df3113063f90b69c20f8a361a668df22f Mon Sep 17 00:00:00 2001 From: Sergio Rubio Date: Fri, 29 Mar 2019 20:14:53 +0100 Subject: [PATCH 141/302] Bump Xcode, RequestKit and Swift versions So it's easier to build in modern macOS. --- Cartfile | 2 +- Cartfile.resolved | 2 +- OctoKit.xcodeproj/project.pbxproj | 124 +++++++++++++++----- Tests/OctoKitTests/ConfigurationTests.swift | 2 +- Tests/OctoKitTests/FollowTests.swift | 2 +- Tests/OctoKitTests/IssueTests.swift | 2 +- Tests/OctoKitTests/OctokitSwiftTests.swift | 2 +- Tests/OctoKitTests/PublicKeyTests.swift | 2 +- Tests/OctoKitTests/PullRequestTests.swift | 2 +- Tests/OctoKitTests/RepositoryTests.swift | 2 +- Tests/OctoKitTests/StarsTests.swift | 2 +- Tests/OctoKitTests/UserTests.swift | 2 +- 12 files changed, 108 insertions(+), 38 deletions(-) diff --git a/Cartfile b/Cartfile index 68459103..7fa463fe 100644 --- a/Cartfile +++ b/Cartfile @@ -1 +1 @@ -github "nerdishbynature/RequestKit" == 2.1.0 +github "nerdishbynature/RequestKit" == 2.3.0 diff --git a/Cartfile.resolved b/Cartfile.resolved index d812108f..1593817d 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1 +1 @@ -github "nerdishbynature/RequestKit" "2.1.0" +github "nerdishbynature/RequestKit" "2.3.0" diff --git a/OctoKit.xcodeproj/project.pbxproj b/OctoKit.xcodeproj/project.pbxproj index 9b53ebe0..618b2aa8 100644 --- a/OctoKit.xcodeproj/project.pbxproj +++ b/OctoKit.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 46; + objectVersion = 50; objects = { /* Begin PBXBuildFile section */ @@ -634,10 +634,11 @@ }; }; buildConfigurationList = F01C6F2F1A6429CC0072FA44 /* Build configuration list for PBXProject "OctoKit" */; - compatibilityVersion = "Xcode 3.2"; + compatibilityVersion = "Xcode 9.3"; developmentRegion = English; hasScannedForEncodings = 0; knownRegions = ( + English, en, Base, ); @@ -911,7 +912,12 @@ ); GCC_NO_COMMON_BLOCKS = YES; INFOPLIST_FILE = Tests/OctoKitTests/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks $(FRAMEWORK_SEARCH_PATHS)"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + "$(FRAMEWORK_SEARCH_PATHS)", + ); PRODUCT_BUNDLE_IDENTIFIER = com.nerdishbynature.OctoKitTests; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -932,11 +938,17 @@ ); GCC_NO_COMMON_BLOCKS = YES; INFOPLIST_FILE = Tests/OctoKitTests/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks $(FRAMEWORK_SEARCH_PATHS)"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + "$(FRAMEWORK_SEARCH_PATHS)", + ); PRODUCT_BUNDLE_IDENTIFIER = com.nerdishbynature.OctoKitTests; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; - SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; SWIFT_VERSION = 4.0; }; name = Release; @@ -963,7 +975,11 @@ ); INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; IPHONEOS_DEPLOYMENT_TARGET = 10.0; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_VERSION = 4.0; @@ -992,9 +1008,14 @@ GCC_NO_COMMON_BLOCKS = YES; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; IPHONEOS_DEPLOYMENT_TARGET = 10.0; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); SKIP_INSTALL = YES; - SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; @@ -1018,7 +1039,11 @@ ); GCC_NO_COMMON_BLOCKS = YES; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); SDKROOT = appletvos; SKIP_INSTALL = YES; TARGETED_DEVICE_FAMILY = 3; @@ -1044,10 +1069,15 @@ ); GCC_NO_COMMON_BLOCKS = YES; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); SDKROOT = appletvos; SKIP_INSTALL = YES; - SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; TARGETED_DEVICE_FAMILY = 3; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -1066,7 +1096,12 @@ ); GCC_NO_COMMON_BLOCKS = YES; INFOPLIST_FILE = Tests/OctoKitTests/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks $(FRAMEWORK_SEARCH_PATHS)"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + "$(FRAMEWORK_SEARCH_PATHS)", + ); PRODUCT_BUNDLE_IDENTIFIER = "com.nerdishbynature.OctoKit-tvOSTests"; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -1087,12 +1122,18 @@ ); GCC_NO_COMMON_BLOCKS = YES; INFOPLIST_FILE = Tests/OctoKitTests/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks $(FRAMEWORK_SEARCH_PATHS)"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + "$(FRAMEWORK_SEARCH_PATHS)", + ); PRODUCT_BUNDLE_IDENTIFIER = "com.nerdishbynature.OctoKit-tvOSTests"; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; SDKROOT = appletvos; - SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; }; name = Release; }; @@ -1114,11 +1155,15 @@ FRAMEWORK_VERSION = A; GCC_NO_COMMON_BLOCKS = YES; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + "@loader_path/Frameworks", + ); MACOSX_DEPLOYMENT_TARGET = 10.12; SDKROOT = macosx; SKIP_INSTALL = YES; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.2; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; }; @@ -1143,12 +1188,17 @@ FRAMEWORK_VERSION = A; GCC_NO_COMMON_BLOCKS = YES; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + "@loader_path/Frameworks", + ); MACOSX_DEPLOYMENT_TARGET = 10.12; SDKROOT = macosx; SKIP_INSTALL = YES; - SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 3.0; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + SWIFT_VERSION = 4.2; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; }; @@ -1166,11 +1216,16 @@ ); GCC_NO_COMMON_BLOCKS = YES; INFOPLIST_FILE = Tests/OctoKitTests/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks $(FRAMEWORK_SEARCH_PATHS)"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + "@loader_path/../Frameworks", + "$(FRAMEWORK_SEARCH_PATHS)", + ); PRODUCT_BUNDLE_IDENTIFIER = "com.nerdishbynature.OctoKit-MacTests"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = macosx; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.2; }; name = Debug; }; @@ -1187,12 +1242,18 @@ ); GCC_NO_COMMON_BLOCKS = YES; INFOPLIST_FILE = Tests/OctoKitTests/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks $(FRAMEWORK_SEARCH_PATHS)"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + "@loader_path/../Frameworks", + "$(FRAMEWORK_SEARCH_PATHS)", + ); PRODUCT_BUNDLE_IDENTIFIER = "com.nerdishbynature.OctoKit-MacTests"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = macosx; - SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 3.0; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + SWIFT_VERSION = 4.2; }; name = Release; }; @@ -1213,7 +1274,11 @@ ); GCC_NO_COMMON_BLOCKS = YES; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); SDKROOT = watchos; SKIP_INSTALL = YES; TARGETED_DEVICE_FAMILY = 4; @@ -1241,10 +1306,15 @@ ); GCC_NO_COMMON_BLOCKS = YES; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); SDKROOT = watchos; SKIP_INSTALL = YES; - SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; TARGETED_DEVICE_FAMILY = 4; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; diff --git a/Tests/OctoKitTests/ConfigurationTests.swift b/Tests/OctoKitTests/ConfigurationTests.swift index 508d015d..4a99c19a 100644 --- a/Tests/OctoKitTests/ConfigurationTests.swift +++ b/Tests/OctoKitTests/ConfigurationTests.swift @@ -66,7 +66,7 @@ class ConfigurationTests: XCTestCase { #if os(iOS) let darwinCount = thisClass.defaultTestSuite.tests.count #else - let darwinCount = thisClass.defaultTestSuite().tests.count + let darwinCount = thisClass.defaultTestSuite.tests.count #endif XCTAssertEqual(linuxCount, darwinCount, "\(darwinCount - linuxCount) tests are missing from allTests") #endif diff --git a/Tests/OctoKitTests/FollowTests.swift b/Tests/OctoKitTests/FollowTests.swift index 440cc125..c8ff8c73 100644 --- a/Tests/OctoKitTests/FollowTests.swift +++ b/Tests/OctoKitTests/FollowTests.swift @@ -141,7 +141,7 @@ class FollowTests: XCTestCase { #if os(iOS) let darwinCount = thisClass.defaultTestSuite.tests.count #else - let darwinCount = thisClass.defaultTestSuite().tests.count + let darwinCount = thisClass.defaultTestSuite.tests.count #endif XCTAssertEqual(linuxCount, darwinCount, "\(darwinCount - linuxCount) tests are missing from allTests") #endif diff --git a/Tests/OctoKitTests/IssueTests.swift b/Tests/OctoKitTests/IssueTests.swift index b4f5ab77..4847840c 100644 --- a/Tests/OctoKitTests/IssueTests.swift +++ b/Tests/OctoKitTests/IssueTests.swift @@ -62,7 +62,7 @@ class IssueTests: XCTestCase { #if os(iOS) let darwinCount = thisClass.defaultTestSuite.tests.count #else - let darwinCount = thisClass.defaultTestSuite().tests.count + let darwinCount = thisClass.defaultTestSuite.tests.count #endif XCTAssertEqual(linuxCount, darwinCount, "\(darwinCount - linuxCount) tests are missing from allTests") #endif diff --git a/Tests/OctoKitTests/OctokitSwiftTests.swift b/Tests/OctoKitTests/OctokitSwiftTests.swift index 73c08072..d17bfbf8 100644 --- a/Tests/OctoKitTests/OctokitSwiftTests.swift +++ b/Tests/OctoKitTests/OctokitSwiftTests.swift @@ -28,7 +28,7 @@ class OctokitSwiftTests: XCTestCase { #if os(iOS) let darwinCount = thisClass.defaultTestSuite.tests.count #else - let darwinCount = thisClass.defaultTestSuite().tests.count + let darwinCount = thisClass.defaultTestSuite.tests.count #endif XCTAssertEqual(linuxCount, darwinCount, "\(darwinCount - linuxCount) tests are missing from allTests") #endif diff --git a/Tests/OctoKitTests/PublicKeyTests.swift b/Tests/OctoKitTests/PublicKeyTests.swift index 65c038d3..27874c71 100644 --- a/Tests/OctoKitTests/PublicKeyTests.swift +++ b/Tests/OctoKitTests/PublicKeyTests.swift @@ -32,7 +32,7 @@ class PublicKeyTests: XCTestCase { #if os(iOS) let darwinCount = thisClass.defaultTestSuite.tests.count #else - let darwinCount = thisClass.defaultTestSuite().tests.count + let darwinCount = thisClass.defaultTestSuite.tests.count #endif XCTAssertEqual(linuxCount, darwinCount, "\(darwinCount - linuxCount) tests are missing from allTests") #endif diff --git a/Tests/OctoKitTests/PullRequestTests.swift b/Tests/OctoKitTests/PullRequestTests.swift index dcd2479e..60811939 100644 --- a/Tests/OctoKitTests/PullRequestTests.swift +++ b/Tests/OctoKitTests/PullRequestTests.swift @@ -57,7 +57,7 @@ class PullRequestTests: XCTestCase { #if os(iOS) let darwinCount = thisClass.defaultTestSuite.tests.count #else - let darwinCount = thisClass.defaultTestSuite().tests.count + let darwinCount = thisClass.defaultTestSuite.tests.count #endif XCTAssertEqual(linuxCount, darwinCount, "\(darwinCount - linuxCount) tests are missing from allTests") #endif diff --git a/Tests/OctoKitTests/RepositoryTests.swift b/Tests/OctoKitTests/RepositoryTests.swift index 39f1ef6e..deee6af3 100644 --- a/Tests/OctoKitTests/RepositoryTests.swift +++ b/Tests/OctoKitTests/RepositoryTests.swift @@ -168,7 +168,7 @@ class RepositoryTests: XCTestCase { #if os(iOS) let darwinCount = thisClass.defaultTestSuite.tests.count #else - let darwinCount = thisClass.defaultTestSuite().tests.count + let darwinCount = thisClass.defaultTestSuite.tests.count #endif XCTAssertEqual(linuxCount, darwinCount, "\(darwinCount - linuxCount) tests are missing from allTests") #endif diff --git a/Tests/OctoKitTests/StarsTests.swift b/Tests/OctoKitTests/StarsTests.swift index 34002c86..30bffec1 100644 --- a/Tests/OctoKitTests/StarsTests.swift +++ b/Tests/OctoKitTests/StarsTests.swift @@ -79,7 +79,7 @@ class StarsTests: XCTestCase { #if os(iOS) let darwinCount = thisClass.defaultTestSuite.tests.count #else - let darwinCount = thisClass.defaultTestSuite().tests.count + let darwinCount = thisClass.defaultTestSuite.tests.count #endif XCTAssertEqual(linuxCount, darwinCount, "\(darwinCount - linuxCount) tests are missing from allTests") #endif diff --git a/Tests/OctoKitTests/UserTests.swift b/Tests/OctoKitTests/UserTests.swift index 3ffa2a87..ed6e4bc8 100644 --- a/Tests/OctoKitTests/UserTests.swift +++ b/Tests/OctoKitTests/UserTests.swift @@ -118,7 +118,7 @@ class UserTests: XCTestCase { #if os(iOS) let darwinCount = thisClass.defaultTestSuite.tests.count #else - let darwinCount = thisClass.defaultTestSuite().tests.count + let darwinCount = thisClass.defaultTestSuite.tests.count #endif XCTAssertEqual(linuxCount, darwinCount, "\(darwinCount - linuxCount) tests are missing from allTests") #endif From 547261034717c72344b43d46e5ddd0bb4fd8603b Mon Sep 17 00:00:00 2001 From: Sergio Rubio Date: Fri, 29 Mar 2019 20:39:24 +0100 Subject: [PATCH 142/302] kill warning: public modifier is redundant --- OctoKit/Follow.swift | 8 ++++---- OctoKit/Issue.swift | 10 +++++----- OctoKit/PublicKey.swift | 2 +- OctoKit/PullRequest.swift | 4 ++-- OctoKit/Repositories.swift | 4 ++-- OctoKit/Stars.swift | 4 ++-- OctoKit/User.swift | 4 ++-- 7 files changed, 18 insertions(+), 18 deletions(-) diff --git a/OctoKit/Follow.swift b/OctoKit/Follow.swift index 98d379fe..33da5281 100644 --- a/OctoKit/Follow.swift +++ b/OctoKit/Follow.swift @@ -9,7 +9,7 @@ public extension Octokit { - parameter completion: Callback for the outcome of the fetch. */ @discardableResult - public func myFollowers(_ session: RequestKitURLSession = URLSession.shared, completion: @escaping (_ response: Response<[User]>) -> Void) -> URLSessionDataTaskProtocol? { + func myFollowers(_ session: RequestKitURLSession = URLSession.shared, completion: @escaping (_ response: Response<[User]>) -> Void) -> URLSessionDataTaskProtocol? { let router = FollowRouter.readAuthenticatedFollowers(configuration) return router.load(session, expectedResultType: [User].self) { users, error in if let error = error { @@ -29,7 +29,7 @@ public extension Octokit { - parameter completion: Callback for the outcome of the fetch. */ @discardableResult - public func followers(_ session: RequestKitURLSession = URLSession.shared, name: String, completion: @escaping (_ response: Response<[User]>) -> Void) -> URLSessionDataTaskProtocol? { + func followers(_ session: RequestKitURLSession = URLSession.shared, name: String, completion: @escaping (_ response: Response<[User]>) -> Void) -> URLSessionDataTaskProtocol? { let router = FollowRouter.readFollowers(name, configuration) return router.load(session, expectedResultType: [User].self) { users, error in if let error = error { @@ -48,7 +48,7 @@ public extension Octokit { - parameter completion: Callback for the outcome of the fetch. */ @discardableResult - public func myFollowing(_ session: RequestKitURLSession = URLSession.shared, completion: @escaping (_ response: Response<[User]>) -> Void) -> URLSessionDataTaskProtocol? { + func myFollowing(_ session: RequestKitURLSession = URLSession.shared, completion: @escaping (_ response: Response<[User]>) -> Void) -> URLSessionDataTaskProtocol? { let router = FollowRouter.readAuthenticatedFollowing(configuration) return router.load(session, expectedResultType: [User].self) { users, error in if let error = error { @@ -68,7 +68,7 @@ public extension Octokit { - parameter completion: Callback for the outcome of the fetch. */ @discardableResult - public func following(_ session: RequestKitURLSession = URLSession.shared, name: String, completion: @escaping (_ response: Response<[User]>) -> Void) -> URLSessionDataTaskProtocol? { + func following(_ session: RequestKitURLSession = URLSession.shared, name: String, completion: @escaping (_ response: Response<[User]>) -> Void) -> URLSessionDataTaskProtocol? { let router = FollowRouter.readFollowing(name, configuration) return router.load(session, expectedResultType: [User].self) { users, error in if let error = error { diff --git a/OctoKit/Issue.swift b/OctoKit/Issue.swift index bc37aa5d..2dab1191 100644 --- a/OctoKit/Issue.swift +++ b/OctoKit/Issue.swift @@ -70,7 +70,7 @@ public extension Octokit { - parameter completion: Callback for the outcome of the fetch. */ @discardableResult - public func myIssues(_ session: RequestKitURLSession = URLSession.shared, state: Openness = .Open, page: String = "1", perPage: String = "100", completion: @escaping (_ response: Response<[Issue]>) -> Void) -> URLSessionDataTaskProtocol? { + func myIssues(_ session: RequestKitURLSession = URLSession.shared, state: Openness = .Open, page: String = "1", perPage: String = "100", completion: @escaping (_ response: Response<[Issue]>) -> Void) -> URLSessionDataTaskProtocol? { let router = IssueRouter.readAuthenticatedIssues(configuration, page, perPage, state) return router.load(session, dateDecodingStrategy: .formatted(Time.rfc3339DateFormatter), expectedResultType: [Issue].self) { issues, error in if let error = error { @@ -92,7 +92,7 @@ public extension Octokit { - parameter completion: Callback for the outcome of the fetch. */ @discardableResult - public func issue(_ session: RequestKitURLSession = URLSession.shared, owner: String, repository: String, number: Int, completion: @escaping (_ response: Response) -> Void) -> URLSessionDataTaskProtocol? { + func issue(_ session: RequestKitURLSession = URLSession.shared, owner: String, repository: String, number: Int, completion: @escaping (_ response: Response) -> Void) -> URLSessionDataTaskProtocol? { let router = IssueRouter.readIssue(configuration, owner, repository, number) return router.load(session, dateDecodingStrategy: .formatted(Time.rfc3339DateFormatter), expectedResultType: Issue.self) { issue, error in if let error = error { @@ -116,7 +116,7 @@ public extension Octokit { - parameter completion: Callback for the outcome of the fetch. */ @discardableResult - public func issues(_ session: RequestKitURLSession = URLSession.shared, owner: String, repository: String, state: Openness = .Open, page: String = "1", perPage: String = "100", completion: @escaping (_ response: Response<[Issue]>) -> Void) -> URLSessionDataTaskProtocol? { + func issues(_ session: RequestKitURLSession = URLSession.shared, owner: String, repository: String, state: Openness = .Open, page: String = "1", perPage: String = "100", completion: @escaping (_ response: Response<[Issue]>) -> Void) -> URLSessionDataTaskProtocol? { let router = IssueRouter.readIssues(configuration, owner, repository, page, perPage, state) return router.load(session, dateDecodingStrategy: .formatted(Time.rfc3339DateFormatter), expectedResultType: [Issue].self) { issues, error in if let error = error { @@ -140,7 +140,7 @@ public extension Octokit { - parameter completion: Callback for the issue that is created. */ @discardableResult - public func postIssue(_ session: RequestKitURLSession = URLSession.shared, owner: String, repository: String, title: String, body: String? = nil, assignee: String? = nil, completion: @escaping (_ response: Response) -> Void) -> URLSessionDataTaskProtocol? { + func postIssue(_ session: RequestKitURLSession = URLSession.shared, owner: String, repository: String, title: String, body: String? = nil, assignee: String? = nil, completion: @escaping (_ response: Response) -> Void) -> URLSessionDataTaskProtocol? { let router = IssueRouter.postIssue(configuration, owner, repository, title, body, assignee) return router.post(session, expectedResultType: Issue.self) { issue, error in if let error = error { @@ -166,7 +166,7 @@ public extension Octokit { - parameter completion: Callback for the issue that is created. */ @discardableResult - public func patchIssue(_ session: RequestKitURLSession = URLSession.shared, owner: String, repository: String, number: Int, title: String? = nil, body: String? = nil, assignee: String? = nil, state: Openness? = nil, completion: @escaping (_ response: Response) -> Void) -> URLSessionDataTaskProtocol? { + func patchIssue(_ session: RequestKitURLSession = URLSession.shared, owner: String, repository: String, number: Int, title: String? = nil, body: String? = nil, assignee: String? = nil, state: Openness? = nil, completion: @escaping (_ response: Response) -> Void) -> URLSessionDataTaskProtocol? { let router = IssueRouter.patchIssue(configuration, owner, repository, number, title, body, assignee, state) return router.post(session, expectedResultType: Issue.self) { issue, error in if let error = error { diff --git a/OctoKit/PublicKey.swift b/OctoKit/PublicKey.swift index 1a1a364c..fca0a08f 100644 --- a/OctoKit/PublicKey.swift +++ b/OctoKit/PublicKey.swift @@ -4,7 +4,7 @@ import RequestKit // MARK: request public extension Octokit { - public func postPublicKey(_ session: RequestKitURLSession = URLSession.shared, publicKey: String, title: String, completion: @escaping (_ response: Response) -> Void) -> URLSessionDataTaskProtocol? { + func postPublicKey(_ session: RequestKitURLSession = URLSession.shared, publicKey: String, title: String, completion: @escaping (_ response: Response) -> Void) -> URLSessionDataTaskProtocol? { let router = PublicKeyRouter.postPublicKey(publicKey, title, configuration) return router.postJSON(session, expectedResultType: [String: AnyObject].self) { json, error in if let error = error { diff --git a/OctoKit/PullRequest.swift b/OctoKit/PullRequest.swift index 507bf88a..5eb2c74a 100644 --- a/OctoKit/PullRequest.swift +++ b/OctoKit/PullRequest.swift @@ -70,7 +70,7 @@ public extension Octokit { - parameter completion: Callback for the outcome of the fetch. */ @discardableResult - public func pullRequest(_ session: RequestKitURLSession = URLSession.shared, + func pullRequest(_ session: RequestKitURLSession = URLSession.shared, owner: String, repository: String, number: Int, @@ -99,7 +99,7 @@ public extension Octokit { - parameter completion: Callback for the outcome of the fetch. */ @discardableResult - public func pullRequests(_ session: RequestKitURLSession = URLSession.shared, + func pullRequests(_ session: RequestKitURLSession = URLSession.shared, owner: String, repository: String, base: String? = nil, diff --git a/OctoKit/Repositories.swift b/OctoKit/Repositories.swift index 106ecfa2..46f8a78a 100644 --- a/OctoKit/Repositories.swift +++ b/OctoKit/Repositories.swift @@ -47,7 +47,7 @@ public extension Octokit { - parameter completion: Callback for the outcome of the fetch. */ @discardableResult - public func repositories(_ session: RequestKitURLSession = URLSession.shared, owner: String? = nil, page: String = "1", perPage: String = "100", completion: @escaping (_ response: Response<[Repository]>) -> Void) -> URLSessionDataTaskProtocol? { + func repositories(_ session: RequestKitURLSession = URLSession.shared, owner: String? = nil, page: String = "1", perPage: String = "100", completion: @escaping (_ response: Response<[Repository]>) -> Void) -> URLSessionDataTaskProtocol? { let router = (owner != nil) ? RepositoryRouter.readRepositories(configuration, owner!, page, perPage) : RepositoryRouter.readAuthenticatedRepositories(configuration, page, perPage) @@ -70,7 +70,7 @@ public extension Octokit { - parameter completion: Callback for the outcome of the fetch. */ @discardableResult - public func repository(_ session: RequestKitURLSession = URLSession.shared, owner: String, name: String, completion: @escaping (_ response: Response) -> Void) -> URLSessionDataTaskProtocol? { + func repository(_ session: RequestKitURLSession = URLSession.shared, owner: String, name: String, completion: @escaping (_ response: Response) -> Void) -> URLSessionDataTaskProtocol? { let router = RepositoryRouter.readRepository(configuration, owner, name) return router.load(session, dateDecodingStrategy: .formatted(Time.rfc3339DateFormatter), expectedResultType: Repository.self) { repo, error in if let error = error { diff --git a/OctoKit/Stars.swift b/OctoKit/Stars.swift index 9dc4617c..6b724632 100644 --- a/OctoKit/Stars.swift +++ b/OctoKit/Stars.swift @@ -10,7 +10,7 @@ public extension Octokit { - parameter completion: Callback for the outcome of the fetch. */ @discardableResult - public func stars(_ session: RequestKitURLSession = URLSession.shared, name: String, completion: @escaping (_ response: Response<[Repository]>) -> Void) -> URLSessionDataTaskProtocol? { + func stars(_ session: RequestKitURLSession = URLSession.shared, name: String, completion: @escaping (_ response: Response<[Repository]>) -> Void) -> URLSessionDataTaskProtocol? { let router = StarsRouter.readStars(name, configuration) return router.load(session, dateDecodingStrategy: .formatted(Time.rfc3339DateFormatter), expectedResultType: [Repository].self) { repos, error in if let error = error { @@ -29,7 +29,7 @@ public extension Octokit { - parameter completion: Callback for the outcome of the fetch. */ @discardableResult - public func myStars(_ session: RequestKitURLSession = URLSession.shared, completion: @escaping (_ response: Response<[Repository]>) -> Void) -> URLSessionDataTaskProtocol? { + func myStars(_ session: RequestKitURLSession = URLSession.shared, completion: @escaping (_ response: Response<[Repository]>) -> Void) -> URLSessionDataTaskProtocol? { let router = StarsRouter.readAuthenticatedStars(configuration) return router.load(session, dateDecodingStrategy: .formatted(Time.rfc3339DateFormatter), expectedResultType: [Repository].self) { repos, error in if let error = error { diff --git a/OctoKit/User.swift b/OctoKit/User.swift index 2344fb72..4ae8303c 100644 --- a/OctoKit/User.swift +++ b/OctoKit/User.swift @@ -45,7 +45,7 @@ public extension Octokit { - parameter completion: Callback for the outcome of the fetch. */ @discardableResult - public func user(_ session: RequestKitURLSession = URLSession.shared, name: String, completion: @escaping (_ response: Response) -> Void) -> URLSessionDataTaskProtocol? { + func user(_ session: RequestKitURLSession = URLSession.shared, name: String, completion: @escaping (_ response: Response) -> Void) -> URLSessionDataTaskProtocol? { let router = UserRouter.readUser(name, self.configuration) return router.load(session, expectedResultType: User.self) { user, error in if let error = error { @@ -64,7 +64,7 @@ public extension Octokit { - parameter completion: Callback for the outcome of the fetch. */ @discardableResult - public func me(_ session: RequestKitURLSession = URLSession.shared, completion: @escaping (_ response: Response) -> Void) -> URLSessionDataTaskProtocol? { + func me(_ session: RequestKitURLSession = URLSession.shared, completion: @escaping (_ response: Response) -> Void) -> URLSessionDataTaskProtocol? { let router = UserRouter.readAuthenticatedUser(self.configuration) return router.load(session, expectedResultType: User.self) { user, error in if let error = error { From 7ffd5cc7b30ce92d0450fa06bc5b19954afae050 Mon Sep 17 00:00:00 2001 From: Sergio Rubio Date: Fri, 29 Mar 2019 20:45:47 +0100 Subject: [PATCH 143/302] Update to recommended settings --- OctoKit.xcodeproj/project.pbxproj | 8 +++++++- .../xcshareddata/xcschemes/OctoKit Mac.xcscheme | 4 +--- .../xcshareddata/xcschemes/OctoKit MacTests.xcscheme | 4 +--- .../xcshareddata/xcschemes/OctoKit tvOS.xcscheme | 4 +--- .../xcshareddata/xcschemes/OctoKit watchOS.xcscheme | 4 +--- OctoKit.xcodeproj/xcshareddata/xcschemes/OctoKit.xcscheme | 8 +++----- 6 files changed, 14 insertions(+), 18 deletions(-) diff --git a/OctoKit.xcodeproj/project.pbxproj b/OctoKit.xcodeproj/project.pbxproj index 618b2aa8..796cc705 100644 --- a/OctoKit.xcodeproj/project.pbxproj +++ b/OctoKit.xcodeproj/project.pbxproj @@ -599,7 +599,7 @@ attributes = { LastSwiftMigration = 0700; LastSwiftUpdateCheck = 0720; - LastUpgradeCheck = 0910; + LastUpgradeCheck = 1020; ORGANIZATIONNAME = "nerdish by nature"; TargetAttributes = { 234F4BA81BDDE31A00A58EF7 = { @@ -1326,6 +1326,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; @@ -1334,12 +1335,14 @@ CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; @@ -1382,6 +1385,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; @@ -1390,12 +1394,14 @@ CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; diff --git a/OctoKit.xcodeproj/xcshareddata/xcschemes/OctoKit Mac.xcscheme b/OctoKit.xcodeproj/xcshareddata/xcschemes/OctoKit Mac.xcscheme index 126e186b..8976613e 100644 --- a/OctoKit.xcodeproj/xcshareddata/xcschemes/OctoKit Mac.xcscheme +++ b/OctoKit.xcodeproj/xcshareddata/xcschemes/OctoKit Mac.xcscheme @@ -1,6 +1,6 @@ @@ -37,7 +36,6 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" - language = "" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" diff --git a/OctoKit.xcodeproj/xcshareddata/xcschemes/OctoKit.xcscheme b/OctoKit.xcodeproj/xcshareddata/xcschemes/OctoKit.xcscheme index 2fe7bdfe..83a695ec 100644 --- a/OctoKit.xcodeproj/xcshareddata/xcschemes/OctoKit.xcscheme +++ b/OctoKit.xcodeproj/xcshareddata/xcschemes/OctoKit.xcscheme @@ -1,6 +1,6 @@ + codeCoverageEnabled = "YES" + shouldUseLaunchSchemeArgsEnv = "YES"> @@ -57,7 +56,6 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" - language = "" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" From 1ccdd2abd3e0d5f5e8974fc0d8d6440146ed1e80 Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Sat, 30 Mar 2019 10:53:13 -0500 Subject: [PATCH 144/302] removed labelsURL from Issues since Github isn't returning a valid URL --- OctoKit.xcodeproj/project.pbxproj | 9 +++++ OctoKit/Issue.swift | 2 -- Tests/OctoKitTests/Fixtures/issue2.json | 45 +++++++++++++++++++++++++ Tests/OctoKitTests/IssueTests.swift | 14 ++++++++ 4 files changed, 68 insertions(+), 2 deletions(-) create mode 100644 Tests/OctoKitTests/Fixtures/issue2.json diff --git a/OctoKit.xcodeproj/project.pbxproj b/OctoKit.xcodeproj/project.pbxproj index 9b53ebe0..54888704 100644 --- a/OctoKit.xcodeproj/project.pbxproj +++ b/OctoKit.xcodeproj/project.pbxproj @@ -96,6 +96,9 @@ 23F6434F1C7AEF70000427B3 /* user_repos.json in Resources */ = {isa = PBXBuildFile; fileRef = 234F4BDC1BDDE44600A58EF7 /* user_repos.json */; }; 23F643501C7AEF72000427B3 /* users.json in Resources */ = {isa = PBXBuildFile; fileRef = E7EE59DF1BE139FD0012E3D2 /* users.json */; }; 23F643511C7AEF73000427B3 /* users.json in Resources */ = {isa = PBXBuildFile; fileRef = E7EE59DF1BE139FD0012E3D2 /* users.json */; }; + 515337A9224FC3760024544D /* issue2.json in Resources */ = {isa = PBXBuildFile; fileRef = 515337A8224FC3760024544D /* issue2.json */; }; + 515337AA224FC3760024544D /* issue2.json in Resources */ = {isa = PBXBuildFile; fileRef = 515337A8224FC3760024544D /* issue2.json */; }; + 515337AB224FC3760024544D /* issue2.json in Resources */ = {isa = PBXBuildFile; fileRef = 515337A8224FC3760024544D /* issue2.json */; }; BF8C711C2C6B42F9F323FCFE /* pull_requests.json in Resources */ = {isa = PBXBuildFile; fileRef = BF8C79B71035B425F7748392 /* pull_requests.json */; }; BF8C716EB8D5CA2CBBA745CB /* pull_request.json in Resources */ = {isa = PBXBuildFile; fileRef = BF8C77314F563A710F11E2F6 /* pull_request.json */; }; BF8C719220F02AC04EF3D137 /* PullRequestTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF8C76EB002802C14A08F63E /* PullRequestTests.swift */; }; @@ -238,6 +241,7 @@ 23CAF29A1C7AB619005011C4 /* OctoKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = OctoKit.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 23F6433C1C7AEEB6000427B3 /* Nocilla.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Nocilla.framework; path = Carthage/Build/tvOS/Nocilla.framework; sourceTree = ""; }; 23F643421C7AEF2F000427B3 /* Nocilla.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Nocilla.framework; path = Carthage/Build/Mac/Nocilla.framework; sourceTree = ""; }; + 515337A8224FC3760024544D /* issue2.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; name = issue2.json; path = Fixtures/issue2.json; sourceTree = ""; }; BF8C72B985869B84F46B4E9D /* Parameters.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Parameters.swift; sourceTree = ""; }; BF8C73E0EF3CEEBDEA68DD5E /* PullRequest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PullRequest.swift; sourceTree = ""; }; BF8C76EB002802C14A08F63E /* PullRequestTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PullRequestTests.swift; sourceTree = ""; }; @@ -342,6 +346,7 @@ isa = PBXGroup; children = ( DABBDE4F1C8C0C20008F57CD /* issue.json */, + 515337A8224FC3760024544D /* issue2.json */, E7EDEA6D1C871D0E006BAAF2 /* issues.json */, 234F4BD81BDDE44600A58EF7 /* public_key.json */, 234F4BD91BDDE44600A58EF7 /* repo.json */, @@ -638,6 +643,7 @@ developmentRegion = English; hasScannedForEncodings = 0; knownRegions = ( + English, en, Base, ); @@ -663,6 +669,7 @@ buildActionMask = 2147483647; files = ( E7EE59E01BE139FD0012E3D2 /* users.json in Resources */, + 515337A9224FC3760024544D /* issue2.json in Resources */, 234F4BDF1BDDE44600A58EF7 /* user_me.json in Resources */, 234F4BDD1BDDE44600A58EF7 /* public_key.json in Resources */, DABBDE501C8C0C20008F57CD /* issue.json in Resources */, @@ -694,6 +701,7 @@ buildActionMask = 2147483647; files = ( 23F643501C7AEF72000427B3 /* users.json in Resources */, + 515337AA224FC3760024544D /* issue2.json in Resources */, 23F6434A1C7AEF69000427B3 /* user_me.json in Resources */, 23F643461C7AEF63000427B3 /* public_key.json in Resources */, DABBDE511C8C0C20008F57CD /* issue.json in Resources */, @@ -718,6 +726,7 @@ buildActionMask = 2147483647; files = ( 23F643511C7AEF73000427B3 /* users.json in Resources */, + 515337AB224FC3760024544D /* issue2.json in Resources */, 23F6434B1C7AEF6A000427B3 /* user_me.json in Resources */, 23F643471C7AEF63000427B3 /* public_key.json in Resources */, DABBDE521C8C0C20008F57CD /* issue.json in Resources */, diff --git a/OctoKit/Issue.swift b/OctoKit/Issue.swift index bc37aa5d..bcb343b0 100644 --- a/OctoKit/Issue.swift +++ b/OctoKit/Issue.swift @@ -13,7 +13,6 @@ open class Issue: Codable { open private(set) var id: Int = -1 open var url: URL? open var repositoryURL: URL? - open var labelsURL: URL? open var commentsURL: URL? open var eventsURL: URL? open var htmlURL: URL? @@ -36,7 +35,6 @@ open class Issue: Codable { case id case url case repositoryURL = "repository_url" - case labelsURL = "labels_url" case commentsURL = "comments_url" case eventsURL = "events_url" case htmlURL = "html_url" diff --git a/Tests/OctoKitTests/Fixtures/issue2.json b/Tests/OctoKitTests/Fixtures/issue2.json new file mode 100644 index 00000000..0c5985ac --- /dev/null +++ b/Tests/OctoKitTests/Fixtures/issue2.json @@ -0,0 +1,45 @@ +{ + "url": "https://api.github.com/repos/vincode-io/FeedCompass/issues/36", + "repository_url": "https://api.github.com/repos/vincode-io/FeedCompass", + "labels_url": "https://api.github.com/repos/vincode-io/FeedCompass/issues/36/labels{/name}", + "comments_url": "https://api.github.com/repos/vincode-io/FeedCompass/issues/36/comments", + "events_url": "https://api.github.com/repos/vincode-io/FeedCompass/issues/36/events", + "html_url": "https://github.com/vincode-io/FeedCompass/issues/36", + "id": 427231234, + "node_id": "MDU6SXNzdWU0MjcyMzEyMzQ=", + "number": 36, + "title": "Add Request: Test File", + "user": { + "login": "vincode-io", + "id": 16448027, + "node_id": "MDQ6VXNlcjE2NDQ4MDI3", + "avatar_url": "https://avatars0.githubusercontent.com/u/16448027?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/vincode-io", + "html_url": "https://github.com/vincode-io", + "followers_url": "https://api.github.com/users/vincode-io/followers", + "following_url": "https://api.github.com/users/vincode-io/following{/other_user}", + "gists_url": "https://api.github.com/users/vincode-io/gists{/gist_id}", + "starred_url": "https://api.github.com/users/vincode-io/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/vincode-io/subscriptions", + "organizations_url": "https://api.github.com/users/vincode-io/orgs", + "repos_url": "https://api.github.com/users/vincode-io/repos", + "events_url": "https://api.github.com/users/vincode-io/events{/privacy}", + "received_events_url": "https://api.github.com/users/vincode-io/received_events", + "type": "User", + "site_admin": false + }, + "labels": [], + "state": "open", + "locked": false, + "assignee": null, + "assignees": [], + "milestone": null, + "comments": 0, + "created_at": "2019-03-30T02:16:35Z", + "updated_at": "2019-03-30T02:16:35Z", + "closed_at": null, + "author_association": "OWNER", + "body": "asdfad asdf asdf a", + "closed_by": null +} diff --git a/Tests/OctoKitTests/IssueTests.swift b/Tests/OctoKitTests/IssueTests.swift index b4f5ab77..bfd32286 100644 --- a/Tests/OctoKitTests/IssueTests.swift +++ b/Tests/OctoKitTests/IssueTests.swift @@ -6,6 +6,7 @@ class IssueTests: XCTestCase { ("testGetMyIssues", testGetMyIssues), ("testGetIssue", testGetIssue), ("testParsingIssue", testParsingIssue), + ("testParsingIssue2", testParsingIssue2), ("testLinuxTestSuiteIncludesAllTests", testLinuxTestSuiteIncludesAllTests) ] @@ -55,6 +56,19 @@ class IssueTests: XCTestCase { XCTAssertEqual(subject.locked, false) } + func testParsingIssue2() { + let subject = Helper.codableFromFile("issue2", type: Issue.self) + XCTAssertEqual(subject.user?.login, "vincode-io") + XCTAssertEqual(subject.user?.id, 16448027) + + XCTAssertEqual(subject.id, 427231234) + XCTAssertEqual(subject.number, 36) + XCTAssertEqual(subject.title, "Add Request: Test File") + XCTAssertEqual(subject.htmlURL, URL(string: "https://github.com/vincode-io/FeedCompass/issues/36")) + XCTAssertEqual(subject.state, Openness.Open) + XCTAssertEqual(subject.locked, false) + } + func testLinuxTestSuiteIncludesAllTests() { #if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) let thisClass = type(of: self) From 6895e251ff28c1b22a70acb7f754d63fcdebab6f Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Sat, 30 Mar 2019 10:57:42 -0500 Subject: [PATCH 145/302] updated to v4 of swift compiler since v3 is no longer supported --- OctoKit.xcodeproj/project.pbxproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OctoKit.xcodeproj/project.pbxproj b/OctoKit.xcodeproj/project.pbxproj index 54888704..9d33125b 100644 --- a/OctoKit.xcodeproj/project.pbxproj +++ b/OctoKit.xcodeproj/project.pbxproj @@ -1313,7 +1313,7 @@ PRODUCT_NAME = OctoKit; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; }; name = Debug; }; @@ -1360,7 +1360,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.nerdishbynature.OctoKit; PRODUCT_NAME = OctoKit; SDKROOT = iphoneos; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; VALIDATE_PRODUCT = YES; }; name = Release; From 6996c2732b8a2f2e7de254641619de1d3275dc44 Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Sat, 30 Mar 2019 11:00:36 -0500 Subject: [PATCH 146/302] updated to v4 of swift compiler since v3 is no longer supported --- OctoKit.xcodeproj/project.pbxproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OctoKit.xcodeproj/project.pbxproj b/OctoKit.xcodeproj/project.pbxproj index 9d33125b..9cd59051 100644 --- a/OctoKit.xcodeproj/project.pbxproj +++ b/OctoKit.xcodeproj/project.pbxproj @@ -1127,7 +1127,7 @@ MACOSX_DEPLOYMENT_TARGET = 10.12; SDKROOT = macosx; SKIP_INSTALL = YES; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; }; @@ -1157,7 +1157,7 @@ SDKROOT = macosx; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; }; From 582201af859ce7bec8dc4b84c4e7fef0c8114da6 Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Sat, 30 Mar 2019 11:45:25 -0500 Subject: [PATCH 147/302] upgraded to RequestKit 2.3 so that we could resolve a decoding bug when posting issues --- Cartfile | 2 +- Cartfile.resolved | 2 +- OctoKit/Issue.swift | 4 +++- Tests/OctoKitTests/IssueTests.swift | 15 +++++++++++++++ 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/Cartfile b/Cartfile index 68459103..7fa463fe 100644 --- a/Cartfile +++ b/Cartfile @@ -1 +1 @@ -github "nerdishbynature/RequestKit" == 2.1.0 +github "nerdishbynature/RequestKit" == 2.3.0 diff --git a/Cartfile.resolved b/Cartfile.resolved index d812108f..1593817d 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1 +1 @@ -github "nerdishbynature/RequestKit" "2.1.0" +github "nerdishbynature/RequestKit" "2.3.0" diff --git a/OctoKit/Issue.swift b/OctoKit/Issue.swift index bcb343b0..9aeed0b3 100644 --- a/OctoKit/Issue.swift +++ b/OctoKit/Issue.swift @@ -140,7 +140,9 @@ public extension Octokit { @discardableResult public func postIssue(_ session: RequestKitURLSession = URLSession.shared, owner: String, repository: String, title: String, body: String? = nil, assignee: String? = nil, completion: @escaping (_ response: Response) -> Void) -> URLSessionDataTaskProtocol? { let router = IssueRouter.postIssue(configuration, owner, repository, title, body, assignee) - return router.post(session, expectedResultType: Issue.self) { issue, error in + let decoder = JSONDecoder() + decoder.dateDecodingStrategy = .formatted(Time.rfc3339DateFormatter) + return router.post(session, decoder: decoder, expectedResultType: Issue.self) { issue, error in if let error = error { completion(Response.failure(error)) } else { diff --git a/Tests/OctoKitTests/IssueTests.swift b/Tests/OctoKitTests/IssueTests.swift index bfd32286..aeab06ee 100644 --- a/Tests/OctoKitTests/IssueTests.swift +++ b/Tests/OctoKitTests/IssueTests.swift @@ -5,6 +5,7 @@ class IssueTests: XCTestCase { static var allTests = [ ("testGetMyIssues", testGetMyIssues), ("testGetIssue", testGetIssue), + ("testPostIssue", testGetIssue), ("testParsingIssue", testParsingIssue), ("testParsingIssue2", testParsingIssue2), ("testLinuxTestSuiteIncludesAllTests", testLinuxTestSuiteIncludesAllTests) @@ -41,6 +42,20 @@ class IssueTests: XCTestCase { XCTAssertTrue(session.wasCalled) } + func testPostIssue() { + let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/repos/octocat/Hello-World/issues", expectedHTTPMethod: "POST", jsonFile: "issue2", statusCode: 200) + let task = Octokit().postIssue(session, owner: "octocat", repository: "Hello-World", title: "Title", body: "Body") { response in + switch response { + case .success(let issue): + XCTAssertEqual(issue.number, 36) + case .failure: + XCTAssert(false, "should not get an error") + } + } + XCTAssertNotNil(task) + XCTAssertTrue(session.wasCalled) + } + // MARK: Model Tests func testParsingIssue() { From 92cb50812885c290af0a44d1f7611889b004800e Mon Sep 17 00:00:00 2001 From: Sergio Rubio Date: Sun, 31 Mar 2019 13:46:12 +0200 Subject: [PATCH 148/302] Update tvOS target to Swift 4.2 --- OctoKit.xcodeproj/project.pbxproj | 2 ++ 1 file changed, 2 insertions(+) diff --git a/OctoKit.xcodeproj/project.pbxproj b/OctoKit.xcodeproj/project.pbxproj index 796cc705..8c9399d5 100644 --- a/OctoKit.xcodeproj/project.pbxproj +++ b/OctoKit.xcodeproj/project.pbxproj @@ -1046,6 +1046,7 @@ ); SDKROOT = appletvos; SKIP_INSTALL = YES; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = 3; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -1078,6 +1079,7 @@ SKIP_INSTALL = YES; SWIFT_COMPILATION_MODE = wholemodule; SWIFT_OPTIMIZATION_LEVEL = "-O"; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = 3; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; From 003dcbfc450999c36014aa00410432654690a650 Mon Sep 17 00:00:00 2001 From: Sergio Rubio Date: Sun, 31 Mar 2019 14:05:26 +0200 Subject: [PATCH 149/302] Missed some Swift version bumps --- OctoKit.xcodeproj/project.pbxproj | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/OctoKit.xcodeproj/project.pbxproj b/OctoKit.xcodeproj/project.pbxproj index 8c9399d5..2cf77fe8 100644 --- a/OctoKit.xcodeproj/project.pbxproj +++ b/OctoKit.xcodeproj/project.pbxproj @@ -921,7 +921,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.nerdishbynature.OctoKitTests; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; }; name = Debug; }; @@ -949,7 +949,7 @@ PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_COMPILATION_MODE = wholemodule; SWIFT_OPTIMIZATION_LEVEL = "-O"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; }; name = Release; }; @@ -982,7 +982,7 @@ ); SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -1016,7 +1016,7 @@ SKIP_INSTALL = YES; SWIFT_COMPILATION_MODE = wholemodule; SWIFT_OPTIMIZATION_LEVEL = "-O"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -1108,6 +1108,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; SDKROOT = appletvos; + SWIFT_VERSION = 4.2; }; name = Debug; }; @@ -1136,6 +1137,7 @@ SDKROOT = appletvos; SWIFT_COMPILATION_MODE = wholemodule; SWIFT_OPTIMIZATION_LEVEL = "-O"; + SWIFT_VERSION = 4.2; }; name = Release; }; @@ -1283,6 +1285,7 @@ ); SDKROOT = watchos; SKIP_INSTALL = YES; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = 4; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -1317,6 +1320,7 @@ SKIP_INSTALL = YES; SWIFT_COMPILATION_MODE = wholemodule; SWIFT_OPTIMIZATION_LEVEL = "-O"; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = 4; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; From 9b7b3e0af108f9b72f6e3ec6f42d6c842578fae4 Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Sun, 31 Mar 2019 11:18:40 -0500 Subject: [PATCH 150/302] changed project defaults to use spaces instead of tabs --- OctoKit.xcodeproj/project.pbxproj | 1 + 1 file changed, 1 insertion(+) diff --git a/OctoKit.xcodeproj/project.pbxproj b/OctoKit.xcodeproj/project.pbxproj index 2292fa84..f11824aa 100644 --- a/OctoKit.xcodeproj/project.pbxproj +++ b/OctoKit.xcodeproj/project.pbxproj @@ -414,6 +414,7 @@ B975D5A3F8B0384EFB0C5863 /* Frameworks */, ); sourceTree = ""; + usesTabs = 0; }; F01C6F351A6429CC0072FA44 /* Products */ = { isa = PBXGroup; From 0ede1dddaf356d0288f5edbde911798eada7d96f Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Sun, 31 Mar 2019 11:33:20 -0500 Subject: [PATCH 151/302] Re-added labelsURL and changed tabs to spaces. --- OctoKit/Issue.swift | 8 ++- Tests/OctoKitTests/Fixtures/issue2.json | 86 ++++++++++++------------- Tests/OctoKitTests/IssueTests.swift | 58 ++++++++--------- 3 files changed, 77 insertions(+), 75 deletions(-) diff --git a/OctoKit/Issue.swift b/OctoKit/Issue.swift index 681b830b..57fc5862 100644 --- a/OctoKit/Issue.swift +++ b/OctoKit/Issue.swift @@ -13,6 +13,8 @@ open class Issue: Codable { open private(set) var id: Int = -1 open var url: URL? open var repositoryURL: URL? + @available(*, deprecated) + open var labelsURL: URL? open var commentsURL: URL? open var eventsURL: URL? open var htmlURL: URL? @@ -140,9 +142,9 @@ public extension Octokit { @discardableResult func postIssue(_ session: RequestKitURLSession = URLSession.shared, owner: String, repository: String, title: String, body: String? = nil, assignee: String? = nil, completion: @escaping (_ response: Response) -> Void) -> URLSessionDataTaskProtocol? { let router = IssueRouter.postIssue(configuration, owner, repository, title, body, assignee) - let decoder = JSONDecoder() - decoder.dateDecodingStrategy = .formatted(Time.rfc3339DateFormatter) - return router.post(session, decoder: decoder, expectedResultType: Issue.self) { issue, error in + let decoder = JSONDecoder() + decoder.dateDecodingStrategy = .formatted(Time.rfc3339DateFormatter) + return router.post(session, decoder: decoder, expectedResultType: Issue.self) { issue, error in if let error = error { completion(Response.failure(error)) } else { diff --git a/Tests/OctoKitTests/Fixtures/issue2.json b/Tests/OctoKitTests/Fixtures/issue2.json index 0c5985ac..76290a43 100644 --- a/Tests/OctoKitTests/Fixtures/issue2.json +++ b/Tests/OctoKitTests/Fixtures/issue2.json @@ -1,45 +1,45 @@ { - "url": "https://api.github.com/repos/vincode-io/FeedCompass/issues/36", - "repository_url": "https://api.github.com/repos/vincode-io/FeedCompass", - "labels_url": "https://api.github.com/repos/vincode-io/FeedCompass/issues/36/labels{/name}", - "comments_url": "https://api.github.com/repos/vincode-io/FeedCompass/issues/36/comments", - "events_url": "https://api.github.com/repos/vincode-io/FeedCompass/issues/36/events", - "html_url": "https://github.com/vincode-io/FeedCompass/issues/36", - "id": 427231234, - "node_id": "MDU6SXNzdWU0MjcyMzEyMzQ=", - "number": 36, - "title": "Add Request: Test File", - "user": { - "login": "vincode-io", - "id": 16448027, - "node_id": "MDQ6VXNlcjE2NDQ4MDI3", - "avatar_url": "https://avatars0.githubusercontent.com/u/16448027?v=4", - "gravatar_id": "", - "url": "https://api.github.com/users/vincode-io", - "html_url": "https://github.com/vincode-io", - "followers_url": "https://api.github.com/users/vincode-io/followers", - "following_url": "https://api.github.com/users/vincode-io/following{/other_user}", - "gists_url": "https://api.github.com/users/vincode-io/gists{/gist_id}", - "starred_url": "https://api.github.com/users/vincode-io/starred{/owner}{/repo}", - "subscriptions_url": "https://api.github.com/users/vincode-io/subscriptions", - "organizations_url": "https://api.github.com/users/vincode-io/orgs", - "repos_url": "https://api.github.com/users/vincode-io/repos", - "events_url": "https://api.github.com/users/vincode-io/events{/privacy}", - "received_events_url": "https://api.github.com/users/vincode-io/received_events", - "type": "User", - "site_admin": false - }, - "labels": [], - "state": "open", - "locked": false, - "assignee": null, - "assignees": [], - "milestone": null, - "comments": 0, - "created_at": "2019-03-30T02:16:35Z", - "updated_at": "2019-03-30T02:16:35Z", - "closed_at": null, - "author_association": "OWNER", - "body": "asdfad asdf asdf a", - "closed_by": null + "url": "https://api.github.com/repos/vincode-io/FeedCompass/issues/36", + "repository_url": "https://api.github.com/repos/vincode-io/FeedCompass", + "labels_url": "https://api.github.com/repos/vincode-io/FeedCompass/issues/36/labels{/name}", + "comments_url": "https://api.github.com/repos/vincode-io/FeedCompass/issues/36/comments", + "events_url": "https://api.github.com/repos/vincode-io/FeedCompass/issues/36/events", + "html_url": "https://github.com/vincode-io/FeedCompass/issues/36", + "id": 427231234, + "node_id": "MDU6SXNzdWU0MjcyMzEyMzQ=", + "number": 36, + "title": "Add Request: Test File", + "user": { + "login": "vincode-io", + "id": 16448027, + "node_id": "MDQ6VXNlcjE2NDQ4MDI3", + "avatar_url": "https://avatars0.githubusercontent.com/u/16448027?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/vincode-io", + "html_url": "https://github.com/vincode-io", + "followers_url": "https://api.github.com/users/vincode-io/followers", + "following_url": "https://api.github.com/users/vincode-io/following{/other_user}", + "gists_url": "https://api.github.com/users/vincode-io/gists{/gist_id}", + "starred_url": "https://api.github.com/users/vincode-io/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/vincode-io/subscriptions", + "organizations_url": "https://api.github.com/users/vincode-io/orgs", + "repos_url": "https://api.github.com/users/vincode-io/repos", + "events_url": "https://api.github.com/users/vincode-io/events{/privacy}", + "received_events_url": "https://api.github.com/users/vincode-io/received_events", + "type": "User", + "site_admin": false + }, + "labels": [], + "state": "open", + "locked": false, + "assignee": null, + "assignees": [], + "milestone": null, + "comments": 0, + "created_at": "2019-03-30T02:16:35Z", + "updated_at": "2019-03-30T02:16:35Z", + "closed_at": null, + "author_association": "OWNER", + "body": "asdfad asdf asdf a", + "closed_by": null } diff --git a/Tests/OctoKitTests/IssueTests.swift b/Tests/OctoKitTests/IssueTests.swift index 6a7122da..11c6d546 100644 --- a/Tests/OctoKitTests/IssueTests.swift +++ b/Tests/OctoKitTests/IssueTests.swift @@ -5,9 +5,9 @@ class IssueTests: XCTestCase { static var allTests = [ ("testGetMyIssues", testGetMyIssues), ("testGetIssue", testGetIssue), - ("testPostIssue", testGetIssue), + ("testPostIssue", testGetIssue), ("testParsingIssue", testParsingIssue), - ("testParsingIssue2", testParsingIssue2), + ("testParsingIssue2", testParsingIssue2), ("testLinuxTestSuiteIncludesAllTests", testLinuxTestSuiteIncludesAllTests) ] @@ -42,20 +42,20 @@ class IssueTests: XCTestCase { XCTAssertTrue(session.wasCalled) } - func testPostIssue() { - let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/repos/octocat/Hello-World/issues", expectedHTTPMethod: "POST", jsonFile: "issue2", statusCode: 200) - let task = Octokit().postIssue(session, owner: "octocat", repository: "Hello-World", title: "Title", body: "Body") { response in - switch response { - case .success(let issue): - XCTAssertEqual(issue.number, 36) - case .failure: - XCTAssert(false, "should not get an error") - } - } - XCTAssertNotNil(task) - XCTAssertTrue(session.wasCalled) - } - + func testPostIssue() { + let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/repos/octocat/Hello-World/issues", expectedHTTPMethod: "POST", jsonFile: "issue2", statusCode: 200) + let task = Octokit().postIssue(session, owner: "octocat", repository: "Hello-World", title: "Title", body: "Body") { response in + switch response { + case .success(let issue): + XCTAssertEqual(issue.number, 36) + case .failure: + XCTAssert(false, "should not get an error") + } + } + XCTAssertNotNil(task) + XCTAssertTrue(session.wasCalled) + } + // MARK: Model Tests func testParsingIssue() { @@ -71,19 +71,19 @@ class IssueTests: XCTestCase { XCTAssertEqual(subject.locked, false) } - func testParsingIssue2() { - let subject = Helper.codableFromFile("issue2", type: Issue.self) - XCTAssertEqual(subject.user?.login, "vincode-io") - XCTAssertEqual(subject.user?.id, 16448027) - - XCTAssertEqual(subject.id, 427231234) - XCTAssertEqual(subject.number, 36) - XCTAssertEqual(subject.title, "Add Request: Test File") - XCTAssertEqual(subject.htmlURL, URL(string: "https://github.com/vincode-io/FeedCompass/issues/36")) - XCTAssertEqual(subject.state, Openness.Open) - XCTAssertEqual(subject.locked, false) - } - + func testParsingIssue2() { + let subject = Helper.codableFromFile("issue2", type: Issue.self) + XCTAssertEqual(subject.user?.login, "vincode-io") + XCTAssertEqual(subject.user?.id, 16448027) + + XCTAssertEqual(subject.id, 427231234) + XCTAssertEqual(subject.number, 36) + XCTAssertEqual(subject.title, "Add Request: Test File") + XCTAssertEqual(subject.htmlURL, URL(string: "https://github.com/vincode-io/FeedCompass/issues/36")) + XCTAssertEqual(subject.state, Openness.Open) + XCTAssertEqual(subject.locked, false) + } + func testLinuxTestSuiteIncludesAllTests() { #if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) let thisClass = type(of: self) From 0a9dcc6131f0e7a1893da95786901a3efa58bf79 Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Sun, 31 Mar 2019 18:19:50 -0500 Subject: [PATCH 152/302] Added initial support for Github Gists. --- OctoKit.xcodeproj/project.pbxproj | 22 +++ OctoKit/File.swift | 23 ++++ OctoKit/Gist.swift | 214 ++++++++++++++++++++++++++++++ 3 files changed, 259 insertions(+) create mode 100644 OctoKit/File.swift create mode 100644 OctoKit/Gist.swift diff --git a/OctoKit.xcodeproj/project.pbxproj b/OctoKit.xcodeproj/project.pbxproj index 9b53ebe0..f4ca72c1 100644 --- a/OctoKit.xcodeproj/project.pbxproj +++ b/OctoKit.xcodeproj/project.pbxproj @@ -96,6 +96,14 @@ 23F6434F1C7AEF70000427B3 /* user_repos.json in Resources */ = {isa = PBXBuildFile; fileRef = 234F4BDC1BDDE44600A58EF7 /* user_repos.json */; }; 23F643501C7AEF72000427B3 /* users.json in Resources */ = {isa = PBXBuildFile; fileRef = E7EE59DF1BE139FD0012E3D2 /* users.json */; }; 23F643511C7AEF73000427B3 /* users.json in Resources */ = {isa = PBXBuildFile; fileRef = E7EE59DF1BE139FD0012E3D2 /* users.json */; }; + 515337C2225166600024544D /* Gist.swift in Sources */ = {isa = PBXBuildFile; fileRef = 515337C1225166600024544D /* Gist.swift */; }; + 515337C4225179FB0024544D /* File.swift in Sources */ = {isa = PBXBuildFile; fileRef = 515337C3225179FB0024544D /* File.swift */; }; + 515337C5225179FB0024544D /* File.swift in Sources */ = {isa = PBXBuildFile; fileRef = 515337C3225179FB0024544D /* File.swift */; }; + 515337C6225179FB0024544D /* File.swift in Sources */ = {isa = PBXBuildFile; fileRef = 515337C3225179FB0024544D /* File.swift */; }; + 515337C7225179FB0024544D /* File.swift in Sources */ = {isa = PBXBuildFile; fileRef = 515337C3225179FB0024544D /* File.swift */; }; + 515337C822517A060024544D /* Gist.swift in Sources */ = {isa = PBXBuildFile; fileRef = 515337C1225166600024544D /* Gist.swift */; }; + 515337C922517A070024544D /* Gist.swift in Sources */ = {isa = PBXBuildFile; fileRef = 515337C1225166600024544D /* Gist.swift */; }; + 515337CA22517A0B0024544D /* Gist.swift in Sources */ = {isa = PBXBuildFile; fileRef = 515337C1225166600024544D /* Gist.swift */; }; BF8C711C2C6B42F9F323FCFE /* pull_requests.json in Resources */ = {isa = PBXBuildFile; fileRef = BF8C79B71035B425F7748392 /* pull_requests.json */; }; BF8C716EB8D5CA2CBBA745CB /* pull_request.json in Resources */ = {isa = PBXBuildFile; fileRef = BF8C77314F563A710F11E2F6 /* pull_request.json */; }; BF8C719220F02AC04EF3D137 /* PullRequestTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF8C76EB002802C14A08F63E /* PullRequestTests.swift */; }; @@ -238,6 +246,8 @@ 23CAF29A1C7AB619005011C4 /* OctoKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = OctoKit.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 23F6433C1C7AEEB6000427B3 /* Nocilla.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Nocilla.framework; path = Carthage/Build/tvOS/Nocilla.framework; sourceTree = ""; }; 23F643421C7AEF2F000427B3 /* Nocilla.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Nocilla.framework; path = Carthage/Build/Mac/Nocilla.framework; sourceTree = ""; }; + 515337C1225166600024544D /* Gist.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Gist.swift; sourceTree = ""; }; + 515337C3225179FB0024544D /* File.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = File.swift; sourceTree = ""; }; BF8C72B985869B84F46B4E9D /* Parameters.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Parameters.swift; sourceTree = ""; }; BF8C73E0EF3CEEBDEA68DD5E /* PullRequest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PullRequest.swift; sourceTree = ""; }; BF8C76EB002802C14A08F63E /* PullRequestTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PullRequestTests.swift; sourceTree = ""; }; @@ -360,7 +370,9 @@ children = ( 239BE7CD1B8C47A100D2CE22 /* OctoKit.h */, 23B267851BDDD756003887E3 /* Configuration.swift */, + 515337C3225179FB0024544D /* File.swift */, E7EE59DB1BE119110012E3D2 /* Follow.swift */, + 515337C1225166600024544D /* Gist.swift */, E7EDEA691C871CEB006BAAF2 /* Issue.swift */, DAEFC58F1C83D85100CF3785 /* Label.swift */, DAEFC5941C83EF0D00CF3785 /* Milestone.swift */, @@ -409,6 +421,7 @@ B975D5A3F8B0384EFB0C5863 /* Frameworks */, ); sourceTree = ""; + usesTabs = 0; }; F01C6F351A6429CC0072FA44 /* Products */ = { isa = PBXGroup; @@ -638,6 +651,7 @@ developmentRegion = English; hasScannedForEncodings = 0; knownRegions = ( + English, en, Base, ); @@ -767,6 +781,8 @@ E7EE59D81BDFEFB30012E3D2 /* Stars.swift in Sources */, 23B2678D1BDDD756003887E3 /* Repositories.swift in Sources */, F8711EA21BFCAE9F005DDACA /* Time.swift in Sources */, + 515337C4225179FB0024544D /* File.swift in Sources */, + 515337C2225166600024544D /* Gist.swift in Sources */, 23B2678C1BDDD756003887E3 /* PublicKey.swift in Sources */, 23B2678E1BDDD756003887E3 /* User.swift in Sources */, 237F91E41E5AEC82005FAA6B /* URL+URLParameters.swift in Sources */, @@ -793,7 +809,9 @@ 237F91E51E5AEC87005FAA6B /* URL+URLParameters.swift in Sources */, DAEFC5961C83EF0D00CF3785 /* Milestone.swift in Sources */, 23CAF2A81C7AB6C6005011C4 /* Octokit.swift in Sources */, + 515337C5225179FB0024544D /* File.swift in Sources */, E7EDEA6F1C871F81006BAAF2 /* Issue.swift in Sources */, + 515337C822517A060024544D /* Gist.swift in Sources */, DAEFC5911C83D85100CF3785 /* Label.swift in Sources */, BF8C797115D9BB2DE41E59E6 /* PullRequest.swift in Sources */, BF8C7DEE90DD25CBCA4AEE71 /* Parameters.swift in Sources */, @@ -832,7 +850,9 @@ 237F91E61E5AEC88005FAA6B /* URL+URLParameters.swift in Sources */, DAEFC5971C83EF0D00CF3785 /* Milestone.swift in Sources */, 23CAF2A91C7AB6C6005011C4 /* Octokit.swift in Sources */, + 515337C6225179FB0024544D /* File.swift in Sources */, E7EDEA701C871F81006BAAF2 /* Issue.swift in Sources */, + 515337C922517A070024544D /* Gist.swift in Sources */, DAEFC5921C83D85100CF3785 /* Label.swift in Sources */, BF8C7FFFDDAFA560EBEC35EE /* PullRequest.swift in Sources */, BF8C7A3F2B4817EF3AD1B315 /* Parameters.swift in Sources */, @@ -871,7 +891,9 @@ 237F91E71E5AEC89005FAA6B /* URL+URLParameters.swift in Sources */, DAEFC5981C83EF0D00CF3785 /* Milestone.swift in Sources */, 23CAF2AA1C7AB6C7005011C4 /* Octokit.swift in Sources */, + 515337C7225179FB0024544D /* File.swift in Sources */, E7EDEA711C871F82006BAAF2 /* Issue.swift in Sources */, + 515337CA22517A0B0024544D /* Gist.swift in Sources */, DAEFC5931C83D85100CF3785 /* Label.swift in Sources */, BF8C7808F0A0A71D0110AD43 /* PullRequest.swift in Sources */, BF8C7AB9EBD2E18007A8B77D /* Parameters.swift in Sources */, diff --git a/OctoKit/File.swift b/OctoKit/File.swift new file mode 100644 index 00000000..280b451c --- /dev/null +++ b/OctoKit/File.swift @@ -0,0 +1,23 @@ + +import Foundation + +public typealias FileDict = [String: File] +public typealias Files = [FileDict] + +open class File: Codable { + open private(set) var id: Int = -1 + open var rawURL: URL? + open var filename: String? + open var type: String? + open var language: String? + open var size: Int? + + enum CodingKeys: String, CodingKey { + case rawURL = "raw_url" + case filename + case type + case language + case size + } + +} diff --git a/OctoKit/Gist.swift b/OctoKit/Gist.swift new file mode 100644 index 00000000..dacac9ab --- /dev/null +++ b/OctoKit/Gist.swift @@ -0,0 +1,214 @@ +import Foundation +import RequestKit + +// MARK: model + +open class Gist: Codable { + open private(set) var id: Int = -1 + open var url: URL? + open var forksURL: URL? + open var commitsURL: URL? + open var gitPushURL: URL? + open var gitPullURL: URL? + open var commentsURL: URL? + open var htmlURL: URL? + open var files: Files + open var publicGist: Bool? + open var createdAt: Date? + open var updatedAt: Date? + open var description: String? + open var comments: Int? + open var user: User? + open var owner: User? + + enum CodingKeys: String, CodingKey { + case id + case url + case forksURL = "forks_url" + case commitsURL = "commits_url" + case gitPushURL = "git_pull_url" + case gitPullURL = "git_push_url" + case commentsURL = "comments_url" + case htmlURL = "html_url" + case files + case publicGist = "public" + case createdAt = "created_at" + case updatedAt = "updated_at" + case description + case comments + case user + case owner + } +} + +// MARK: request + +public extension Octokit { + + /** + Fetches the gists of the specified user + - parameter session: RequestKitURLSession, defaults to URLSession.sharedSession() + - parameter owner: The username who owns the gists. + - parameter page: Current page for gist pagination. `1` by default. + - parameter perPage: Number of gists per page. `100` by default. + - parameter completion: Callback for the outcome of the fetch. + */ + @discardableResult + func gists(_ session: RequestKitURLSession = URLSession.shared, owner: String, page: String = "1", perPage: String = "100", completion: @escaping (_ response: Response<[Gist]>) -> Void) -> URLSessionDataTaskProtocol? { + let router = GistRouter.readGists(configuration, owner, page, perPage) + return router.load(session, dateDecodingStrategy: .formatted(Time.rfc3339DateFormatter), expectedResultType: [Gist].self) { gists, error in + if let error = error { + completion(Response.failure(error)) + } else { + if let gists = gists { + completion(Response.success(gists)) + } + } + } + } + + /** + Fetches an gist in a repository + - parameter session: RequestKitURLSession, defaults to URLSession.sharedSession() + - parameter id: The id of the gist. + - parameter completion: Callback for the outcome of the fetch. + */ + @discardableResult + func gist(_ session: RequestKitURLSession = URLSession.shared, id: Int, completion: @escaping (_ response: Response) -> Void) -> URLSessionDataTaskProtocol? { + let router = GistRouter.readGist(configuration, id) + return router.load(session, dateDecodingStrategy: .formatted(Time.rfc3339DateFormatter), expectedResultType: Gist.self) { gist, error in + if let error = error { + completion(Response.failure(error)) + } else { + if let gist = gist { + completion(Response.success(gist)) + } + } + } + } + + /** + Creates an gist with a single file. + - parameter session: RequestKitURLSession, defaults to URLSession.sharedSession() + - parameter description: The description of the gist. + - parameter filename: The name of the file in the gist. + - parameter fileContent: The content of the file in the gist. + - parameter completion: Callback for the issue that is created. + */ + @discardableResult + func postGistFile(_ session: RequestKitURLSession = URLSession.shared, description: String, filename: String, fileContent: String, completion: @escaping (_ response: Response) -> Void) -> URLSessionDataTaskProtocol? { + let router = GistRouter.postGistFile(configuration, description, filename, fileContent) + return router.post(session, expectedResultType: Issue.self) { issue, error in + if let error = error { + completion(Response.failure(error)) + } else { + if let issue = issue { + completion(Response.success(issue)) + } + } + } + } + + /** + Edits an issue in a repository. + - parameter session: RequestKitURLSession, defaults to URLSession.sharedSession() + - parameter owner: The user or organization that owns the repository. + - parameter repository: The name of the repository. + - parameter number: The number of the issue. + - parameter title: The title of the issue. + - parameter body: The body text of the issue in GitHub-flavored Markdown format. + - parameter assignee: The name of the user to assign the issue to. This parameter is ignored if the user lacks push access to the repository. + - parameter state: Whether the issue is open or closed. + - parameter completion: Callback for the issue that is created. + */ + @discardableResult + func patchIssue(_ session: RequestKitURLSession = URLSession.shared, id: String, description: String, filename: String, fileContent: String, completion: @escaping (_ response: Response) -> Void) -> URLSessionDataTaskProtocol? { + let router = GistRouter.patchGistFile(configuration, id, description, filename, fileContent) + return router.post(session, expectedResultType: Gist.self) { gist, error in + if let error = error { + completion(Response.failure(error)) + } else { + if let gist = gist { + completion(Response.success(gist)) + } + } + } + } +} + +// MARK: Router + +enum GistRouter: JSONPostRouter { + case readGists(Configuration, String, String, String) + case readGist(Configuration, Int) + case postGistFile(Configuration, String, String, String) + case patchGistFile(Configuration, String, String, String, String) + + var method: HTTPMethod { + switch self { + case .postGistFile, .patchGistFile: + return .POST + default: + return .GET + } + } + + var encoding: HTTPEncoding { + switch self { + case .postGistFile, .patchGistFile: + return .json + default: + return .url + } + } + + var configuration: Configuration { + switch self { + case .readGists(let config, _, _, _): return config + case .readGist(let config, _): return config + case .postGistFile(let config, _, _, _): return config + case .patchGistFile(let config, _, _, _, _): return config + } + } + + var params: [String: Any] { + switch self { + case .readGists(_, _, let page, let perPage): + return ["per_page": perPage, "page": page] + case .readGist: + return [:] + case .postGistFile(_, let description, let filename, let fileContent): + var params = [String: Any]() + params["description"] = description + var file = [String: Any]() + file["content"] = fileContent + var files = [String: Any]() + files[filename] = file + params["files"] = files + return params + case .patchGistFile(_, _, let description, let filename, let fileContent): + var params = [String: Any]() + params["description"] = description + var file = [String: Any]() + file["content"] = fileContent + var files = [String: Any]() + files[filename] = file + params["files"] = files + return params + } + } + + var path: String { + switch self { + case .readGists(_, let owner, _, _): + return "users/\(owner)/gists" + case .readGist(_, let id): + return "gists/\(id)" + case .postGistFile(_, _, _, _): + return "gists" + case .patchGistFile(_, let id, _, _, _): + return "gists/\(id)" + } + } + +} From e7968753d486b7c6f24f44fdf6b3a5f3b98f79c1 Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Mon, 1 Apr 2019 14:25:42 -0500 Subject: [PATCH 153/302] Added decoder for posts. --- OctoKit/Gist.swift | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/OctoKit/Gist.swift b/OctoKit/Gist.swift index dacac9ab..abc07f1b 100644 --- a/OctoKit/Gist.swift +++ b/OctoKit/Gist.swift @@ -98,7 +98,9 @@ public extension Octokit { @discardableResult func postGistFile(_ session: RequestKitURLSession = URLSession.shared, description: String, filename: String, fileContent: String, completion: @escaping (_ response: Response) -> Void) -> URLSessionDataTaskProtocol? { let router = GistRouter.postGistFile(configuration, description, filename, fileContent) - return router.post(session, expectedResultType: Issue.self) { issue, error in + let decoder = JSONDecoder() + decoder.dateDecodingStrategy = .formatted(Time.rfc3339DateFormatter) + return router.post(session, decoder: decoder, expectedResultType: Issue.self) { issue, error in if let error = error { completion(Response.failure(error)) } else { @@ -124,7 +126,9 @@ public extension Octokit { @discardableResult func patchIssue(_ session: RequestKitURLSession = URLSession.shared, id: String, description: String, filename: String, fileContent: String, completion: @escaping (_ response: Response) -> Void) -> URLSessionDataTaskProtocol? { let router = GistRouter.patchGistFile(configuration, id, description, filename, fileContent) - return router.post(session, expectedResultType: Gist.self) { gist, error in + let decoder = JSONDecoder() + decoder.dateDecodingStrategy = .formatted(Time.rfc3339DateFormatter) + return router.post(session, decoder: decoder, expectedResultType: Gist.self) { gist, error in if let error = error { completion(Response.failure(error)) } else { From 8319d87bb01eefa4fc0d87aca5f69581a3da653e Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Mon, 1 Apr 2019 15:07:50 -0500 Subject: [PATCH 154/302] Added Gist tests and fixed some bugs they found. --- OctoKit.xcodeproj/project.pbxproj | 32 +++++- OctoKit/File.swift | 3 +- OctoKit/Gist.swift | 43 ++++++-- Tests/OctoKitTests/Fixtures/gist.json | 136 +++++++++++++++++++++++++ Tests/OctoKitTests/Fixtures/gists.json | 49 +++++++++ Tests/OctoKitTests/GistTests.swift | 103 +++++++++++++++++++ 6 files changed, 352 insertions(+), 14 deletions(-) create mode 100644 Tests/OctoKitTests/Fixtures/gist.json create mode 100644 Tests/OctoKitTests/Fixtures/gists.json create mode 100644 Tests/OctoKitTests/GistTests.swift diff --git a/OctoKit.xcodeproj/project.pbxproj b/OctoKit.xcodeproj/project.pbxproj index bb3f9b51..dfe70b47 100644 --- a/OctoKit.xcodeproj/project.pbxproj +++ b/OctoKit.xcodeproj/project.pbxproj @@ -96,6 +96,9 @@ 23F6434F1C7AEF70000427B3 /* user_repos.json in Resources */ = {isa = PBXBuildFile; fileRef = 234F4BDC1BDDE44600A58EF7 /* user_repos.json */; }; 23F643501C7AEF72000427B3 /* users.json in Resources */ = {isa = PBXBuildFile; fileRef = E7EE59DF1BE139FD0012E3D2 /* users.json */; }; 23F643511C7AEF73000427B3 /* users.json in Resources */ = {isa = PBXBuildFile; fileRef = E7EE59DF1BE139FD0012E3D2 /* users.json */; }; + 515337A9224FC3760024544D /* issue2.json in Resources */ = {isa = PBXBuildFile; fileRef = 515337A8224FC3760024544D /* issue2.json */; }; + 515337AA224FC3760024544D /* issue2.json in Resources */ = {isa = PBXBuildFile; fileRef = 515337A8224FC3760024544D /* issue2.json */; }; + 515337AB224FC3760024544D /* issue2.json in Resources */ = {isa = PBXBuildFile; fileRef = 515337A8224FC3760024544D /* issue2.json */; }; 515337C2225166600024544D /* Gist.swift in Sources */ = {isa = PBXBuildFile; fileRef = 515337C1225166600024544D /* Gist.swift */; }; 515337C4225179FB0024544D /* File.swift in Sources */ = {isa = PBXBuildFile; fileRef = 515337C3225179FB0024544D /* File.swift */; }; 515337C5225179FB0024544D /* File.swift in Sources */ = {isa = PBXBuildFile; fileRef = 515337C3225179FB0024544D /* File.swift */; }; @@ -104,9 +107,15 @@ 515337C822517A060024544D /* Gist.swift in Sources */ = {isa = PBXBuildFile; fileRef = 515337C1225166600024544D /* Gist.swift */; }; 515337C922517A070024544D /* Gist.swift in Sources */ = {isa = PBXBuildFile; fileRef = 515337C1225166600024544D /* Gist.swift */; }; 515337CA22517A0B0024544D /* Gist.swift in Sources */ = {isa = PBXBuildFile; fileRef = 515337C1225166600024544D /* Gist.swift */; }; - 515337A9224FC3760024544D /* issue2.json in Resources */ = {isa = PBXBuildFile; fileRef = 515337A8224FC3760024544D /* issue2.json */; }; - 515337AA224FC3760024544D /* issue2.json in Resources */ = {isa = PBXBuildFile; fileRef = 515337A8224FC3760024544D /* issue2.json */; }; - 515337AB224FC3760024544D /* issue2.json in Resources */ = {isa = PBXBuildFile; fileRef = 515337A8224FC3760024544D /* issue2.json */; }; + 515337F222529D590024544D /* GistTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 515337F022529C380024544D /* GistTests.swift */; }; + 515337F322529D5A0024544D /* GistTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 515337F022529C380024544D /* GistTests.swift */; }; + 515337F422529D5C0024544D /* GistTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 515337F022529C380024544D /* GistTests.swift */; }; + 515337F622529E7B0024544D /* gists.json in Resources */ = {isa = PBXBuildFile; fileRef = 515337F522529E7B0024544D /* gists.json */; }; + 515337F722529E7B0024544D /* gists.json in Resources */ = {isa = PBXBuildFile; fileRef = 515337F522529E7B0024544D /* gists.json */; }; + 515337F822529E7B0024544D /* gists.json in Resources */ = {isa = PBXBuildFile; fileRef = 515337F522529E7B0024544D /* gists.json */; }; + 515337FA2252A0410024544D /* gist.json in Resources */ = {isa = PBXBuildFile; fileRef = 515337F92252A0410024544D /* gist.json */; }; + 515337FB2252A0410024544D /* gist.json in Resources */ = {isa = PBXBuildFile; fileRef = 515337F92252A0410024544D /* gist.json */; }; + 515337FC2252A0410024544D /* gist.json in Resources */ = {isa = PBXBuildFile; fileRef = 515337F92252A0410024544D /* gist.json */; }; BF8C711C2C6B42F9F323FCFE /* pull_requests.json in Resources */ = {isa = PBXBuildFile; fileRef = BF8C79B71035B425F7748392 /* pull_requests.json */; }; BF8C716EB8D5CA2CBBA745CB /* pull_request.json in Resources */ = {isa = PBXBuildFile; fileRef = BF8C77314F563A710F11E2F6 /* pull_request.json */; }; BF8C719220F02AC04EF3D137 /* PullRequestTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF8C76EB002802C14A08F63E /* PullRequestTests.swift */; }; @@ -249,9 +258,12 @@ 23CAF29A1C7AB619005011C4 /* OctoKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = OctoKit.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 23F6433C1C7AEEB6000427B3 /* Nocilla.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Nocilla.framework; path = Carthage/Build/tvOS/Nocilla.framework; sourceTree = ""; }; 23F643421C7AEF2F000427B3 /* Nocilla.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Nocilla.framework; path = Carthage/Build/Mac/Nocilla.framework; sourceTree = ""; }; + 515337A8224FC3760024544D /* issue2.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; name = issue2.json; path = Fixtures/issue2.json; sourceTree = ""; }; 515337C1225166600024544D /* Gist.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Gist.swift; sourceTree = ""; }; 515337C3225179FB0024544D /* File.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = File.swift; sourceTree = ""; }; - 515337A8224FC3760024544D /* issue2.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; name = issue2.json; path = Fixtures/issue2.json; sourceTree = ""; }; + 515337F022529C380024544D /* GistTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GistTests.swift; sourceTree = ""; }; + 515337F522529E7B0024544D /* gists.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; name = gists.json; path = Fixtures/gists.json; sourceTree = ""; }; + 515337F92252A0410024544D /* gist.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; name = gist.json; path = Fixtures/gist.json; sourceTree = ""; }; BF8C72B985869B84F46B4E9D /* Parameters.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Parameters.swift; sourceTree = ""; }; BF8C73E0EF3CEEBDEA68DD5E /* PullRequest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PullRequest.swift; sourceTree = ""; }; BF8C76EB002802C14A08F63E /* PullRequestTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PullRequestTests.swift; sourceTree = ""; }; @@ -337,6 +349,7 @@ 234F4BD71BDDE40400A58EF7 /* Fixtures */, 234F4BC91BDDE3F900A58EF7 /* ConfigurationTests.swift */, E7EE59DD1BE11C2A0012E3D2 /* FollowTests.swift */, + 515337F022529C380024544D /* GistTests.swift */, E7EDEA6B1C871D01006BAAF2 /* IssueTests.swift */, 234F4BCB1BDDE3F900A58EF7 /* OctokitSwiftTests.swift */, 234F4BCC1BDDE3F900A58EF7 /* PublicKeyTests.swift */, @@ -355,6 +368,8 @@ 234F4BD71BDDE40400A58EF7 /* Fixtures */ = { isa = PBXGroup; children = ( + 515337F92252A0410024544D /* gist.json */, + 515337F522529E7B0024544D /* gists.json */, DABBDE4F1C8C0C20008F57CD /* issue.json */, 515337A8224FC3760024544D /* issue2.json */, E7EDEA6D1C871D0E006BAAF2 /* issues.json */, @@ -689,6 +704,8 @@ 234F4BDE1BDDE44600A58EF7 /* repo.json in Resources */, 234F4BE11BDDE44600A58EF7 /* user_repos.json in Resources */, 234F4BE01BDDE44600A58EF7 /* user_mietzmithut.json in Resources */, + 515337F622529E7B0024544D /* gists.json in Resources */, + 515337FA2252A0410024544D /* gist.json in Resources */, E7EDEA6E1C871D0E006BAAF2 /* issues.json in Resources */, BF8C78845606511558E7B929 /* pull_requests.json in Resources */, BF8C7B976A0652C486FAF736 /* pull_request.json in Resources */, @@ -721,6 +738,8 @@ 23F643481C7AEF66000427B3 /* repo.json in Resources */, 23F6434E1C7AEF6F000427B3 /* user_repos.json in Resources */, 23F6434C1C7AEF6C000427B3 /* user_mietzmithut.json in Resources */, + 515337F722529E7B0024544D /* gists.json in Resources */, + 515337FB2252A0410024544D /* gist.json in Resources */, E7EDEA741C871FA8006BAAF2 /* issues.json in Resources */, BF8C7923F427B3CFC6833337 /* pull_requests.json in Resources */, BF8C7A686709462323C702D8 /* pull_request.json in Resources */, @@ -746,6 +765,8 @@ 23F643491C7AEF67000427B3 /* repo.json in Resources */, 23F6434F1C7AEF70000427B3 /* user_repos.json in Resources */, 23F6434D1C7AEF6D000427B3 /* user_mietzmithut.json in Resources */, + 515337F822529E7B0024544D /* gists.json in Resources */, + 515337FC2252A0410024544D /* gist.json in Resources */, E7EDEA751C871FA9006BAAF2 /* issues.json in Resources */, BF8C711C2C6B42F9F323FCFE /* pull_requests.json in Resources */, BF8C716EB8D5CA2CBBA745CB /* pull_request.json in Resources */, @@ -774,6 +795,7 @@ 234F4BD51BDDE3F900A58EF7 /* TestHelper.swift in Sources */, 23A0521F1CA924950068BFF7 /* OctoKitURLTestSession.swift in Sources */, 234F4BD01BDDE3F900A58EF7 /* ConfigurationTests.swift in Sources */, + 515337F222529D590024544D /* GistTests.swift in Sources */, 234F4BD21BDDE3F900A58EF7 /* OctokitSwiftTests.swift in Sources */, E7EE59DA1BE10DA60012E3D2 /* StarsTests.swift in Sources */, BF8C719220F02AC04EF3D137 /* PullRequestTests.swift in Sources */, @@ -838,6 +860,7 @@ 23CAF2C01C7AB702005011C4 /* PublicKeyTests.swift in Sources */, 23A052201CA924950068BFF7 /* OctoKitURLTestSession.swift in Sources */, 23CAF2CA1C7AB711005011C4 /* UserTests.swift in Sources */, + 515337F322529D5A0024544D /* GistTests.swift in Sources */, 23CAF2C21C7AB705005011C4 /* RepositoryTests.swift in Sources */, 23CAF2BA1C7AB6F1005011C4 /* ConfigurationTests.swift in Sources */, BF8C725A44F262E5305385CC /* PullRequestTests.swift in Sources */, @@ -879,6 +902,7 @@ 23CAF2C11C7AB702005011C4 /* PublicKeyTests.swift in Sources */, 23A052211CA924950068BFF7 /* OctoKitURLTestSession.swift in Sources */, 23CAF2CB1C7AB712005011C4 /* UserTests.swift in Sources */, + 515337F422529D5C0024544D /* GistTests.swift in Sources */, 23CAF2C31C7AB706005011C4 /* RepositoryTests.swift in Sources */, 23CAF2BB1C7AB6F1005011C4 /* ConfigurationTests.swift in Sources */, BF8C732A1D13EFA1DE994A6B /* PullRequestTests.swift in Sources */, diff --git a/OctoKit/File.swift b/OctoKit/File.swift index 280b451c..ccd5e092 100644 --- a/OctoKit/File.swift +++ b/OctoKit/File.swift @@ -1,8 +1,7 @@ import Foundation -public typealias FileDict = [String: File] -public typealias Files = [FileDict] +public typealias Files = [String: File] open class File: Codable { open private(set) var id: Int = -1 diff --git a/OctoKit/Gist.swift b/OctoKit/Gist.swift index abc07f1b..f2160ebb 100644 --- a/OctoKit/Gist.swift +++ b/OctoKit/Gist.swift @@ -4,7 +4,7 @@ import RequestKit // MARK: model open class Gist: Codable { - open private(set) var id: Int = -1 + open private(set) var id: String? open var url: URL? open var forksURL: URL? open var commitsURL: URL? @@ -45,6 +45,27 @@ open class Gist: Codable { public extension Octokit { + /** + Fetches the gists of the authenticated user + - parameter session: RequestKitURLSession, defaults to URLSession.sharedSession() + - parameter page: Current page for gist pagination. `1` by default. + - parameter perPage: Number of gists per page. `100` by default. + - parameter completion: Callback for the outcome of the fetch. + */ + @discardableResult + func myGists(_ session: RequestKitURLSession = URLSession.shared, page: String = "1", perPage: String = "100", completion: @escaping (_ response: Response<[Gist]>) -> Void) -> URLSessionDataTaskProtocol? { + let router = GistRouter.readAuthenticatedGists(configuration, page, perPage) + return router.load(session, dateDecodingStrategy: .formatted(Time.rfc3339DateFormatter), expectedResultType: [Gist].self) { gists, error in + if let error = error { + completion(Response.failure(error)) + } else { + if let gists = gists { + completion(Response.success(gists)) + } + } + } + } + /** Fetches the gists of the specified user - parameter session: RequestKitURLSession, defaults to URLSession.sharedSession() @@ -74,7 +95,7 @@ public extension Octokit { - parameter completion: Callback for the outcome of the fetch. */ @discardableResult - func gist(_ session: RequestKitURLSession = URLSession.shared, id: Int, completion: @escaping (_ response: Response) -> Void) -> URLSessionDataTaskProtocol? { + func gist(_ session: RequestKitURLSession = URLSession.shared, id: String, completion: @escaping (_ response: Response) -> Void) -> URLSessionDataTaskProtocol? { let router = GistRouter.readGist(configuration, id) return router.load(session, dateDecodingStrategy: .formatted(Time.rfc3339DateFormatter), expectedResultType: Gist.self) { gist, error in if let error = error { @@ -96,16 +117,16 @@ public extension Octokit { - parameter completion: Callback for the issue that is created. */ @discardableResult - func postGistFile(_ session: RequestKitURLSession = URLSession.shared, description: String, filename: String, fileContent: String, completion: @escaping (_ response: Response) -> Void) -> URLSessionDataTaskProtocol? { + func postGistFile(_ session: RequestKitURLSession = URLSession.shared, description: String, filename: String, fileContent: String, completion: @escaping (_ response: Response) -> Void) -> URLSessionDataTaskProtocol? { let router = GistRouter.postGistFile(configuration, description, filename, fileContent) let decoder = JSONDecoder() decoder.dateDecodingStrategy = .formatted(Time.rfc3339DateFormatter) - return router.post(session, decoder: decoder, expectedResultType: Issue.self) { issue, error in + return router.post(session, decoder: decoder, expectedResultType: Gist.self) { gist, error in if let error = error { completion(Response.failure(error)) } else { - if let issue = issue { - completion(Response.success(issue)) + if let gist = gist { + completion(Response.success(gist)) } } } @@ -124,7 +145,7 @@ public extension Octokit { - parameter completion: Callback for the issue that is created. */ @discardableResult - func patchIssue(_ session: RequestKitURLSession = URLSession.shared, id: String, description: String, filename: String, fileContent: String, completion: @escaping (_ response: Response) -> Void) -> URLSessionDataTaskProtocol? { + func patchGistFile(_ session: RequestKitURLSession = URLSession.shared, id: String, description: String, filename: String, fileContent: String, completion: @escaping (_ response: Response) -> Void) -> URLSessionDataTaskProtocol? { let router = GistRouter.patchGistFile(configuration, id, description, filename, fileContent) let decoder = JSONDecoder() decoder.dateDecodingStrategy = .formatted(Time.rfc3339DateFormatter) @@ -143,8 +164,9 @@ public extension Octokit { // MARK: Router enum GistRouter: JSONPostRouter { + case readAuthenticatedGists(Configuration, String, String) case readGists(Configuration, String, String, String) - case readGist(Configuration, Int) + case readGist(Configuration, String) case postGistFile(Configuration, String, String, String) case patchGistFile(Configuration, String, String, String, String) @@ -168,6 +190,7 @@ enum GistRouter: JSONPostRouter { var configuration: Configuration { switch self { + case .readAuthenticatedGists(let config, _, _): return config case .readGists(let config, _, _, _): return config case .readGist(let config, _): return config case .postGistFile(let config, _, _, _): return config @@ -177,6 +200,8 @@ enum GistRouter: JSONPostRouter { var params: [String: Any] { switch self { + case .readAuthenticatedGists(_, let page, let perPage): + return ["per_page": perPage, "page": page] case .readGists(_, _, let page, let perPage): return ["per_page": perPage, "page": page] case .readGist: @@ -204,6 +229,8 @@ enum GistRouter: JSONPostRouter { var path: String { switch self { + case .readAuthenticatedGists(_, _, _): + return "/gists" case .readGists(_, let owner, _, _): return "users/\(owner)/gists" case .readGist(_, let id): diff --git a/Tests/OctoKitTests/Fixtures/gist.json b/Tests/OctoKitTests/Fixtures/gist.json new file mode 100644 index 00000000..5fff71ee --- /dev/null +++ b/Tests/OctoKitTests/Fixtures/gist.json @@ -0,0 +1,136 @@ +{ + "url": "https://api.github.com/gists/aa5a315d61ae9438b18d", + "forks_url": "https://api.github.com/gists/aa5a315d61ae9438b18d/forks", + "commits_url": "https://api.github.com/gists/aa5a315d61ae9438b18d/commits", + "id": "aa5a315d61ae9438b18d", + "node_id": "MDQ6R2lzdGFhNWEzMTVkNjFhZTk0MzhiMThk", + "git_pull_url": "https://gist.github.com/aa5a315d61ae9438b18d.git", + "git_push_url": "https://gist.github.com/aa5a315d61ae9438b18d.git", + "html_url": "https://gist.github.com/aa5a315d61ae9438b18d", + "files": { + "hello_world.rb": { + "filename": "hello_world.rb", + "type": "application/x-ruby", + "language": "Ruby", + "raw_url": "https://gist.githubusercontent.com/octocat/6cad326836d38bd3a7ae/raw/db9c55113504e46fa076e7df3a04ce592e2e86d8/hello_world.rb", + "size": 167, + "truncated": false, + "content": "class HelloWorld\n def initialize(name)\n @name = name.capitalize\n end\n def sayHi\n puts \"Hello !\"\n end\nend\n\nhello = HelloWorld.new(\"World\")\nhello.sayHi" + }, + "hello_world.py": { + "filename": "hello_world.py", + "type": "application/x-python", + "language": "Python", + "raw_url": "https://gist.githubusercontent.com/octocat/e29f3839074953e1cc2934867fa5f2d2/raw/99c1bf3a345505c2e6195198d5f8c36267de570b/hello_world.py", + "size": 199, + "truncated": false, + "content": "class HelloWorld:\n\n def __init__(self, name):\n self.name = name.capitalize()\n \n def sayHi(self):\n print \"Hello \" + self.name + \"!\"\n\nhello = HelloWorld(\"world\")\nhello.sayHi()" + }, + "hello_world_ruby.txt": { + "filename": "hello_world_ruby.txt", + "type": "text/plain", + "language": "Text", + "raw_url": "https://gist.githubusercontent.com/octocat/e29f3839074953e1cc2934867fa5f2d2/raw/9e4544db60e01a261aac098592b11333704e9082/hello_world_ruby.txt", + "size": 46, + "truncated": false, + "content": "Run `ruby hello_world.rb` to print Hello World" + }, + "hello_world_python.txt": { + "filename": "hello_world_python.txt", + "type": "text/plain", + "language": "Text", + "raw_url": "https://gist.githubusercontent.com/octocat/e29f3839074953e1cc2934867fa5f2d2/raw/076b4b78c10c9b7e1e0b73ffb99631bfc948de3b/hello_world_python.txt", + "size": 48, + "truncated": false, + "content": "Run `python hello_world.py` to print Hello World" + } + }, + "public": true, + "created_at": "2010-04-14T02:15:15Z", + "updated_at": "2011-06-20T11:34:15Z", + "description": "Hello World Examples", + "comments": 0, + "user": null, + "comments_url": "https://api.github.com/gists/aa5a315d61ae9438b18d/comments/", + "owner": { + "login": "octocat", + "id": 1, + "node_id": "MDQ6VXNlcjE=", + "avatar_url": "https://github.com/images/error/octocat_happy.gif", + "gravatar_id": "", + "url": "https://api.github.com/users/octocat", + "html_url": "https://github.com/octocat", + "followers_url": "https://api.github.com/users/octocat/followers", + "following_url": "https://api.github.com/users/octocat/following{/other_user}", + "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", + "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", + "organizations_url": "https://api.github.com/users/octocat/orgs", + "repos_url": "https://api.github.com/users/octocat/repos", + "events_url": "https://api.github.com/users/octocat/events{/privacy}", + "received_events_url": "https://api.github.com/users/octocat/received_events", + "type": "User", + "site_admin": false + }, + "truncated": false, + "forks": [ + { + "user": { + "login": "octocat", + "id": 1, + "node_id": "MDQ6VXNlcjE=", + "avatar_url": "https://github.com/images/error/octocat_happy.gif", + "gravatar_id": "", + "url": "https://api.github.com/users/octocat", + "html_url": "https://github.com/octocat", + "followers_url": "https://api.github.com/users/octocat/followers", + "following_url": "https://api.github.com/users/octocat/following{/other_user}", + "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", + "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", + "organizations_url": "https://api.github.com/users/octocat/orgs", + "repos_url": "https://api.github.com/users/octocat/repos", + "events_url": "https://api.github.com/users/octocat/events{/privacy}", + "received_events_url": "https://api.github.com/users/octocat/received_events", + "type": "User", + "site_admin": false + }, + "url": "https://api.github.com/gists/dee9c42e4998ce2ea439", + "id": "dee9c42e4998ce2ea439", + "created_at": "2011-04-14T16:00:49Z", + "updated_at": "2011-04-14T16:00:49Z" + } + ], + "history": [ + { + "url": "https://api.github.com/gists/aa5a315d61ae9438b18d/57a7f021a713b1c5a6a199b54cc514735d2d462f", + "version": "57a7f021a713b1c5a6a199b54cc514735d2d462f", + "user": { + "login": "octocat", + "id": 1, + "node_id": "MDQ6VXNlcjE=", + "avatar_url": "https://github.com/images/error/octocat_happy.gif", + "gravatar_id": "", + "url": "https://api.github.com/users/octocat", + "html_url": "https://github.com/octocat", + "followers_url": "https://api.github.com/users/octocat/followers", + "following_url": "https://api.github.com/users/octocat/following{/other_user}", + "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", + "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", + "organizations_url": "https://api.github.com/users/octocat/orgs", + "repos_url": "https://api.github.com/users/octocat/repos", + "events_url": "https://api.github.com/users/octocat/events{/privacy}", + "received_events_url": "https://api.github.com/users/octocat/received_events", + "type": "User", + "site_admin": false + }, + "change_status": { + "deletions": 0, + "additions": 180, + "total": 180 + }, + "committed_at": "2010-04-14T02:15:15Z" + } + ] +} diff --git a/Tests/OctoKitTests/Fixtures/gists.json b/Tests/OctoKitTests/Fixtures/gists.json new file mode 100644 index 00000000..d28aa0a8 --- /dev/null +++ b/Tests/OctoKitTests/Fixtures/gists.json @@ -0,0 +1,49 @@ +[ + { + "url": "https://api.github.com/gists/aa5a315d61ae9438b18d", + "forks_url": "https://api.github.com/gists/aa5a315d61ae9438b18d/forks", + "commits_url": "https://api.github.com/gists/aa5a315d61ae9438b18d/commits", + "id": "aa5a315d61ae9438b18d", + "node_id": "MDQ6R2lzdGFhNWEzMTVkNjFhZTk0MzhiMThk", + "git_pull_url": "https://gist.github.com/aa5a315d61ae9438b18d.git", + "git_push_url": "https://gist.github.com/aa5a315d61ae9438b18d.git", + "html_url": "https://gist.github.com/aa5a315d61ae9438b18d", + "files": { + "hello_world.rb": { + "filename": "hello_world.rb", + "type": "application/x-ruby", + "language": "Ruby", + "raw_url": "https://gist.githubusercontent.com/octocat/6cad326836d38bd3a7ae/raw/db9c55113504e46fa076e7df3a04ce592e2e86d8/hello_world.rb", + "size": 167 + } + }, + "public": true, + "created_at": "2010-04-14T02:15:15Z", + "updated_at": "2011-06-20T11:34:15Z", + "description": "Hello World Examples", + "comments": 0, + "user": null, + "comments_url": "https://api.github.com/gists/aa5a315d61ae9438b18d/comments/", + "owner": { + "login": "octocat", + "id": 1, + "node_id": "MDQ6VXNlcjE=", + "avatar_url": "https://github.com/images/error/octocat_happy.gif", + "gravatar_id": "", + "url": "https://api.github.com/users/octocat", + "html_url": "https://github.com/octocat", + "followers_url": "https://api.github.com/users/octocat/followers", + "following_url": "https://api.github.com/users/octocat/following{/other_user}", + "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", + "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", + "organizations_url": "https://api.github.com/users/octocat/orgs", + "repos_url": "https://api.github.com/users/octocat/repos", + "events_url": "https://api.github.com/users/octocat/events{/privacy}", + "received_events_url": "https://api.github.com/users/octocat/received_events", + "type": "User", + "site_admin": false + }, + "truncated": false + } +] diff --git a/Tests/OctoKitTests/GistTests.swift b/Tests/OctoKitTests/GistTests.swift new file mode 100644 index 00000000..6b394804 --- /dev/null +++ b/Tests/OctoKitTests/GistTests.swift @@ -0,0 +1,103 @@ + +import Foundation +import XCTest +import OctoKit + +class GistTests: XCTestCase { + + static var allTests = [ + ("testGetMyGists", testGetGists), + ("testGetGists", testGetGists), + ("testGetGist", testGetGist), + ("testPostGist", testPostGist), + ("testPatchGist", testPatchGist), + ("testLinuxTestSuiteIncludesAllTests", testLinuxTestSuiteIncludesAllTests) + ] + + // MARK: Actual Request tests + + func testGetMyGists() { + let config = TokenConfiguration("12345") + let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/gists?access_token=12345&page=1&per_page=100", expectedHTTPMethod: "GET", jsonFile: "gists", statusCode: 200) + let task = Octokit(config).myGists(session) { response in + switch response { + case .success(let gists): + XCTAssertEqual(gists.count, 1) + case .failure(let error): + XCTAssertNil(error) + } + } + XCTAssertNotNil(task) + XCTAssertTrue(session.wasCalled) + } + + func testGetGists() { + let config = TokenConfiguration("12345") + let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/users/vincode-io/gists?access_token=12345&page=1&per_page=100", expectedHTTPMethod: "GET", jsonFile: "gists", statusCode: 200) + let task = Octokit(config).gists(session, owner: "vincode-io") { response in + switch response { + case .success(let gists): + XCTAssertEqual(gists.count, 1) + case .failure(let error): + XCTAssertNil(error) + } + } + XCTAssertNotNil(task) + XCTAssertTrue(session.wasCalled) + } + + func testGetGist() { + let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/gists/aa5a315d61ae9438b18d", expectedHTTPMethod: "GET", jsonFile: "gist", statusCode: 200) + let task = Octokit().gist(session, id: "aa5a315d61ae9438b18d") { response in + switch response { + case .success(let gist): + XCTAssertEqual(gist.id, "aa5a315d61ae9438b18d") + case .failure: + XCTAssert(false, "should not get an error") + } + } + XCTAssertNotNil(task) + XCTAssertTrue(session.wasCalled) + } + + func testPostGist() { + let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/gists", expectedHTTPMethod: "POST", jsonFile: "gist", statusCode: 200) + let task = Octokit().postGistFile(session, description: "Test Post", filename: "Hello-World.swift", fileContent: "Sample Program") { response in + switch response { + case .success(let gist): + XCTAssertEqual(gist.id, "aa5a315d61ae9438b18d") + case .failure: + XCTAssert(false, "should not get an error") + } + } + XCTAssertNotNil(task) + XCTAssertTrue(session.wasCalled) + } + + func testPatchGist() { + let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/gists/aa5a315d61ae9438b18d", expectedHTTPMethod: "POST", jsonFile: "gist", statusCode: 200) + let task = Octokit().patchGistFile(session, id: "aa5a315d61ae9438b18d", description: "Test Post", filename: "Hello-World.swift", fileContent: "Sample Program") { response in + switch response { + case .success(let gist): + XCTAssertEqual(gist.id, "aa5a315d61ae9438b18d") + case .failure: + XCTAssert(false, "should not get an error") + } + } + XCTAssertNotNil(task) + XCTAssertTrue(session.wasCalled) + } + + func testLinuxTestSuiteIncludesAllTests() { + #if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) + let thisClass = type(of: self) + let linuxCount = thisClass.allTests.count + #if os(iOS) + let darwinCount = thisClass.defaultTestSuite.tests.count + #else + let darwinCount = thisClass.defaultTestSuite.tests.count + #endif + XCTAssertEqual(linuxCount, darwinCount, "\(darwinCount - linuxCount) tests are missing from allTests") + #endif + } +} From e1cab744d19b9233b460f3d7fb510ddd334dcdd1 Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Mon, 1 Apr 2019 15:14:19 -0500 Subject: [PATCH 155/302] Fixed my sloppy documentation. --- OctoKit/Gist.swift | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/OctoKit/Gist.swift b/OctoKit/Gist.swift index f2160ebb..c7206770 100644 --- a/OctoKit/Gist.swift +++ b/OctoKit/Gist.swift @@ -89,7 +89,7 @@ public extension Octokit { } /** - Fetches an gist in a repository + Fetches an gist - parameter session: RequestKitURLSession, defaults to URLSession.sharedSession() - parameter id: The id of the gist. - parameter completion: Callback for the outcome of the fetch. @@ -114,7 +114,7 @@ public extension Octokit { - parameter description: The description of the gist. - parameter filename: The name of the file in the gist. - parameter fileContent: The content of the file in the gist. - - parameter completion: Callback for the issue that is created. + - parameter completion: Callback for the gist that is created. */ @discardableResult func postGistFile(_ session: RequestKitURLSession = URLSession.shared, description: String, filename: String, fileContent: String, completion: @escaping (_ response: Response) -> Void) -> URLSessionDataTaskProtocol? { @@ -133,16 +133,13 @@ public extension Octokit { } /** - Edits an issue in a repository. + Edits an gist with a single file. - parameter session: RequestKitURLSession, defaults to URLSession.sharedSession() - - parameter owner: The user or organization that owns the repository. - - parameter repository: The name of the repository. - - parameter number: The number of the issue. - - parameter title: The title of the issue. - - parameter body: The body text of the issue in GitHub-flavored Markdown format. - - parameter assignee: The name of the user to assign the issue to. This parameter is ignored if the user lacks push access to the repository. - - parameter state: Whether the issue is open or closed. - - parameter completion: Callback for the issue that is created. + - parameter id: The of the gist to update. + - parameter description: The description of the gist. + - parameter filename: The name of the file in the gist. + - parameter fileContent: The content of the file in the gist. + - parameter completion: Callback for the gist that is created. */ @discardableResult func patchGistFile(_ session: RequestKitURLSession = URLSession.shared, id: String, description: String, filename: String, fileContent: String, completion: @escaping (_ response: Response) -> Void) -> URLSessionDataTaskProtocol? { From d95db3fdda61fd6c95d25366ddb0159732174036 Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Mon, 1 Apr 2019 17:14:09 -0500 Subject: [PATCH 156/302] Added publicAccess to the Gist post function. --- OctoKit/Gist.swift | 15 ++++++++------- Tests/OctoKitTests/GistTests.swift | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/OctoKit/Gist.swift b/OctoKit/Gist.swift index c7206770..fdacaf3e 100644 --- a/OctoKit/Gist.swift +++ b/OctoKit/Gist.swift @@ -117,8 +117,8 @@ public extension Octokit { - parameter completion: Callback for the gist that is created. */ @discardableResult - func postGistFile(_ session: RequestKitURLSession = URLSession.shared, description: String, filename: String, fileContent: String, completion: @escaping (_ response: Response) -> Void) -> URLSessionDataTaskProtocol? { - let router = GistRouter.postGistFile(configuration, description, filename, fileContent) + func postGistFile(_ session: RequestKitURLSession = URLSession.shared, description: String, filename: String, fileContent: String, publicAccess: Bool, completion: @escaping (_ response: Response) -> Void) -> URLSessionDataTaskProtocol? { + let router = GistRouter.postGistFile(configuration, description, filename, fileContent, publicAccess) let decoder = JSONDecoder() decoder.dateDecodingStrategy = .formatted(Time.rfc3339DateFormatter) return router.post(session, decoder: decoder, expectedResultType: Gist.self) { gist, error in @@ -164,7 +164,7 @@ enum GistRouter: JSONPostRouter { case readAuthenticatedGists(Configuration, String, String) case readGists(Configuration, String, String, String) case readGist(Configuration, String) - case postGistFile(Configuration, String, String, String) + case postGistFile(Configuration, String, String, String, Bool) case patchGistFile(Configuration, String, String, String, String) var method: HTTPMethod { @@ -190,7 +190,7 @@ enum GistRouter: JSONPostRouter { case .readAuthenticatedGists(let config, _, _): return config case .readGists(let config, _, _, _): return config case .readGist(let config, _): return config - case .postGistFile(let config, _, _, _): return config + case .postGistFile(let config, _, _, _, _): return config case .patchGistFile(let config, _, _, _, _): return config } } @@ -203,8 +203,9 @@ enum GistRouter: JSONPostRouter { return ["per_page": perPage, "page": page] case .readGist: return [:] - case .postGistFile(_, let description, let filename, let fileContent): + case .postGistFile(_, let description, let filename, let fileContent, let publicAccess): var params = [String: Any]() + params["public"] = publicAccess params["description"] = description var file = [String: Any]() file["content"] = fileContent @@ -227,12 +228,12 @@ enum GistRouter: JSONPostRouter { var path: String { switch self { case .readAuthenticatedGists(_, _, _): - return "/gists" + return "gists" case .readGists(_, let owner, _, _): return "users/\(owner)/gists" case .readGist(_, let id): return "gists/\(id)" - case .postGistFile(_, _, _, _): + case .postGistFile(_, _, _, _, _): return "gists" case .patchGistFile(_, let id, _, _, _): return "gists/\(id)" diff --git a/Tests/OctoKitTests/GistTests.swift b/Tests/OctoKitTests/GistTests.swift index 6b394804..05b50448 100644 --- a/Tests/OctoKitTests/GistTests.swift +++ b/Tests/OctoKitTests/GistTests.swift @@ -62,7 +62,7 @@ class GistTests: XCTestCase { func testPostGist() { let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/gists", expectedHTTPMethod: "POST", jsonFile: "gist", statusCode: 200) - let task = Octokit().postGistFile(session, description: "Test Post", filename: "Hello-World.swift", fileContent: "Sample Program") { response in + let task = Octokit().postGistFile(session, description: "Test Post", filename: "Hello-World.swift", fileContent: "Sample Program", publicAccess: true) { response in switch response { case .success(let gist): XCTAssertEqual(gist.id, "aa5a315d61ae9438b18d") From 11dbb4e1429310c3c11c1348d2047c4f900df02b Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Tue, 2 Apr 2019 05:56:55 -0500 Subject: [PATCH 157/302] Added missing parameter comment. --- OctoKit/Gist.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/OctoKit/Gist.swift b/OctoKit/Gist.swift index fdacaf3e..920d35dd 100644 --- a/OctoKit/Gist.swift +++ b/OctoKit/Gist.swift @@ -114,6 +114,7 @@ public extension Octokit { - parameter description: The description of the gist. - parameter filename: The name of the file in the gist. - parameter fileContent: The content of the file in the gist. + - parameter publicAccess: The public/private visability of the gist. - parameter completion: Callback for the gist that is created. */ @discardableResult From 2c21aef14d00b4c9d530849f1f8c0a6aaa91c288 Mon Sep 17 00:00:00 2001 From: Rob Mathers Date: Sat, 25 May 2019 23:57:14 -0400 Subject: [PATCH 158/302] Create method to get a single label from a repo --- OctoKit/Label.swift | 64 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/OctoKit/Label.swift b/OctoKit/Label.swift index 27270ac3..5b2221dd 100644 --- a/OctoKit/Label.swift +++ b/OctoKit/Label.swift @@ -1,7 +1,71 @@ import Foundation +import RequestKit open class Label: Codable { open var url: URL? open var name: String? open var color: String? } + +// MARK: request + +public extension Octokit { + /** + Fetches a single label in a repository + - parameter session: RequestKitURLSession, defaults to URLSession.sharedSession() + - parameter owner: The user or organization that owns the repository. + - parameter repository: The name of the repository. + - parameter name: The name of the label. + - parameter completion: Callback for the outcome of the fetch. + */ + @discardableResult + func label(_ session: RequestKitURLSession = URLSession.shared, owner: String, repository: String, name: String, completion: @escaping (_ response: Response