Documentation
¶
Index ¶
- Constants
- Variables
- func ContainsNewline(s string) bool
- func ContainsWhiteSpace(s string) bool
- func Execute()
- func GitAdd(fp string)
- func GitAddAll()
- func GitCommit(msg string)
- func GitRm(fp string)
- func IsBrkChnFooter(token string) bool
- func MatchFooters(str string) []string
- func ParseFooter(f string) (token, sep, val string)
- func TrimFooter(s string) string
- type CommitFooters
- type CommitMsg
Constants ¶
const ( // CodeAddedNotStaged added not staged CodeAddedNotStaged = " A" // CodeModifiedNotStaged modified not staged CodeModifiedNotStaged = " M" // CodeDeletedNotStaged deleted not staged CodeDeletedNotStaged = " D" // CodeRenamedNotStaged renamed in work tree not staged // not common, `git rename` will automatically stage the changes CodeRenamedNotStaged = " R" // CodeCopiedNotStaged copied in work tree not staged // not common, TODO: verify usage CodeCopiedNotStaged = " C" // CodeUntracked untracked CodeUntracked = "??" // PathSepArrow path separator if file is moved or copied PathSepArrow = "->" )
const ( // RequiredType error msg of missing type RequiredType = "commit type is required" // RequiredDesc error msg of missing description RequiredDesc = "commit description is required" // InvalidType error msg of invalid type InvalidType = "commit type is invalid" // InvalidScope error msg of invalid scope InvalidScope = "commit scope is invalid" // InvalidDesc error msg of invalid description InvalidDesc = "commit description is invalid" // InvalidBrkChnFTSep error msg of invalid breaking change footer separator InvalidBrkChnFTSep = "breaking change footer separator is invalid" // RequiredBrkChnFTDesc error msg of missing breaking footer description RequiredBrkChnFTDesc = "breaking change footer description is required" InvalidFooter = "commit footer is invalid" InvalidFooterToken = "commit footer token is invalid" // FTokenBrkChange special footer token FTokenBrkChange = "BREAKING CHANGE" // FTokenBrkChangeAlias FTokenBrkChange alias FTokenBrkChangeAlias = "BREAKING-CHANGE" // FSepColonSpace footer separator FSepColonSpace = ": " // FSepSpaceSharp footer separator FSepSpaceSharp = " #" )
const CommitMsgTmpl = `` /* 178-byte string literal not displayed */
CommitMsgTmpl template for building commit message
const GitExec = "git"
GitExec git executable name
const VersionTmpl = `
{{- .Name}} {{.Version}}
`
VersionTmpl version template for --version output
Variables ¶
{
Name: "footers",
Prompt: &survey.Multiline{
Message: "Enter optional footers:",
},
},
}FootersQuestions ask footers input separately to handle custom parse logic
var PresetCommitTypes = []string{"fix", "feat", "build", "chore", "ci", "docs", "perf", "refactor", "style", "test"}
PresetCommitTypes conventional commits suggested types
var UnstagedShortCodes = []string{ CodeAddedNotStaged, CodeModifiedNotStaged, CodeDeletedNotStaged, CodeRenamedNotStaged, CodeCopiedNotStaged, CodeUntracked, }
UnstagedShortCodes git status --short output XY code of not staged files
Functions ¶
func ContainsNewline ¶
ContainsNewline check if string contains newline chars
func ContainsWhiteSpace ¶
ContainsWhiteSpace check if string contains whitesapces
func Execute ¶
func Execute()
Execute adds all child commands to the root command and sets flags appropriately. This is called by main.main(). It only needs to happen once to the rootCmd.
func GitRm ¶ added in v0.1.1
func GitRm(fp string)
GitRm exec `git rm` to stage changes of a deleted file
func IsBrkChnFooter ¶
IsBrkChnFooter check if token is breaking change footer token
func MatchFooters ¶ added in v0.1.3
MatchFooters takes raw footers input string and return string slice of found footers. Match <token + sep>, find indices and take values in between Caveats: "BREAKING CHANGE #" is not matched, for " #" is not valid separator for breaking change, instead, "CHANGE #" is matched
func ParseFooter ¶
ParseFooter return components of a commit msg footer if seperable by ": " or " #" @param f footer without no newlines @return token "" if separated wrongly @return sep "" if separated wrongly @return val "" if separated wrongly
func TrimFooter ¶ added in v0.1.3
TrimFooter separator space should not be trimed if no footer value Whitespace trimmed value may contains leading "#" or trailing ":", treat it as intention to mean a separator, add the space back
Types ¶
type CommitFooters ¶ added in v0.1.3
type CommitFooters struct {
}CommitFooters helper struct for separate survey with custom Setter
func (*CommitFooters) WriteAnswer ¶ added in v0.1.3
func (ft *CommitFooters) WriteAnswer(name string, value interface{}) error
WriteAnswer implements Settable interface of CommitMsg for survey assign string input to parsed footer slice
type CommitMsg ¶
type CommitMsg struct { Type string `survey:"type"` // required, preset or config values only Scope string `survey:"scope"` // optional HasBrkChange bool `survey:"breaking"` // optional, default false Description string `survey:"description"` // required, no line break Body string `survey:"body"` // optional, allow line breaks }
CommitMsg properties
func (*CommitMsg) Commit ¶ added in v0.1.1
func (cm *CommitMsg) Commit()
Commit validate and git commit the CommitMsg
func (*CommitMsg) Prompt ¶ added in v0.2.0
func (cm *CommitMsg) Prompt()
Prompt use interactive prompts to build the commit message