2020-01-24 16:30:16 +00:00
|
|
|
// Copyright 2018 The Gitea Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a MIT-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
package cmd
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"sort"
|
|
|
|
|
|
|
|
"code.gitea.io/changelog/config"
|
|
|
|
"code.gitea.io/changelog/service"
|
|
|
|
|
|
|
|
"github.com/urfave/cli/v2"
|
|
|
|
)
|
|
|
|
|
|
|
|
var Contributors = &cli.Command{
|
|
|
|
Name: "contributors",
|
|
|
|
Usage: "Generates a contributors list",
|
|
|
|
Action: runContributors,
|
|
|
|
}
|
|
|
|
|
|
|
|
func runContributors(cmd *cli.Context) error {
|
2020-02-02 22:45:12 +00:00
|
|
|
if ConfigPathFlag == "" {
|
|
|
|
ConfigPathFlag = getDefaultConfigFile()
|
|
|
|
}
|
|
|
|
|
2020-01-24 16:30:16 +00:00
|
|
|
cfg, err := config.New(ConfigPathFlag)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2022-03-13 02:33:03 +00:00
|
|
|
s, err := service.New(cfg.Service, cfg.Repo, cfg.BaseURL, MilestoneFlag, TagFlag, TokenFlag, IssuesFlag)
|
2020-01-24 16:30:16 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
contributors, err := s.Contributors()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
sort.Sort(contributors)
|
|
|
|
|
|
|
|
for _, contributor := range contributors {
|
|
|
|
fmt.Printf("* [@%s](%s)\n", contributor.Name, contributor.Profile)
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|