From 012f13c7457ef27b21c74a7cbdda113fb95f5736 Mon Sep 17 00:00:00 2001 From: YeyoM Date: Mon, 1 Jul 2024 11:03:57 -0600 Subject: [PATCH] feat: :fire: Added description checking --- main.go | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/main.go b/main.go index 559d36b..205c0e0 100644 --- a/main.go +++ b/main.go @@ -6,7 +6,6 @@ import ( "os/exec" "strings" "time" - //"unicode" tea "github.com/charmbracelet/bubbletea" @@ -235,35 +234,40 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { if msg.String() == "enter" { switch m.currentStep { - case -1: + case -1: // check if there are changes to commit if m.canCommit && !m.noChanges { m.currentStep++ } return m, nil - case 0: + case 0: // step 1 -> select the type of change (required) m.currentStep++ if m.commitType == "" { m.commitType = "feat" } return m, nil - case 1: + case 1: // step 2 -> what is the scope of this change (optional) m.currentStep++ return m, nil - case 2: + case 2: // step 3 -> select a gitmoji for the commit (optional) m.currentStep++ return m, nil - case 3: + case 3: // step 4 -> write a short, imperative tense description of the change (required) + if m.description == "" { + docStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("9")).Margin(1, 2) // change the color to red + return m, nil + } + docStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("#fff")).Margin(1, 2) // change the color back to white m.currentStep++ return m, nil - case 4: + case 4: // step 5 -> provide a longer description of the change (optional) m.currentStep++ return m, nil - case 5: + case 5: // step 6 -> list any breaking changes or issues closed by this change (optional) m.currentStep++ return m, nil - case 6: + case 6: // step 7 -> display the commit message (preview) m.CommitChanges() - time.Sleep(5 * time.Second) + time.Sleep(2 * time.Second) m.currentStep++ return m, nil default: @@ -500,16 +504,6 @@ func (m model) CommitChanges() { return } - // Split the output by newlines and trim leading whitespace from each line - // lines := strings.Split(string(output), "\n") - // fmt.Println(lines) - // for _, line := range lines { - // trimmedLine := strings.TrimLeftFunc(line, func(r rune) bool { - // return unicode.IsSpace(r) - // }) - // fmt.Println(trimmedLine) - // } - // Inform the user about the next steps with styles fmt.Println(successStyle.Render("Changes committed successfully. Now you can push the changes to the remote repository using: git push")) m.finished = true