From dd264e48ab7046e6b32b5c41d65d2c9fefead0d8 Mon Sep 17 00:00:00 2001 From: 15ho Date: Thu, 3 Jul 2025 14:18:00 +0800 Subject: [PATCH] feat: change the commit message scope to optional change the commit message scope to optional Signed-off-by: 15ho --- git_wapper.go | 6 +++++- ui_commit_committing.go | 7 ++++++- ui_commit_inputs.go | 6 ------ 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/git_wapper.go b/git_wapper.go index 2df2b75..8cfac90 100644 --- a/git_wapper.go +++ b/git_wapper.go @@ -34,7 +34,11 @@ func commit(msg commitMsg) error { _ = os.Remove(f.Name()) }() - _, err = fmt.Fprintf(f, "%s(%s): %s\n\n%s\n\n%s\n\n%s\n", msg.Type, msg.Scope, msg.Subject, msg.Body, msg.Footer, msg.SOB) + var scope string + if msg.Scope != "" { + scope = "(" + msg.Scope + ")" + } + _, err = fmt.Fprintf(f, "%s%s: %s\n\n%s\n\n%s\n\n%s\n", msg.Type, scope, msg.Subject, msg.Body, msg.Footer, msg.SOB) if err != nil { return err } diff --git a/ui_commit_committing.go b/ui_commit_committing.go index 26bc25a..d01d868 100644 --- a/ui_commit_committing.go +++ b/ui_commit_committing.go @@ -1,6 +1,7 @@ package main import ( + "strings" "time" "github.com/charmbracelet/bubbles/spinner" @@ -114,7 +115,11 @@ func (m committingModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { } func (m committingModel) View() string { - header := committingTypeStyle.Render(m.msg.Type) + committingScopeStyle.Render("("+m.msg.Scope+")") + committingSubjectStyle.Render(": "+m.msg.Subject) + "\n" + var scope string + if strings.TrimSpace(m.msg.Scope) != "" { + scope = committingScopeStyle.Render("("+m.msg.Scope+")") + } + header := committingTypeStyle.Render(m.msg.Type) + scope + committingSubjectStyle.Render(": "+m.msg.Subject) + "\n" body := committingBodyStyle.Render(m.msg.Body) footer := committingFooterStyle.Render(m.msg.Footer+"\n"+m.msg.SOB) + "\n" diff --git a/ui_commit_inputs.go b/ui_commit_inputs.go index 4eb0ffe..0014dba 100644 --- a/ui_commit_inputs.go +++ b/ui_commit_inputs.go @@ -225,12 +225,6 @@ func newInputsModel() inputsModel { iwc.input.PromptStyle = inputsPromptFocusStyle iwc.input.TextStyle = inputsTextFocusStyle iwc.input.Focus() - iwc.checker = func(s string) error { - if strings.TrimSpace(s) == "" { - return errors.New("Scope cannot be empty") - } - return nil - } case 1: iwc.input.Prompt = "2. SUBJECT " iwc.input.PromptStyle = inputsPromptNormalStyle