Skip to content

Commit 1e74b49

Browse files
committed
✨ changed to trim filepathes if it overflows the specified length in commit message (src/cmd/root.go)
1 parent 66bed3b commit 1e74b49

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

src/cmd/root.go

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,26 +65,35 @@ func gitCommit(prefix string, subject string) {
6565
wg.Wait()
6666

6767
_, emoji := lib.IncludeGitimoji(prefix)
68+
appConfig := lib.GetAppConfig()
6869

69-
aliases := lib.GetAppConfig()
7070
gitChange = strings.ReplaceAll(gitChange, "\n", ", ")
7171

72-
var commitMsg string
72+
var commigMessage string
7373

74-
if *aliases.WriteEmoji {
74+
var message string
7575

76+
if *appConfig.WriteEmoji {
7677
if emoji != "" {
7778
prefix = emoji
78-
commitMsg = fmt.Sprintf("%s %s (%s)", prefix, subject, gitChange)
7979
} else {
80-
commitMsg = fmt.Sprintf(":%s: %s (%s)", prefix, subject, gitChange)
80+
prefix = fmt.Sprintf(":%s:", prefix)
81+
}
82+
}
83+
84+
if *appConfig.UseLimitPathesLength {
85+
if *appConfig.LimitPathesLength < len([]rune(gitChange)) {
86+
gitChange = fmt.Sprintf("%s...", gitChange[:*appConfig.LimitPathesLength])
8187
}
8288

89+
message = fmt.Sprintf("%s (%s)", subject, gitChange)
8390
} else {
84-
commitMsg = fmt.Sprintf(":%s: %s (%s)", prefix, subject, gitChange)
91+
message = fmt.Sprintf("%s", subject)
8592
}
8693

87-
cmd := exec.Command("git", "commit", "-m", commitMsg)
94+
commigMessage = fmt.Sprintf("%s %s", prefix, message)
95+
96+
cmd := exec.Command("git", "commit", "-m", commigMessage)
8897
_, err = cmd.Output()
8998
if err != nil {
9099
log.ErrorExit(err)

0 commit comments

Comments
 (0)