use .changelog.yml config if in working dir (#37)

use .changelog.yml config if in working dir

Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: https://gitea.com/gitea/changelog/pulls/37
Reviewed-by: John Olheiser <john.olheiser@gmail.com>
Reviewed-by: Andrew Thornton <art27@cantab.net>
This commit is contained in:
6543 2020-02-02 22:45:12 +00:00 committed by Andrew Thornton
parent cb765dc996
commit a9ba232835
3 changed files with 28 additions and 0 deletions

View File

@ -4,6 +4,11 @@
package cmd package cmd
import (
"os"
"path/filepath"
)
var ( var (
MilestoneFlag string MilestoneFlag string
ConfigPathFlag string ConfigPathFlag string
@ -11,3 +16,16 @@ var (
DetailsFlag bool DetailsFlag bool
AfterFlag int64 AfterFlag int64
) )
func getDefaultConfigFile() string {
pwd, err := os.Getwd()
if err != nil {
return ""
}
config := filepath.Join(pwd, ".changelog.yml")
info, err := os.Stat(config)
if err == nil && !info.IsDir() {
return config
}
return ""
}

View File

@ -21,6 +21,11 @@ var Contributors = &cli.Command{
} }
func runContributors(cmd *cli.Context) error { func runContributors(cmd *cli.Context) error {
if ConfigPathFlag == "" {
ConfigPathFlag = getDefaultConfigFile()
}
cfg, err := config.New(ConfigPathFlag) cfg, err := config.New(ConfigPathFlag)
if err != nil { if err != nil {
return err return err

View File

@ -26,6 +26,11 @@ var (
) )
func runGenerate(cmd *cli.Context) error { func runGenerate(cmd *cli.Context) error {
if ConfigPathFlag == "" {
ConfigPathFlag = getDefaultConfigFile()
}
cfg, err := config.New(ConfigPathFlag) cfg, err := config.New(ConfigPathFlag)
if err != nil { if err != nil {
return err return err