Skip to content

Commit 84274c7

Browse files
committed
Refine regex to better support windows
1 parent 2d47386 commit 84274c7

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

project/project.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ var (
3434
"post-commit": {
3535
Exe: "gtm",
3636
Command: "gtm commit --yes",
37-
RE: regexp.MustCompile(`(?s)[/,:,a-z,A-Z,0-9,$,-,_,=, ]*gtm(.exe|)\s+commit\s+--yes\.*`)},
37+
RE: regexp.MustCompile(`(?s)[/,\,:,a-z,A-Z,0-9,$,-,_,=,(,),",., ]*gtm(.exe"|)\s+commit\s+--yes\.*`)},
3838
}
3939
// GitConfig is map of git configuration settings
4040
GitConfig = map[string]string{

scm/git.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,11 @@ func RemoveHooks(hooks map[string]GitHook, wd ...string) error {
680680
output := string(b)
681681

682682
if hook.RE.MatchString(output) {
683-
output := strings.Replace(hook.RE.ReplaceAllString(output, ""), "\n\n", "\n", 1)
683+
output := hook.RE.ReplaceAllString(output, "")
684+
i := strings.LastIndexAny(output, "\n")
685+
if i > -1 {
686+
output = output[0:i]
687+
}
684688
if err = ioutil.WriteFile(fp, []byte(output), 0755); err != nil {
685689
return err
686690
}

0 commit comments

Comments
 (0)