Skip to content

Commit 0731388

Browse files
author
R0n0066
committed
update (utils): Add staging check to working tree
1 parent 0098e1a commit 0731388

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

cmd/utils.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import (
2424
"errors"
2525
"fmt"
2626
"os"
27-
"regexp"
2827
"strings"
2928
"time"
3029

@@ -119,9 +118,14 @@ func commit(message string) (err error) {
119118
s, err := w.Status()
120119
checkErr(err)
121120

122-
m, _ := regexp.MatchString("A .*", s.String())
121+
hasStagingFiles := false
122+
for _, status := range s {
123+
if status.Staging == 77 {
124+
hasStagingFiles = true
125+
}
126+
}
123127

124-
if m {
128+
if hasStagingFiles {
125129
username, err := gitconfig.Username()
126130
email, err := gitconfig.Email()
127131

0 commit comments

Comments
 (0)