generated from AndreasAugustin/template
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat (msg): add nice commit msg format 🎉
- Loading branch information
1 parent
cb0c367
commit f059a8f
Showing
4 changed files
with
75 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package pkg | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
) | ||
|
||
func BuildCommitTitle(_type string, scope string, isBreaking bool, desc string, gitmoji Gitmoji, config Config) string { | ||
|
||
var s strings.Builder | ||
|
||
s.WriteString(_type) | ||
|
||
if scope != "" { | ||
s.WriteString(fmt.Sprintf("(%s)", scope)) | ||
} | ||
|
||
if isBreaking { | ||
s.WriteString("!") | ||
} | ||
|
||
s.WriteString(fmt.Sprintf(": %s ", gitmojiToString(gitmoji, config))) | ||
s.WriteString(eventualCapitalizeTitle(desc, config)) | ||
|
||
return s.String() | ||
} | ||
|
||
func gitmojiToString(gitmoji Gitmoji, config Config) string { | ||
if config.EmojiFormat == CODE { | ||
return gitmoji.Code | ||
} else { | ||
return gitmoji.Emoji | ||
} | ||
} | ||
|
||
func eventualCapitalizeTitle(title string, config Config) string { | ||
if config.CapitalizeTitle { | ||
return strings.ToUpper(title) | ||
} | ||
return title | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package pkg_test |