Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Developing 1.0 - Iris #214

Merged
merged 78 commits into from
Feb 3, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
af1e9f9
started abstracting away the source server types so that we can hide …
czechboy0 Oct 16, 2015
e0bb07f
started defining methods required by all server protocols
czechboy0 Oct 16, 2015
c71685b
Merge branch 'master' into hd/abstracting_source_server
czechboy0 Oct 21, 2015
65e42e3
move
czechboy0 Oct 21, 2015
5117309
mega refactor in progress
czechboy0 Oct 21, 2015
da07eed
refactoring in progress, abstracting away github types, very much not…
czechboy0 Oct 21, 2015
c1d7534
Merge branch 'master' into hd/abstracting_source_server
czechboy0 Nov 3, 2015
50c36c9
Merge branch 'master' into hd/abstracting_source_server
czechboy0 Jan 21, 2016
8d984ff
compiles, but is still very broken (work in progress)
czechboy0 Jan 21, 2016
a237521
starting to work issues out, buildasaur is sort of running, but many …
czechboy0 Jan 21, 2016
22d3713
protocols ftw!
czechboy0 Jan 21, 2016
070e35d
fixed a beautiful infinite recursion. anyway, buildasaur passed the f…
czechboy0 Jan 21, 2016
717e7ed
renaming summary builder tests to what they really are, github specif…
czechboy0 Jan 21, 2016
cc747dc
tests passing again!
czechboy0 Jan 21, 2016
2379569
no need for those todo's
czechboy0 Jan 21, 2016
4e1bcac
adding folders
czechboy0 Jan 21, 2016
56452ec
moving things around
czechboy0 Jan 21, 2016
2f60167
added keychain for ssh passphrase, github token and server passwords
czechboy0 Jan 22, 2016
13aca91
made keychain thread safe
czechboy0 Jan 22, 2016
3d84eb8
fixed the migrator and a missed copy-paste bug, now everything seems …
czechboy0 Jan 22, 2016
70542e7
Merge pull request #207 from czechboy0/hd/bitbucket
czechboy0 Jan 22, 2016
4aa7a13
don't forget the passphrasers!
czechboy0 Jan 22, 2016
1def561
switched to using a in-memory dictionary instead of the real keychain…
czechboy0 Jan 23, 2016
4536208
Merge pull request #209 from czechboy0/hd/keychain
czechboy0 Jan 23, 2016
ed414f9
added OAuth support, already in the UI for GitHub, needs a bit more w…
czechboy0 Jan 27, 2016
62b8ddf
fixing both personal token and oauth user flows
czechboy0 Jan 27, 2016
5da0312
final fixes
czechboy0 Jan 27, 2016
3ac499c
working out testing on CI with CocoaPods keys
czechboy0 Jan 27, 2016
f474f6e
print env
czechboy0 Jan 27, 2016
9d30e98
env
czechboy0 Jan 27, 2016
5e81822
inserting dummy credentials
czechboy0 Jan 27, 2016
05b99ba
wip
czechboy0 Jan 27, 2016
8dbf6ae
wipp
czechboy0 Jan 27, 2016
24922bf
project for keys
czechboy0 Jan 27, 2016
e1db594
nicer
czechboy0 Jan 27, 2016
dd568d9
fire it up
czechboy0 Jan 27, 2016
ec39385
v++
czechboy0 Jan 27, 2016
69ec05f
hmm trying random things
czechboy0 Jan 27, 2016
e1168d7
fix project name back
czechboy0 Jan 27, 2016
1bb1d9e
testing things
czechboy0 Jan 27, 2016
3b84e26
let it run again
czechboy0 Jan 27, 2016
6b85ef5
no idea what else to try
czechboy0 Jan 27, 2016
bc0857b
remove old keys
czechboy0 Jan 27, 2016
708fdb3
Merge pull request #215 from czechboy0/hd/authentication_refactoring
czechboy0 Jan 27, 2016
00284e4
bitbucket authentication works, more generalization for it across the…
czechboy0 Jan 27, 2016
8de836a
Merge pull request #216 from czechboy0/hd/bitbucket_authentication
czechboy0 Jan 27, 2016
c3846b0
adding bitbucket entities
czechboy0 Jan 27, 2016
7e50077
adding entities
czechboy0 Jan 27, 2016
25a8ff0
parsing done for: repositories, pull requests, issues, pull request b…
czechboy0 Jan 27, 2016
7cdfc72
Merge pull request #218 from czechboy0/hd/bitbucket_entities
czechboy0 Jan 27, 2016
8019222
adding more working endpoints
czechboy0 Jan 27, 2016
87a9d14
almost all bitbucket endpoints have been implemented, only getting br…
czechboy0 Jan 27, 2016
148fcbd
fixing bitbucket-specific issues
czechboy0 Jan 27, 2016
6056488
Merge pull request #221 from czechboy0/hd/bitbucket_entities
czechboy0 Jan 27, 2016
6465ed8
work on refresh token handling, is slightly more complicated than ant…
czechboy0 Jan 27, 2016
af3f8da
simplified migration to just format 3, fixed tests
czechboy0 Jan 28, 2016
27d99d9
refresh token flow works
czechboy0 Jan 28, 2016
970890a
just renamed a couple of things
czechboy0 Jan 28, 2016
c084c88
bitbucket token refresh seems to be working, needs a live test now, b…
czechboy0 Jan 28, 2016
0fe5c99
Merge pull request #222 from czechboy0/hd/bitbucket_refresh_token
czechboy0 Jan 28, 2016
775b720
adding posting comments to bitbucket - had to drop down to API v1
czechboy0 Jan 28, 2016
670a02f
removed unused code - we can't do these things for bitbucket :(
czechboy0 Jan 28, 2016
306d4ce
Merge pull request #223 from czechboy0/hd/bitbucket_posting_comments
czechboy0 Jan 28, 2016
3795424
added bitbucket v2 pagination support, so now ALL PRs/comments get pu…
czechboy0 Jan 28, 2016
f7d1b35
Merge pull request #224 from czechboy0/hd/bitbucket_pagination
czechboy0 Jan 28, 2016
22031ef
Merge pull request #217 from czechboy0/hd/bitbucket
czechboy0 Jan 28, 2016
ef39809
Merge branch 'master' into develop_1.0
czechboy0 Jan 28, 2016
a8dac52
fix main thread UI calls
czechboy0 Jan 29, 2016
377a04a
adding fastlane actions for releasing a new version on sparkle feed
czechboy0 Feb 3, 2016
f0fcc9c
adding sparkle xml entry works now, we need to create the proper rele…
czechboy0 Feb 3, 2016
1f13d95
test
czechboy0 Feb 3, 2016
14ab7ca
mostly finished work on sparkle
czechboy0 Feb 3, 2016
8c6e455
fixes here and there
czechboy0 Feb 3, 2016
71c6063
back
czechboy0 Feb 3, 2016
37c1b5c
last be 0.8.0
czechboy0 Feb 3, 2016
72f8b38
Merge pull request #230 from czechboy0/hd/sparkle_develop
czechboy0 Feb 3, 2016
f3b05db
moving pods
czechboy0 Feb 3, 2016
a1aa76a
v++
czechboy0 Feb 3, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions BuildaGitServer/Base/Authentication.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
//
// Authentication.swift
// Buildasaur
//
// Created by Honza Dvorsky on 1/26/16.
// Copyright © 2016 Honza Dvorsky. All rights reserved.
//

import Foundation
import BuildaUtils

public struct ProjectAuthenticator {

public enum AuthType: String {
case PersonalToken
case OAuthToken
}

public let service: GitService
public let username: String
public let type: AuthType
public let secret: String

public init(service: GitService, username: String, type: AuthType, secret: String) {
self.service = service
self.username = username
self.type = type
self.secret = secret
}
}

public protocol KeychainStringSerializable {
static func fromString(value: String) throws -> Self
func toString() -> String
}

extension ProjectAuthenticator: KeychainStringSerializable {

public static func fromString(value: String) throws -> ProjectAuthenticator {

let comps = value.componentsSeparatedByString(":")
guard comps.count >= 4 else { throw Error.withInfo("Corrupted keychain string") }
guard let service = GitService(rawValue: comps[0]) else {
throw Error.withInfo("Unsupported service: \(comps[0])")
}
guard let type = ProjectAuthenticator.AuthType(rawValue: comps[2]) else {
throw Error.withInfo("Unsupported auth type: \(comps[2])")
}
//join the rest back in case we have ":" in the token
let remaining = comps.dropFirst(3).joinWithSeparator(":")
let auth = ProjectAuthenticator(service: service, username: comps[1], type: type, secret: remaining)
return auth
}

public func toString() -> String {

return [
self.service.rawValue,
self.username,
self.type.rawValue,
self.secret
].joinWithSeparator(":")
}
}
114 changes: 114 additions & 0 deletions BuildaGitServer/Base/BaseTypes.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
//
// BaseTypes.swift
// Buildasaur
//
// Created by Honza Dvorsky on 10/16/15.
// Copyright © 2015 Honza Dvorsky. All rights reserved.
//

import Foundation
import ReactiveCocoa

public protocol BuildStatusCreator {
func createStatusFromState(state: BuildState, description: String?, targetUrl: String?) -> StatusType
}

public protocol SourceServerType: BuildStatusCreator {

func getBranchesOfRepo(repo: String, completion: (branches: [BranchType]?, error: ErrorType?) -> ())
func getOpenPullRequests(repo: String, completion: (prs: [PullRequestType]?, error: ErrorType?) -> ())
func getPullRequest(pullRequestNumber: Int, repo: String, completion: (pr: PullRequestType?, error: ErrorType?) -> ())
func getRepo(repo: String, completion: (repo: RepoType?, error: ErrorType?) -> ())
func getStatusOfCommit(commit: String, repo: String, completion: (status: StatusType?, error: ErrorType?) -> ())
func postStatusOfCommit(commit: String, status: StatusType, repo: String, completion: (status: StatusType?, error: ErrorType?) -> ())
func postCommentOnIssue(comment: String, issueNumber: Int, repo: String, completion: (comment: CommentType?, error: ErrorType?) -> ())
func getCommentsOfIssue(issueNumber: Int, repo: String, completion: (comments: [CommentType]?, error: ErrorType?) -> ())

func authChangedSignal() -> Signal<ProjectAuthenticator?, NoError>
}

public class SourceServerFactory {

public init() { }

public func createServer(service: GitService, auth: ProjectAuthenticator?) -> SourceServerType {

if let auth = auth {
precondition(service == auth.service)
}

return GitServerFactory.server(service, auth: auth)
}
}

public struct RepoPermissions {
public let read: Bool
public let write: Bool
public init(read: Bool, write: Bool) {
self.read = read
self.write = write
}
}

public protocol RateLimitType {

var report: String { get }
}

public protocol RepoType {

var permissions: RepoPermissions { get }
var originUrlSSH: String { get }
var latestRateLimitInfo: RateLimitType? { get }
}

public protocol BranchType {

var name: String { get }
var commitSHA: String { get }
}

public protocol IssueType {

var number: Int { get }
}

public protocol PullRequestType: IssueType {

var headName: String { get }
var headCommitSHA: String { get }
var headRepo: RepoType { get }

var baseName: String { get }

var title: String { get }
}

public enum BuildState {
case NoState
case Pending
case Success
case Error
case Failure
}

public protocol StatusType {

var state: BuildState { get }
var description: String? { get }
var targetUrl: String? { get }
}

extension StatusType {

public func isEqual(rhs: StatusType) -> Bool {
let lhs = self
return lhs.state == rhs.state && lhs.description == rhs.description
}
}

public protocol CommentType {

var body: String { get }
}

32 changes: 32 additions & 0 deletions BuildaGitServer/Base/GitServerFactory.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//
// GitServerFactory.swift
// Buildasaur
//
// Created by Honza Dvorsky on 13/12/2014.
// Copyright (c) 2014 Honza Dvorsky. All rights reserved.
//

import Foundation
import BuildaUtils

class GitServerFactory {

class func server(service: GitService, auth: ProjectAuthenticator?, http: HTTP? = nil) -> SourceServerType {

let server: SourceServerType

switch service {
case .GitHub:
let baseURL = "https://api.github.com"
let endpoints = GitHubEndpoints(baseURL: baseURL, auth: auth)
server = GitHubServer(endpoints: endpoints, http: http)
case .BitBucket:
let baseURL = "https://api.bitbucket.org"
let endpoints = BitBucketEndpoints(baseURL: baseURL, auth: auth)
server = BitBucketServer(endpoints: endpoints, http: http)
}

return server
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// GitHubServerExtensions.swift
// SourceServerExtensions.swift
// Buildasaur
//
// Created by Honza Dvorsky on 14/12/2014.
Expand All @@ -10,12 +10,12 @@ import Foundation
import BuildaUtils

//functions to make working with github easier - utility functions
public extension GitHubServer {
extension SourceServerType {

/**
* Get the latest status of a pull request.
*/
public func getStatusOfPullRequest(pullRequestNumber: Int, repo: String, completion: (status: Status?, error: NSError?) -> ()) {
func getStatusOfPullRequest(pullRequestNumber: Int, repo: String, completion: (status: StatusType?, error: ErrorType?) -> ()) {

self.getPullRequest(pullRequestNumber, repo: repo) { (pr, error) -> () in

Expand All @@ -26,7 +26,7 @@ public extension GitHubServer {

if let pr = pr {
//fetched PR, now take its head's sha - that's the commit we care about.
let sha = pr.head.sha
let sha = pr.headName
self.getStatusOfCommit(sha, repo: repo, completion: completion)
} else {
completion(status: nil, error: Error.withInfo("PR is nil and error is nil"))
Expand All @@ -35,7 +35,7 @@ public extension GitHubServer {
}

//TODO: support paging through all the comments. currently we only fetch the last ~30 comments.
public func findMatchingCommentInIssue(commentsToMatch: [String], issue: Int, repo: String, completion: (foundComments: [Comment]?, error: NSError?) -> ()) {
public func findMatchingCommentInIssue(commentsToMatch: [String], issue: Int, repo: String, completion: (foundComments: [CommentType]?, error: ErrorType?) -> ()) {

self.getCommentsOfIssue(issue, repo: repo) { (comments, error) -> () in

Expand All @@ -45,7 +45,7 @@ public extension GitHubServer {
}

if let comments = comments {
let filtered = comments.filter { (comment: Comment) -> Bool in
let filtered = comments.filter { (comment: CommentType) -> Bool in

let filteredSearch = commentsToMatch.filter {
(searchString: String) -> Bool in
Expand Down
25 changes: 25 additions & 0 deletions BuildaGitServer/BitBucket/BitBucketComment.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//
// BitBucketComment.swift
// Buildasaur
//
// Created by Honza Dvorsky on 1/27/16.
// Copyright © 2016 Honza Dvorsky. All rights reserved.
//

import Foundation

class BitBucketComment: BitBucketEntity, CommentType {

let body: String

required init(json: NSDictionary) {

self.body = json
.optionalDictionaryForKey("content")?
.stringForKey("raw") ?? json.stringForKey("content")

super.init(json: json)
}


}
Loading