fix: correct path when commit

main
sudo pacman -Syu 2022-07-03 23:37:42 +07:00 committed by sudo pacman -Syu
parent 7051e7fa89
commit ae9371b193
3 changed files with 6 additions and 4 deletions

View File

@ -72,7 +72,7 @@ func (a *action) RunGenerate(c *cli.Context) error {
if a.flags.autoCommit {
commitMsg := fmt.Sprintf(autoCommitMessageTemplate, version)
if err := repo.Commit(commitMsg, a.flags.filename, finalOutput); err != nil {
if err := repo.Commit(commitMsg, finalOutput); err != nil {
return err
}
}
@ -98,7 +98,7 @@ func (a *action) getConventionalCommits(commits []git.Commit) []convention.Commi
func (a *action) getFinalOutput() string {
nameWithExt := a.flags.filename + "." + a.flags.filetype
finalOutput := filepath.Join(a.flags.output, nameWithExt)
finalOutput := filepath.Join(a.flags.repository, a.flags.output, nameWithExt)
a.log("final output %s", finalOutput)

View File

@ -33,7 +33,7 @@ const (
usageFlagTo = "to `COMMIT`, which is kinda old commit, default is oldest commit"
usageFlagScope = "scope to generate"
usageFlagRepository = "`REPOSITORY` directory path"
usageFlagOutput = "`OUTPUT` directory path"
usageFlagOutput = "`OUTPUT` directory path, relative to `REPOSITORY` path"
usageFlagFilename = "output `FILENAME`"
usageFlagFiletype = "output `FILETYPE`"
usageFlagDryRun = "demo run without actually changing anything"

View File

@ -69,7 +69,9 @@ func (r *repo) Commit(commitMessage string, paths ...string) error {
}
for _, path := range paths {
if _, err := gitWorktree.Add(path); err != nil {
if err := gitWorktree.AddWithOptions(&git.AddOptions{
Path: path,
}); err != nil {
return fmt.Errorf("failed to git add %s: %w", path, err)
}
}