Skip to content

Commit cdf5381

Browse files
committed
wip + screenshots
1 parent 7ca6aa2 commit cdf5381

File tree

7 files changed

+27
-6
lines changed

7 files changed

+27
-6
lines changed

Other/screenshot1.png

8.61 MB
Loading

Other/screenshot2.png

8.53 MB
Loading

Other/screenshot3.png

8.48 MB
Loading

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# SwiftGit
22

3+
<table>
4+
<tr>
5+
<td><img src="https://github.com/LiveUI/SwiftGit/blob/master/Other/screenshot1.png?raw=true" alt="" /></td>
6+
<td><img src="https://github.com/LiveUI/SwiftGit/blob/master/Other/screenshot2.png?raw=true" alt="" /></td>
7+
<td><img src="https://github.com/LiveUI/SwiftGit/blob/master/Other/screenshot3.png?raw=true" alt="" /></td>
8+
</tr>
9+
</table>
10+
311
## Use
412
* Run `carthage update --platform osx --cache-builds` to install dependencies, run the app
513

SwiftGit/AppDelegate.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,20 +98,20 @@ class AppDelegate: NSObject, NSApplicationDelegate {
9898
@objc func commit(_ sender: NSMenuItem) {
9999
let storyboard = NSStoryboard(name: "Main", bundle: nil)
100100
let windowController = storyboard.instantiateController(withIdentifier: "Commit Window Controller") as! NSWindowController
101+
guard let path = sender.project.path else { return }
102+
var context = CustomContext()
103+
context.currentdirectory = path
101104
if let commitWindow = windowController.window {
102105
let controller = commitWindow.contentViewController as! CommitViewController
103106
controller.project = sender.project
104107
controller.cancel = {
105108
windowController.close()
106109
}
107110
controller.stageAll = {
108-
guard let path = sender.project.path else { return }
109-
var context = CustomContext()
110-
context.currentdirectory = path
111111
try? context.runAndPrint("git", "add", ".", "-A")
112112
}
113113
controller.commit = { commitMessage in
114-
sender.project.repo?.commit(message: commitMessage, signature: Signature(name: "", email: <#T##String#>))
114+
try? context.runAndPrint("git", "commit", "-m", commitMessage)
115115
}
116116

117117
NSApplication.shared.runModal(for: commitWindow)

SwiftGit/Commit/CommitViewController.swift

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import Reloaded
1212
import SwiftGit2
1313

1414

15-
class CommitViewController: NSViewController, NSTextViewDelegate {
15+
class CommitViewController: NSViewController, NSTextViewDelegate, NSTextFieldDelegate {
1616

1717
var project: Project!
1818

@@ -26,6 +26,8 @@ class CommitViewController: NSViewController, NSTextViewDelegate {
2626
var cancel: (() -> Void)?
2727
var stageAll: (() -> Void)?
2828

29+
// MARK: View lifecycle
30+
2931
override func viewWillAppear() {
3032
super.viewWillAppear()
3133

@@ -49,11 +51,15 @@ class CommitViewController: NSViewController, NSTextViewDelegate {
4951
NSApplication.shared.stopModal()
5052
}
5153

54+
// MARK: Delegate methods
55+
5256
func textDidChange(_ notification: Notification) {
5357
project.lastCommitMessage = (notification.object as? NSTextView)?.string
5458
try! project.save()
5559
}
5660

61+
// MARK: Actions
62+
5763
@IBAction func stageMissing(_ sender: NSButton) {
5864
stageAll?()
5965

@@ -70,6 +76,12 @@ class CommitViewController: NSViewController, NSTextViewDelegate {
7076
}
7177

7278
@IBAction func makeCommit(_ sender: NSButton) {
79+
guard !textView.string.isEmpty else {
80+
81+
return
82+
}
83+
sender.isEnabled = false
84+
7385
project.lastCommitMessage = ""
7486
try! project.save()
7587

@@ -96,6 +108,7 @@ extension CommitViewController: NSTableViewDelegate, NSTableViewDataSource {
96108
let status = statuses[row]
97109
if let cell = cell as? NSButtonCell {
98110
cell.state = status.status.isStaged ? .on : .off
111+
cell.isEnabled = false
99112
} else if let cell = cell as? NSTextFieldCell {
100113
cell.stringValue = status.title
101114
}

SwiftGit/Supporting files/Main.storyboard

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@
151151
<constraints>
152152
<constraint firstItem="1jw-vR-zhQ" firstAttribute="leading" secondItem="wmF-MI-4cx" secondAttribute="trailing" constant="8" id="6mh-F6-Ckk"/>
153153
<constraint firstItem="5S1-3e-rr4" firstAttribute="top" secondItem="Fho-b9-dLP" secondAttribute="top" constant="13" id="8Bv-9i-r2M"/>
154+
<constraint firstItem="wsE-wg-062" firstAttribute="top" secondItem="1jw-vR-zhQ" secondAttribute="bottom" constant="8" id="J5k-wo-uwm"/>
154155
<constraint firstItem="mjK-Ba-m8L" firstAttribute="leading" secondItem="Fho-b9-dLP" secondAttribute="leading" constant="8" id="QLH-9y-Ltx"/>
155156
<constraint firstAttribute="bottom" secondItem="wsE-wg-062" secondAttribute="bottom" constant="10" id="Scn-4P-lNP"/>
156157
<constraint firstAttribute="trailing" secondItem="wsE-wg-062" secondAttribute="trailing" constant="8" id="TCX-FG-iYE"/>
@@ -161,7 +162,6 @@
161162
<constraint firstItem="1jw-vR-zhQ" firstAttribute="top" secondItem="5S1-3e-rr4" secondAttribute="bottom" constant="8" id="jgb-JG-rr4"/>
162163
<constraint firstItem="wmF-MI-4cx" firstAttribute="leading" secondItem="Fho-b9-dLP" secondAttribute="leading" constant="8" id="kLR-mp-qPk"/>
163164
<constraint firstAttribute="trailing" secondItem="1jw-vR-zhQ" secondAttribute="trailing" constant="8" id="ymd-G5-i6F"/>
164-
<constraint firstItem="wsE-wg-062" firstAttribute="top" secondItem="1jw-vR-zhQ" secondAttribute="bottom" constant="8" id="z7k-wP-v5V"/>
165165
</constraints>
166166
</view>
167167
<connections>

0 commit comments

Comments
 (0)