-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow changelog to be split into separate sections (#40)
* Allow changelog to be split into separate sections * Refine wording in comments in IssuesFetcher * Update Sources/GitBuddyCore/Models/Changelog.swift Co-Authored-By: Antoine van der Lee <[email protected]> * Fix linter issues * Fix remaining tests, update comments and README.md * Update README.md and tests * Add doc comment * Update IssuesJSON.swift * Update Package.swift * Update Sources/GitBuddyCore/Models/Changelog.swift * Update Package.swift Co-authored-by: Antoine van der Lee <[email protected]>
- Loading branch information
1 parent
f73fc1d
commit 1cae532
Showing
12 changed files
with
4,565 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// | ||
// IssuesFetcher.swift | ||
// | ||
// | ||
// Created by Max Desiatov on 26/03/2020. | ||
// | ||
|
||
import Foundation | ||
import OctoKit | ||
|
||
struct IssuesFetcher { | ||
|
||
let octoKit: Octokit | ||
let project: GITProject | ||
|
||
/// Fetches issues and filters them by a given `fromDate` and `toDate`. | ||
func fetchAllBetween(_ fromDate: Date, and toDate: Date, using session: URLSession = URLSession.shared) throws -> [Issue] { | ||
let group = DispatchGroup() | ||
group.enter() | ||
|
||
var result: Result<[Issue], Swift.Error>! | ||
|
||
octoKit.issues(session, owner: project.organisation, repository: project.repository, state: .Closed) { (response) in | ||
switch response { | ||
case .success(let issues): | ||
result = .success(issues) | ||
case .failure(let error): | ||
result = .failure(error) | ||
} | ||
group.leave() | ||
} | ||
group.wait() | ||
|
||
return try result.get().filter { issue -> Bool in | ||
guard | ||
// It looks like OctoKit.swift doesn't support `pull_request` property that helps in | ||
// distinguishing between issues and pull requests, as the issues endpoint returns both. | ||
// See https://developer.github.com/v3/issues/ for more details. | ||
issue.htmlURL?.pathComponents.contains("issues") ?? false, | ||
let closedAt = issue.closedAt | ||
else { return false } | ||
return closedAt > fromDate && closedAt < toDate | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.