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

Option to disable posting status comments #43

Merged
merged 7 commits into from
May 13, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
45 changes: 38 additions & 7 deletions Buildasaur/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -1338,7 +1338,7 @@
<constraints>
<constraint firstAttribute="height" constant="56" id="7Nb-aF-8GR"/>
</constraints>
<scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="YES" id="dZ6-jK-9d0">
<scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" doubleValue="0.5" horizontal="YES" id="dZ6-jK-9d0">
<rect key="frame" x="1" y="117.29037600755692" width="237" height="16"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
Expand Down Expand Up @@ -1434,7 +1434,7 @@
<constraints>
<constraint firstAttribute="height" constant="113" id="akl-ae-qWk"/>
</constraints>
<scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="YES" id="RFK-qC-17J">
<scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" doubleValue="1" horizontal="YES" id="RFK-qC-17J">
<rect key="frame" x="1" y="117.52239549160004" width="237" height="16"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
Expand Down Expand Up @@ -1860,8 +1860,11 @@
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="JKR-Sp-m8Y">
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="JKR-Sp-m8Y">
<rect key="frame" x="20" y="124" width="169" height="19"/>
<constraints>
<constraint firstAttribute="width" constant="169" id="OyQ-h8-Dln"/>
</constraints>
<buttonCell key="cell" type="roundTextured" title="Manual Bot Management" bezelStyle="texturedRounded" alignment="center" controlSize="small" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="hR5-Ym-8aa">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="smallSystem"/>
Expand All @@ -1870,15 +1873,15 @@
<action selector="manualBotManagementTapped:" target="RHg-5W-Hb1" id="u8a-Hh-JeY"/>
</connections>
</button>
<button fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="SL5-bS-Lf1">
<rect key="frame" x="46" y="42" width="130" height="18"/>
<button translatesAutoresizingMaskIntoConstraints="NO" id="SL5-bS-Lf1">
<rect key="frame" x="97" y="57" width="109" height="18"/>
<buttonCell key="cell" type="check" title="Wait for &quot;lttm&quot;" bezelStyle="regularSquare" imagePosition="right" state="on" inset="2" id="Qky-j0-ffo">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
</button>
<button horizontalHuggingPriority="750" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="BkU-KL-lMX">
<rect key="frame" x="18" y="36" width="25" height="25"/>
<button horizontalHuggingPriority="750" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="BkU-KL-lMX">
<rect key="frame" x="8" y="51" width="25" height="25"/>
<buttonCell key="cell" type="help" bezelStyle="helpButton" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="Pce-dC-RwH">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
Expand All @@ -1887,26 +1890,54 @@
<action selector="helpLttmButtonTapped:" target="RHg-5W-Hb1" id="HyJ-tw-2fB"/>
</connections>
</button>
<button translatesAutoresizingMaskIntoConstraints="NO" id="I34-eZ-a6k">
<rect key="frame" x="41" y="34" width="165" height="18"/>
<buttonCell key="cell" type="check" title="Post Status Comments" bezelStyle="regularSquare" imagePosition="right" state="on" inset="2" id="iGN-fv-G4G">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
</button>
<button horizontalHuggingPriority="750" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="t3o-Ag-QHY">
<rect key="frame" x="8" y="30" width="25" height="25"/>
<buttonCell key="cell" type="help" bezelStyle="helpButton" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="hoN-6R-mFO">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="helpPostStatusCommentsButtonTapped:" target="RHg-5W-Hb1" id="EYM-w9-DOh"/>
</connections>
</button>
</subviews>
<constraints>
<constraint firstItem="A9h-Jh-CP9" firstAttribute="top" secondItem="I34-eZ-a6k" secondAttribute="bottom" constant="6" id="3dX-AM-Tlf"/>
<constraint firstItem="8VZ-bw-dT5" firstAttribute="top" secondItem="zNe-bD-Pj4" secondAttribute="top" constant="5" id="Idf-Wk-1a9"/>
<constraint firstItem="t3o-Ag-QHY" firstAttribute="centerX" secondItem="BkU-KL-lMX" secondAttribute="centerX" id="JBt-fO-4Qt"/>
<constraint firstItem="SL5-bS-Lf1" firstAttribute="trailing" secondItem="I34-eZ-a6k" secondAttribute="trailing" id="K0Z-Rf-B9m"/>
<constraint firstAttribute="trailing" secondItem="8VZ-bw-dT5" secondAttribute="trailing" constant="7" id="KhO-CN-dKQ"/>
<constraint firstItem="JKR-Sp-m8Y" firstAttribute="top" secondItem="zNe-bD-Pj4" secondAttribute="top" constant="5" id="P0S-FI-EdB"/>
<constraint firstAttribute="centerY" secondItem="Fkq-gK-hvs" secondAttribute="centerY" constant="20" id="Tyj-fy-PKg"/>
<constraint firstAttribute="bottom" secondItem="8VZ-bw-dT5" secondAttribute="bottom" constant="8" id="VKM-vY-EPh"/>
<constraint firstItem="Fkq-gK-hvs" firstAttribute="centerY" secondItem="cYi-gZ-3MX" secondAttribute="centerY" constant="-0.5" id="Vmg-bM-hj9"/>
<constraint firstItem="SL5-bS-Lf1" firstAttribute="centerY" secondItem="BkU-KL-lMX" secondAttribute="centerY" constant="-1.5" id="arW-Yk-6ql"/>
<constraint firstItem="Fkq-gK-hvs" firstAttribute="leading" secondItem="5mg-80-kNh" secondAttribute="leading" id="cG9-Du-imO"/>
<constraint firstAttribute="bottom" secondItem="5mg-80-kNh" secondAttribute="bottom" constant="10" id="cJp-rk-CCh"/>
<constraint firstItem="8VZ-bw-dT5" firstAttribute="leading" secondItem="XOz-yR-q3G" secondAttribute="trailing" constant="24" id="cwr-61-Au2"/>
<constraint firstItem="XOz-yR-q3G" firstAttribute="leading" secondItem="A9h-Jh-CP9" secondAttribute="trailing" constant="3" id="d8B-OU-HKq"/>
<constraint firstItem="t3o-Ag-QHY" firstAttribute="leading" secondItem="zNe-bD-Pj4" secondAttribute="leading" constant="10" id="gL4-h3-Znl"/>
<constraint firstItem="JKR-Sp-m8Y" firstAttribute="leading" secondItem="Fkq-gK-hvs" secondAttribute="leading" id="gvn-Js-kCf"/>
<constraint firstItem="A9h-Jh-CP9" firstAttribute="centerY" secondItem="XOz-yR-q3G" secondAttribute="centerY" id="iRF-ex-h9B"/>
<constraint firstItem="I34-eZ-a6k" firstAttribute="top" secondItem="SL5-bS-Lf1" secondAttribute="bottom" constant="9" id="iY6-IQ-EOK"/>
<constraint firstItem="I34-eZ-a6k" firstAttribute="centerY" secondItem="t3o-Ag-QHY" secondAttribute="centerY" constant="0.5" id="idz-E5-OE3"/>
<constraint firstItem="A9h-Jh-CP9" firstAttribute="baseline" secondItem="5mg-80-kNh" secondAttribute="baseline" id="n8b-gL-QIi"/>
<constraint firstItem="A9h-Jh-CP9" firstAttribute="leading" secondItem="5mg-80-kNh" secondAttribute="trailing" constant="12" id="s3n-tF-0xA"/>
<constraint firstItem="I34-eZ-a6k" firstAttribute="leading" secondItem="t3o-Ag-QHY" secondAttribute="trailing" constant="12" id="shw-I6-mBG"/>
<constraint firstItem="Fkq-gK-hvs" firstAttribute="leading" secondItem="zNe-bD-Pj4" secondAttribute="leading" constant="20" id="tAH-BV-LCf"/>
<constraint firstItem="cYi-gZ-3MX" firstAttribute="leading" secondItem="Fkq-gK-hvs" secondAttribute="trailing" constant="14" id="wg4-z7-3io"/>
</constraints>
</view>
<connections>
<outlet property="lttmToggle" destination="SL5-bS-Lf1" id="0d3-tb-sVO"/>
<outlet property="postStatusCommentsToggle" destination="I34-eZ-a6k" id="DbA-bD-uId"/>
<outlet property="startStopButton" destination="Fkq-gK-hvs" id="5Ba-3L-5FZ"/>
<outlet property="statusActivityIndicator" destination="cYi-gZ-3MX" id="5l5-14-v81"/>
<outlet property="statusTextField" destination="8VZ-bw-dT5" id="Uav-J8-RH3"/>
Expand Down
13 changes: 11 additions & 2 deletions Buildasaur/HDGitHubXCBotSyncer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,18 @@ public class HDGitHubXCBotSyncer : Syncer {
let xcodeServer: XcodeServer!
let localSource: LocalSource!
let waitForLttm: Bool
let postStatusComments: Bool

typealias GitHubStatusAndComment = (status: Status, comment: String?)

init(integrationServer: XcodeServer, sourceServer: GitHubServer, localSource: LocalSource, syncInterval: NSTimeInterval, waitForLttm: Bool) {
init(integrationServer: XcodeServer, sourceServer: GitHubServer, localSource: LocalSource,
syncInterval: NSTimeInterval, waitForLttm: Bool, postStatusComments: Bool) {

self.github = sourceServer
self.xcodeServer = integrationServer
self.localSource = localSource
self.waitForLttm = waitForLttm
self.postStatusComments = postStatusComments
super.init(syncInterval: syncInterval)
}

Expand All @@ -42,6 +45,7 @@ public class HDGitHubXCBotSyncer : Syncer {
self.github = GitHubFactory.server(project.githubToken)
self.xcodeServer = XcodeServerFactory.server(serverConfig)
self.waitForLttm = json.optionalBoolForKey("wait_for_lttm") ?? true
self.postStatusComments = json.optionalBoolForKey("post_status_comments") ?? true
super.init(syncInterval: syncInterval)

} else {
Expand All @@ -50,6 +54,7 @@ public class HDGitHubXCBotSyncer : Syncer {
self.xcodeServer = nil
self.localSource = nil
self.waitForLttm = true
self.postStatusComments = true
super.init(syncInterval: 0)
return nil
}
Expand All @@ -62,6 +67,7 @@ public class HDGitHubXCBotSyncer : Syncer {
dict["project_path"] = self.localSource.url.absoluteString
dict["server_host"] = self.xcodeServer.config.host
dict["wait_for_lttm"] = self.waitForLttm
dict["post_status_comments"] = self.postStatusComments
return dict
}

Expand Down Expand Up @@ -549,8 +555,11 @@ public class HDGitHubXCBotSyncer : Syncer {
return
}

//have a chance to NOT post a status comment...
let postStatusComments = self.postStatusComments

//optional there can be a comment to be posted as well
if let comment = statusWithComment.comment {
if let comment = statusWithComment.comment where postStatusComments {

//we have a comment, post it
self.github.postCommentOnIssue(comment, issueNumber: pr.number, repo: repo, completion: { (comment, error) -> () in
Expand Down
12 changes: 8 additions & 4 deletions Buildasaur/Images.xcassets/AppIcon.appiconset/Contents.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
{
"images" : [
{
"idiom" : "mac",
"size" : "16x16",
"idiom" : "mac",
"filename" : "builda_icon@16x.png",
"scale" : "1x"
},
{
"idiom" : "mac",
"size" : "16x16",
"idiom" : "mac",
"filename" : "builda_icon@32x-2.png",
"scale" : "2x"
},
{
"idiom" : "mac",
"size" : "32x32",
"idiom" : "mac",
"filename" : "builda_icon@32x.png",
"scale" : "1x"
},
{
"idiom" : "mac",
"size" : "32x32",
"idiom" : "mac",
"filename" : "builda_icon@64x.png",
"scale" : "2x"
},
{
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 15 additions & 1 deletion Buildasaur/StatusSyncerViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class StatusSyncerViewController: StatusViewController, SyncerDelegate {
@IBOutlet weak var syncIntervalStepper: NSStepper!
@IBOutlet weak var syncIntervalTextField: NSTextField!
@IBOutlet weak var lttmToggle: NSButton!
@IBOutlet weak var postStatusCommentsToggle: NSButton!

var isSyncing: Bool {
set {
Expand Down Expand Up @@ -136,6 +137,7 @@ class StatusSyncerViewController: StatusViewController, SyncerDelegate {
self.startStopButton.title = self.isSyncing ? "Stop" : "Start"
self.syncIntervalStepper.enabled = !self.isSyncing
self.lttmToggle.enabled = !self.isSyncing
self.postStatusCommentsToggle.enabled = !self.isSyncing

if self.isSyncing {
self.statusActivityIndicator.startAnimation(nil)
Expand All @@ -147,9 +149,11 @@ class StatusSyncerViewController: StatusViewController, SyncerDelegate {

self.updateIntervalFromUIToValue(syncer.syncInterval)
self.lttmToggle.state = syncer.waitForLttm ? NSOnState : NSOffState
self.postStatusCommentsToggle.state = syncer.postStatusComments ? NSOnState : NSOffState
} else {
self.updateIntervalFromUIToValue(15) //default
self.lttmToggle.state = NSOnState //default is true
self.postStatusCommentsToggle.state = NSOnState //default is true
}
}

Expand Down Expand Up @@ -191,6 +195,14 @@ class StatusSyncerViewController: StatusViewController, SyncerDelegate {
}
}

@IBAction func helpPostStatusCommentsButtonTapped(sender: AnyObject) {

let urlString = "https://github.com/czechboy0/Buildasaur/blob/master/README.md#posting-status-comments"
if let url = NSURL(string: urlString) {
NSWorkspace.sharedWorkspace().openURL(url)
}
}

override func prepareForSegue(segue: NSStoryboardSegue, sender: AnyObject?) {

if let manual = segue.destinationController as? ManualBotManagementViewController {
Expand All @@ -208,11 +220,13 @@ class StatusSyncerViewController: StatusViewController, SyncerDelegate {
}

let waitForLttm = self.lttmToggle.state == NSOnState
let postStatusComments = self.postStatusCommentsToggle.state == NSOnState
let syncInterval = self.syncIntervalTextField.doubleValue
let project = self.delegate.getProjectStatusViewController().project()!
let serverConfig = self.delegate.getServerStatusViewController().serverConfig()!

if let syncer = self.storageManager.addSyncer(syncInterval, waitForLttm: waitForLttm, project: project, serverConfig: serverConfig) {
if let syncer = self.storageManager.addSyncer(syncInterval, waitForLttm: waitForLttm, postStatusComments: postStatusComments,
project: project, serverConfig: serverConfig) {

syncer.active = true

Expand Down
6 changes: 4 additions & 2 deletions Buildasaur/StorageManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ class StorageManager {
self.servers.append(config)
}

func addSyncer(syncInterval: NSTimeInterval, waitForLttm: Bool, project: LocalSource, serverConfig: XcodeServerConfig) -> HDGitHubXCBotSyncer? {
func addSyncer(syncInterval: NSTimeInterval, waitForLttm: Bool, postStatusComments: Bool,
project: LocalSource, serverConfig: XcodeServerConfig) -> HDGitHubXCBotSyncer? {

if syncInterval <= 0 {
Log.error("Sync interval must be > 0 seconds.")
Expand All @@ -61,7 +62,8 @@ class StorageManager {

let xcodeServer = XcodeServerFactory.server(serverConfig)
let github = GitHubFactory.server(project.githubToken)
let syncer = HDGitHubXCBotSyncer(integrationServer: xcodeServer, sourceServer: github, localSource: project, syncInterval: syncInterval, waitForLttm: waitForLttm)
let syncer = HDGitHubXCBotSyncer(integrationServer: xcodeServer, sourceServer: github, localSource: project,
syncInterval: syncInterval, waitForLttm: waitForLttm, postStatusComments: postStatusComments)
self.syncers.append(syncer)
return syncer
}
Expand Down
Binary file added Meta/comment.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading