mirror of
https://github.com/thegeeklab/git-sv.git
synced 2024-11-21 22:10:39 +00:00
feat: use configured commit types on commit comand
This commit is contained in:
parent
dd5b15af22
commit
e67ae6c859
@ -265,7 +265,7 @@ func tagHandler(git sv.Git, semverProcessor sv.SemVerCommitsProcessor) func(c *c
|
|||||||
func commitHandler(cfg Config, git sv.Git, messageProcessor sv.MessageProcessor) func(c *cli.Context) error {
|
func commitHandler(cfg Config, git sv.Git, messageProcessor sv.MessageProcessor) func(c *cli.Context) error {
|
||||||
return func(c *cli.Context) error {
|
return func(c *cli.Context) error {
|
||||||
|
|
||||||
ctype, err := promptType()
|
ctype, err := promptType(cfg.CommitMessage.Types)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -14,18 +14,28 @@ type commitType struct {
|
|||||||
Example string
|
Example string
|
||||||
}
|
}
|
||||||
|
|
||||||
func promptType() (commitType, error) {
|
func promptType(types []string) (commitType, error) {
|
||||||
items := []commitType{
|
defaultTypes := map[string]commitType{
|
||||||
{Type: "build", Description: "changes that affect the build system or external dependencies", Example: "gradle, maven, go mod, npm"},
|
"build": {Type: "build", Description: "changes that affect the build system or external dependencies", Example: "gradle, maven, go mod, npm"},
|
||||||
{Type: "ci", Description: "changes to our CI configuration files and scripts", Example: "Circle, BrowserStack, SauceLabs"},
|
"ci": {Type: "ci", Description: "changes to our CI configuration files and scripts", Example: "Circle, BrowserStack, SauceLabs"},
|
||||||
{Type: "chore", Description: "update something without impacting the user", Example: "gitignore"},
|
"chore": {Type: "chore", Description: "update something without impacting the user", Example: "gitignore"},
|
||||||
{Type: "docs", Description: "documentation only changes"},
|
"docs": {Type: "docs", Description: "documentation only changes"},
|
||||||
{Type: "feat", Description: "a new feature"},
|
"feat": {Type: "feat", Description: "a new feature"},
|
||||||
{Type: "fix", Description: "a bug fix"},
|
"fix": {Type: "fix", Description: "a bug fix"},
|
||||||
{Type: "perf", Description: "a code change that improves performance"},
|
"perf": {Type: "perf", Description: "a code change that improves performance"},
|
||||||
{Type: "refactor", Description: "a code change that neither fixes a bug nor adds a feature"},
|
"refactor": {Type: "refactor", Description: "a code change that neither fixes a bug nor adds a feature"},
|
||||||
{Type: "style", Description: "changes that do not affect the meaning of the code", Example: "white-space, formatting, missing semi-colons, etc"},
|
"style": {Type: "style", Description: "changes that do not affect the meaning of the code", Example: "white-space, formatting, missing semi-colons, etc"},
|
||||||
{Type: "test", Description: "adding missing tests or correcting existing tests"},
|
"test": {Type: "test", Description: "adding missing tests or correcting existing tests"},
|
||||||
|
"revert": {Type: "revert", Description: "revert a single commit"},
|
||||||
|
}
|
||||||
|
|
||||||
|
var items []commitType
|
||||||
|
for _, t := range types {
|
||||||
|
if v, exists := defaultTypes[t]; exists {
|
||||||
|
items = append(items, v)
|
||||||
|
} else {
|
||||||
|
items = append(items, commitType{Type: t})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template := &promptui.SelectTemplates{
|
template := &promptui.SelectTemplates{
|
||||||
|
Loading…
Reference in New Issue
Block a user