-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit_commitpush.js
More file actions
55 lines (41 loc) · 1.74 KB
/
Copy pathgit_commitpush.js
File metadata and controls
55 lines (41 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
%SCRIPT
filename = editor.fileName()
workdir = filename.substring(0, filename.lastIndexOf("/"))
d = new Date()
commitString = "TexStudio " + d.getFullYear() + "/" + ("0" + (d.getMonth() + 1)).slice(-2) + "/" +("0" + d.getDate()).slice(-2) + " " + ("0" + d.getHours()).slice(-2) + ":" +("0" + d.getMinutes()).slice(-2)
// Get current branch name
cmd = "git rev-parse --abbrev-ref HEAD >/dev/null 2>&1"
var proc = system(cmd, workingDirectory=workdir)
proc.waitForFinished()
statusMessage = proc.readAllStandardOutputStr()
branchName = statusMessage.trim()
// Create a new dialog box
dialog = new UniversalInputDialog()
dialog.setWindowTitle("Git Commit/Push")
dialog.add(true, "Push to remote repo","push")
dialog.add(commitString, "Comment","comment")
dialog.add(branchName, "Branch", "branch")
dialog.add(true, "Commit all Files","allfiles")
accepted = dialog.exec()
if ( accepted != null && accepted != 0) {
comment = dialog.get("comment")
if ((dialog.get("push")) == true) {
branch = dialog.get("branch")
if ((dialog.get("allfiles")) == true) {
buildManager.runCommand("git commit -a -m \"" + comment + "\"", filename)
buildManager.runCommand("git push origin \"" + branch + "\"",filename )
}
else {
buildManager.runCommand("git commit " + filename + " -m \"" + comment + "\"", filename)
buildManager.runCommand("git push origin \"" + branch + "\"",filename )
}
}
else {
if ((dialog.get("allfiles")) == true) {
buildManager.runCommand("git commit -a -m \"" + comment + "\"", filename)
}
else {
buildManager.runCommand("git commit " + filename + " -m \"" + comment + "\"", filename)
}
}
}