Skip to content

Commit 1996f80

Browse files
authored
Merge branch 'master' into master
2 parents 6d1a3f8 + aa8bd19 commit 1996f80

2 files changed

Lines changed: 40 additions & 5 deletions

File tree

GitHubListener/AppDelegate.swift

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,11 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCent
203203
for commit in commits.reversed() {
204204
let testDate:Date = commit.description.author.date
205205
if (date != nil && date != testDate) {
206-
self.showNotification(title: "\(repo.fullName)", subtitle: "\(commit.author.login) added commit", informativeText: commit.description.message, image: commit.author.avatarUrl, url: commit.htmlUrl)
206+
if (commit.description.verification.verified) {
207+
self.showNotification(title: "\(repo.fullName)", subtitle: "\(commit.author.login) added commit", informativeText: commit.description.message, image: commit.author.avatarUrl, url: commit.htmlUrl)
208+
} else {
209+
self.showNotification(title: "\(repo.fullName)", subtitle: "\(commit.description.author.name) added commit", informativeText: commit.description.message, url: commit.htmlUrl)
210+
}
207211
}
208212
}
209213
}
@@ -527,7 +531,12 @@ struct Commit: Codable {
527531
let container = try decoder.container(keyedBy: CodingKeys.self)
528532
let id = try container.decode(String.self, forKey: .id)
529533
let htmlUrl = try container.decode(String.self, forKey: .htmlUrl)
530-
let author = try container.decode(User.self, forKey: .author)
534+
var author:User = User(id: 0, login: "", avatarUrl: "")
535+
do {
536+
author = try container.decode(User.self, forKey: .author)
537+
} catch {
538+
539+
}
531540
let description = try container.decode(CommitDescription.self, forKey: .description)
532541
self.init(id: id, htmlUrl: htmlUrl, author: author, description: description)
533542
}
@@ -564,25 +573,29 @@ struct Commit: Codable {
564573
let message: String
565574
let commentCount: Int
566575
let author: CommitAuthor
576+
let verification: Verification
567577

568578
enum CodingKeys: String, CodingKey {
569579
case message
570580
case commentCount = "comment_count"
571581
case author
582+
case verification
572583
}
573584

574-
init(message: String, commentCount: Int, author: CommitAuthor) {
585+
init(message: String, commentCount: Int, author: CommitAuthor, verification: Verification) {
575586
self.message = message
576587
self.commentCount = commentCount
577588
self.author = author
589+
self.verification = verification
578590
}
579591

580592
init(from decoder: Decoder) throws {
581593
let container = try decoder.container(keyedBy: CodingKeys.self)
582594
let message = try container.decode(String.self, forKey: .message)
583595
let commentCount = try container.decode(Int.self, forKey: .commentCount)
584596
let author = try container.decode(CommitAuthor.self, forKey: .author)
585-
self.init(message: message, commentCount: commentCount, author: author)
597+
let verification = try container.decode(Verification.self, forKey: .verification)
598+
self.init(message: message, commentCount: commentCount, author: author, verification: verification)
586599
}
587600

588601
struct CommitAuthor: Codable {
@@ -610,6 +623,28 @@ struct Commit: Codable {
610623
self.init(name: name, email: email, date: date)
611624
}
612625
}
626+
627+
struct Verification: Codable {
628+
let verified: Bool
629+
let reason: String
630+
631+
enum CodingKeys: String, CodingKey {
632+
case verified
633+
case reason
634+
}
635+
636+
init(verified: Bool, reason: String) {
637+
self.verified = verified
638+
self.reason = reason
639+
}
640+
641+
init(from decoder: Decoder) throws {
642+
let container = try decoder.container(keyedBy: CodingKeys.self)
643+
let verified = try container.decode(Bool.self, forKey: .verified)
644+
let reason = try container.decode(String.self, forKey: .reason)
645+
self.init(verified: verified, reason: reason)
646+
}
647+
}
613648
}
614649
}
615650

GitHubListener/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<key>CFBundlePackageType</key>
1818
<string>APPL</string>
1919
<key>CFBundleShortVersionString</key>
20-
<string>1.0</string>
20+
<string>0.3</string>
2121
<key>CFBundleVersion</key>
2222
<string>1</string>
2323
<key>LSApplicationCategoryType</key>

0 commit comments

Comments
 (0)