forked from TLMcode/AHKs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GitCommit.ahk
54 lines (44 loc) · 1.58 KB
/
GitCommit.ahk
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
#include FcnLib.ahk
#include FcnLib-Misc.ahk
;make a commit in git
;maybe we need to make all of this prep stuff into a function
ForceWinFocus("MINGW32", "Contains")
SendInput, q{ENTER}
SendInput, clear{ENTER}
;SendInput, git add --all{ENTER} ;need something that will only stage new files
SendInput, git status{ENTER}
SendInput, git add -p{ENTER}
;TODO perhaps we should ask about the commit message at first,
;then say: "does this change relate to 'fixed invalid email'?"
; doing that may make my commit messages awesome and frequent
commitMessage := prompt("Specify a commit message:")
Loop
{
ret := prompt("Commit Message: " . commitMessage . "`nWould you like to include this item in the commit?")
ForceWinFocus("MINGW32", "Contains")
if (ret == "")
ExitApp
else if (ret == "f")
break
else if (ret == "a")
break
else if (strlen(ret) == 1)
SendInput, %ret%{ENTER}
else
break
}
ForceWinFocus("MINGW32", "Contains")
SendInput, q{ENTER}
if NOT commitMessage
ExitApp
;add all new files if they told us to...
if (ret == "a")
SendInput, git add --all{ENTER}
currentBranchName := GitGetCurrentBranchName()
issueNumber := GitGetIssueNumber(currentBranchName)
issueTitle := RemoveLineEndings(GitGetIssueTitle(issueNumber))
fullCommitMessage=%issueNumber% - %issueTitle% - %commitMessage%
fullCommitMessage := StringReplace(fullCommitMessage, """", "'")
fullCommitMessage := RegExReplace(fullCommitMessage, " +", " ")
ForceWinFocus("MINGW32", "Contains")
SendInput, git ci -m"%fullCommitMessage%"{ENTER}