Finish functionality using generated swagger client
Signed-off-by: jolheiser <john.olheiser@gmail.com>
This commit is contained in:
parent
110c9f6950
commit
4609c89bba
|
@ -1,8 +1,8 @@
|
|||
# The full repository name
|
||||
repo: gitea/tea
|
||||
repo: go-gitea/gitea
|
||||
|
||||
# Service type (gitea or github)
|
||||
service: gitea
|
||||
service: github
|
||||
|
||||
# Base URL for Gitea instance if using gitea service type
|
||||
base-url: https://gitea.com
|
||||
|
|
|
@ -21,23 +21,22 @@ var Contributors = &cli.Command{
|
|||
}
|
||||
|
||||
func runContributors(cmd *cli.Context) error {
|
||||
cfg, err := config.Load(ConfigPath)
|
||||
if err := config.Load(ConfigPath); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
s, err := service.Load()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
s, err := service.Parse(cfg.Service)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
contributors, err := s.Contributors(cfg, Milestone)
|
||||
contributors, err := s.Contributors(Milestone)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, contributor := range contributors {
|
||||
fmt.Printf("* [@%s](https://github.com/%s)\n", contributor, contributor)
|
||||
fmt.Printf("* [@%s](%s/%s)\n", contributor, s.BaseURL(), contributor)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
|
@ -21,23 +21,22 @@ var Generate = &cli.Command{
|
|||
}
|
||||
|
||||
func runGenerate(cmd *cli.Context) error {
|
||||
cfg, err := config.Load(ConfigPath)
|
||||
if err := config.Load(ConfigPath); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
s, err := service.Load()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
s, err := service.Parse(cfg.Service)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
changelog, err := s.Changelog(cfg, Milestone)
|
||||
changelog, err := s.Changelog(Milestone)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Printf(changelog.TagURL)
|
||||
for _, g := range cfg.Groups {
|
||||
for _, g := range config.Cfg.Groups {
|
||||
if len(changelog.Entries[g.Name]) == 0 {
|
||||
continue
|
||||
}
|
||||
|
|
|
@ -11,7 +11,10 @@ import (
|
|||
"gopkg.in/yaml.v2"
|
||||
)
|
||||
|
||||
var defaultConfig []byte
|
||||
var (
|
||||
defaultConfig []byte
|
||||
Cfg *Config
|
||||
)
|
||||
|
||||
// Group is a grouping of PRs
|
||||
type Group struct {
|
||||
|
@ -31,7 +34,7 @@ type Config struct {
|
|||
}
|
||||
|
||||
// Load a config from a path, defaulting to changelog.example.yml
|
||||
func Load(configPath string) (*Config, error) {
|
||||
func Load(configPath string) error {
|
||||
var err error
|
||||
var configContent []byte
|
||||
if len(configPath) == 0 {
|
||||
|
@ -39,20 +42,19 @@ func Load(configPath string) (*Config, error) {
|
|||
} else {
|
||||
configContent, err = ioutil.ReadFile(configPath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
var config *Config
|
||||
if err = yaml.Unmarshal(configContent, &config); err != nil {
|
||||
return nil, err
|
||||
if err = yaml.Unmarshal(configContent, &Cfg); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if len(config.SkipLabels) > 0 {
|
||||
if config.SkipRegex, err = regexp.Compile(config.SkipLabels); err != nil {
|
||||
return nil, err
|
||||
if len(Cfg.SkipLabels) > 0 {
|
||||
if Cfg.SkipRegex, err = regexp.Compile(Cfg.SkipLabels); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return config, nil
|
||||
return nil
|
||||
}
|
||||
|
|
3
go.mod
3
go.mod
|
@ -3,7 +3,8 @@ module code.gitea.io/changelog
|
|||
go 1.13
|
||||
|
||||
require (
|
||||
code.gitea.io/sdk/gitea v0.0.0-20200107034216-f0ac57ba0b2b
|
||||
gitea.com/jolheiser/gitea-sdk v0.0.0-20200109220820-7c157d02c55f
|
||||
github.com/antihax/optional v1.0.0
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.0 // indirect
|
||||
github.com/google/go-github v17.0.0+incompatible
|
||||
github.com/google/go-querystring v1.0.0 // indirect
|
||||
|
|
22
go.sum
22
go.sum
|
@ -1,12 +1,14 @@
|
|||
code.gitea.io/sdk v0.0.0-20200107034216-f0ac57ba0b2b h1:ujbGMqEbr4d/gSfsOkJapGwx9h0g+cRgTuHlRovgLFI=
|
||||
code.gitea.io/sdk/gitea v0.0.0-20200107034216-f0ac57ba0b2b h1:z5T6DxY2fqJz02qhXGnQQ2lXfPW5bTDM/0lqzFGNcyk=
|
||||
code.gitea.io/sdk/gitea v0.0.0-20200107034216-f0ac57ba0b2b/go.mod h1:8IxkM1gyiwEjfO0m47bcmr3u3foR15+LoVub43hCHd0=
|
||||
gitea.com/gitea/go-sdk v0.0.0-20200107034216-f0ac57ba0b2b h1:qAIFQDSrZFRzUHHWSXuotBA0BpB5m7Y978gl1Jp4Vro=
|
||||
gitea.com/gitea/go-sdk v0.0.0-20200107034216-f0ac57ba0b2b/go.mod h1:r9S7LXuEumOEDhkZ9qHLhHSnTO6XNnKiBEbunPJJY+8=
|
||||
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
gitea.com/jolheiser/gitea-sdk v0.0.0-20200109220820-7c157d02c55f h1:1EIcRd8J1+7hLF7hCI+H+Dn5PGilrmitiQdXi+qEnY8=
|
||||
gitea.com/jolheiser/gitea-sdk v0.0.0-20200109220820-7c157d02c55f/go.mod h1:8IIUqhmftS5zEzOXKIuYhRzD22qDvGAdzJ+N2+b0k+4=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/antihax/optional v1.0.0 h1:xK2lYat7ZLaVVcIuj82J8kIro4V6kDe0AUDFboUCwcg=
|
||||
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.0 h1:EoUDS0afbrsXAZ9YQ9jdu/mZ2sXgT1/2yyNng4PGlyM=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
|
||||
github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/google/go-github v17.0.0+incompatible h1:N0LgJ1j65A7kfXrZnUDaYCs/Sf4rEjNlfyDHW9dolSY=
|
||||
github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ=
|
||||
github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk=
|
||||
|
@ -19,6 +21,16 @@ github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5I
|
|||
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
|
||||
github.com/urfave/cli/v2 v2.1.1 h1:Qt8FeAtxE/vfdrLmR3rxR6JRE0RoVmbXu8+6kZtYU4k=
|
||||
github.com/urfave/cli/v2 v2.1.1/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ=
|
||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e h1:bRhVy7zSSasaqNksaRZiA5EEI+Ei4I1nO5Jh72wfHlg=
|
||||
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d h1:TzXSXBo42m9gQenoE3b9BGiEpg5IG2JkU5FkPIawgtw=
|
||||
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 h1:YUO/7uOKsKeq9UokNS62b8FYywz3ker1l1vDZRCRefw=
|
||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
google.golang.org/appengine v1.4.0 h1:/wp5JvzpHIxhs/dumFmF7BXTf3Z+dd4uXta4kVyO508=
|
||||
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
|
|
|
@ -5,30 +5,37 @@
|
|||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/antihax/optional"
|
||||
"sort"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"code.gitea.io/changelog/config"
|
||||
"code.gitea.io/sdk/gitea"
|
||||
"gitea.com/jolheiser/gitea-sdk"
|
||||
)
|
||||
|
||||
// Gitea defines a Gitea service
|
||||
type Gitea struct{}
|
||||
|
||||
// Changelog returns a Gitea changelog
|
||||
func (ge Gitea) Changelog(cfg *config.Config, milestone string) (Changelog, error) {
|
||||
func (ge Gitea) Changelog(milestone string) (Changelog, error) {
|
||||
changelog := Changelog{
|
||||
TagURL: fmt.Sprintf("## [%s](%s/%s/src/tag/v%s) - %s\n", cfg.BaseURL, milestone, cfg.Repo, milestone, time.Now().Format("2006-01-02")),
|
||||
// FIXME Update tag location if Gitea ever has a page specifically for tags like GitHub does
|
||||
TagURL: fmt.Sprintf("## [%s](%s/%s/src/tag/v%s) - %s\n", milestone, config.Cfg.BaseURL, config.Cfg.Repo, milestone, time.Now().Format("2006-01-02")),
|
||||
}
|
||||
|
||||
client := gitea.NewClient(cfg.BaseURL, "")
|
||||
client := gitea.NewAPIClient(&gitea.Configuration{
|
||||
BasePath: config.Cfg.BaseURL + "/api/v1",
|
||||
DefaultHeader: make(map[string]string),
|
||||
UserAgent: "Gitea-Changelog/1.0.0/go",
|
||||
})
|
||||
|
||||
labels := make(map[string]string)
|
||||
entries := make(map[string][]Entry)
|
||||
var defaultGroup string
|
||||
for _, g := range cfg.Groups {
|
||||
for _, g := range config.Cfg.Groups {
|
||||
entries[g.Name] = []Entry{}
|
||||
for _, l := range g.Labels {
|
||||
labels[l] = g.Name
|
||||
|
@ -39,19 +46,33 @@ func (ge Gitea) Changelog(cfg *config.Config, milestone string) (Changelog, erro
|
|||
}
|
||||
|
||||
if defaultGroup == "" {
|
||||
defaultGroup = cfg.Groups[len(cfg.Groups)-1].Name
|
||||
defaultGroup = config.Cfg.Groups[len(config.Cfg.Groups)-1].Name
|
||||
}
|
||||
|
||||
repoOwner := strings.Split(cfg.Repo, "/")
|
||||
repoOwner := strings.Split(config.Cfg.Repo, "/")
|
||||
repo := repoOwner[0]
|
||||
owner := repoOwner[1]
|
||||
|
||||
milestones, _, err := client.IssueApi.IssueGetMilestonesList(context.Background(), repo, owner, nil)
|
||||
if err != nil {
|
||||
return changelog, err
|
||||
}
|
||||
|
||||
var milestoneID int64
|
||||
for _, ms := range milestones {
|
||||
if ms.Title == milestone {
|
||||
milestoneID = ms.Id
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
p := 1
|
||||
perPage := 100
|
||||
for {
|
||||
// FIXME Once SDK is updated, search only by milestone
|
||||
results, err := client.ListRepoPullRequests(repo, owner, gitea.ListPullRequestsOptions{
|
||||
Page: p,
|
||||
State: "closed",
|
||||
results, _, err := client.RepositoryApi.RepoListPullRequests(context.Background(), repo, owner, &gitea.RepoListPullRequestsOpts{
|
||||
Page: optional.NewInt32(int32(p)),
|
||||
State: optional.NewString("closed"),
|
||||
Milestone: optional.NewInt64(milestoneID),
|
||||
})
|
||||
p++
|
||||
if err != nil {
|
||||
|
@ -60,13 +81,13 @@ func (ge Gitea) Changelog(cfg *config.Config, milestone string) (Changelog, erro
|
|||
|
||||
PRLoop: // labels in Go, let's get old school
|
||||
for _, pr := range results {
|
||||
if pr == nil || !pr.HasMerged || pr.Milestone == nil || pr.Milestone.Title != milestone {
|
||||
if !pr.Merged {
|
||||
continue
|
||||
}
|
||||
|
||||
var label string
|
||||
for _, lb := range pr.Labels {
|
||||
if cfg.SkipRegex != nil && cfg.SkipRegex.MatchString(lb.Name) {
|
||||
if config.Cfg.SkipRegex != nil && config.Cfg.SkipRegex.MatchString(lb.Name) {
|
||||
continue PRLoop
|
||||
}
|
||||
|
||||
|
@ -78,12 +99,12 @@ func (ge Gitea) Changelog(cfg *config.Config, milestone string) (Changelog, erro
|
|||
if len(label) > 0 {
|
||||
entries[label] = append(entries[label], Entry{
|
||||
Title: pr.Title,
|
||||
Index: pr.Index,
|
||||
Index: pr.Number,
|
||||
})
|
||||
} else {
|
||||
entries[defaultGroup] = append(entries[defaultGroup], Entry{
|
||||
Title: pr.Title,
|
||||
Index: pr.Index,
|
||||
Index: pr.Number,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -99,20 +120,38 @@ func (ge Gitea) Changelog(cfg *config.Config, milestone string) (Changelog, erro
|
|||
}
|
||||
|
||||
// Contributors returns a list of contributors from Gitea
|
||||
func (ge Gitea) Contributors(cfg *config.Config, milestone string) ([]string, error) {
|
||||
client := gitea.NewClient(cfg.BaseURL, "")
|
||||
func (ge Gitea) Contributors(milestone string) ([]string, error) {
|
||||
client := gitea.NewAPIClient(&gitea.Configuration{
|
||||
BasePath: config.Cfg.BaseURL + "/api/v1",
|
||||
DefaultHeader: make(map[string]string),
|
||||
UserAgent: "Gitea-Changelog/1.0.0/go",
|
||||
})
|
||||
|
||||
contributorsMap := make(map[string]bool)
|
||||
repoOwner := strings.Split(cfg.Repo, "/")
|
||||
repoOwner := strings.Split(config.Cfg.Repo, "/")
|
||||
repo := repoOwner[0]
|
||||
owner := repoOwner[1]
|
||||
|
||||
milestones, _, err := client.IssueApi.IssueGetMilestonesList(context.Background(), repo, owner, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var milestoneID int64
|
||||
for _, ms := range milestones {
|
||||
if ms.Title == milestone {
|
||||
milestoneID = ms.Id
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
p := 1
|
||||
perPage := 100
|
||||
for {
|
||||
// FIXME Once SDK is updated, search only by milestone
|
||||
results, err := client.ListRepoPullRequests(repo, owner, gitea.ListPullRequestsOptions{
|
||||
Page: p,
|
||||
State: "closed",
|
||||
results, _, err := client.RepositoryApi.RepoListPullRequests(context.Background(), repo, owner, &gitea.RepoListPullRequestsOpts{
|
||||
Page: optional.NewInt32(int32(p)),
|
||||
State: optional.NewString("closed"),
|
||||
Milestone: optional.NewInt64(milestoneID),
|
||||
})
|
||||
p++
|
||||
if err != nil {
|
||||
|
@ -120,15 +159,11 @@ func (ge Gitea) Contributors(cfg *config.Config, milestone string) ([]string, er
|
|||
}
|
||||
|
||||
for _, pr := range results {
|
||||
if !pr.HasMerged || pr.Milestone == nil {
|
||||
if !pr.Merged {
|
||||
continue
|
||||
}
|
||||
|
||||
if pr.Milestone.Title != milestone {
|
||||
continue
|
||||
}
|
||||
|
||||
contributorsMap[pr.Poster.UserName] = true
|
||||
contributorsMap[pr.User.Login] = true
|
||||
}
|
||||
|
||||
if len(results) != perPage {
|
||||
|
@ -145,3 +180,7 @@ func (ge Gitea) Contributors(cfg *config.Config, milestone string) ([]string, er
|
|||
|
||||
return contributors, nil
|
||||
}
|
||||
|
||||
func (ge Gitea) BaseURL() string {
|
||||
return config.Cfg.BaseURL
|
||||
}
|
||||
|
|
|
@ -19,9 +19,9 @@ import (
|
|||
type GitHub struct{}
|
||||
|
||||
// Changelog returns a GitHub changelog
|
||||
func (gh GitHub) Changelog(cfg *config.Config, milestone string) (Changelog, error) {
|
||||
func (gh GitHub) Changelog(milestone string) (Changelog, error) {
|
||||
changelog := Changelog{
|
||||
TagURL: fmt.Sprintf("## [%s](https://github.com/%s/releases/tag/v%s) - %s\n", milestone, cfg.Repo, milestone, time.Now().Format("2006-01-02")),
|
||||
TagURL: fmt.Sprintf("## [%s](https://github.com/%s/releases/tag/v%s) - %s\n", milestone, config.Cfg.Repo, milestone, time.Now().Format("2006-01-02")),
|
||||
}
|
||||
|
||||
client := github.NewClient(nil)
|
||||
|
@ -30,7 +30,7 @@ func (gh GitHub) Changelog(cfg *config.Config, milestone string) (Changelog, err
|
|||
labels := make(map[string]string)
|
||||
entries := make(map[string][]Entry)
|
||||
var defaultGroup string
|
||||
for _, g := range cfg.Groups {
|
||||
for _, g := range config.Cfg.Groups {
|
||||
entries[g.Name] = []Entry{}
|
||||
for _, l := range g.Labels {
|
||||
labels[l] = g.Name
|
||||
|
@ -41,10 +41,10 @@ func (gh GitHub) Changelog(cfg *config.Config, milestone string) (Changelog, err
|
|||
}
|
||||
|
||||
if defaultGroup == "" {
|
||||
defaultGroup = cfg.Groups[len(cfg.Groups)-1].Name
|
||||
defaultGroup = config.Cfg.Groups[len(config.Cfg.Groups)-1].Name
|
||||
}
|
||||
|
||||
query := fmt.Sprintf(`repo:%s is:merged milestone:"%s"`, cfg.Repo, milestone)
|
||||
query := fmt.Sprintf(`repo:%s is:merged milestone:"%s"`, config.Cfg.Repo, milestone)
|
||||
p := 1
|
||||
perPage := 100
|
||||
for {
|
||||
|
@ -63,7 +63,7 @@ func (gh GitHub) Changelog(cfg *config.Config, milestone string) (Changelog, err
|
|||
for _, pr := range result.Issues {
|
||||
var label string
|
||||
for _, lb := range pr.Labels {
|
||||
if cfg.SkipRegex != nil && cfg.SkipRegex.MatchString(lb.GetName()) {
|
||||
if config.Cfg.SkipRegex != nil && config.Cfg.SkipRegex.MatchString(lb.GetName()) {
|
||||
continue PRLoop
|
||||
}
|
||||
|
||||
|
@ -96,12 +96,12 @@ func (gh GitHub) Changelog(cfg *config.Config, milestone string) (Changelog, err
|
|||
}
|
||||
|
||||
// Contributors returns a list of contributors from GitHub
|
||||
func (gh GitHub) Contributors(cfg *config.Config, milestone string) ([]string, error) {
|
||||
func (gh GitHub) Contributors(milestone string) ([]string, error) {
|
||||
client := github.NewClient(nil)
|
||||
ctx := context.Background()
|
||||
|
||||
contributorsMap := make(map[string]bool)
|
||||
query := fmt.Sprintf(`repo:%s is:merged milestone:"%s"`, cfg.Repo, milestone)
|
||||
query := fmt.Sprintf(`repo:%s is:merged milestone:"%s"`, config.Cfg.Repo, milestone)
|
||||
p := 1
|
||||
perPage := 100
|
||||
for {
|
||||
|
@ -134,3 +134,7 @@ func (gh GitHub) Contributors(cfg *config.Config, milestone string) ([]string, e
|
|||
|
||||
return contributors, nil
|
||||
}
|
||||
|
||||
func (gh GitHub) BaseURL() string {
|
||||
return "https://github.com"
|
||||
}
|
||||
|
|
|
@ -12,8 +12,8 @@ import (
|
|||
)
|
||||
|
||||
// Parse returns a service from a string
|
||||
func Parse(s string) (Service, error) {
|
||||
switch strings.ToLower(s) {
|
||||
func Load() (Service, error) {
|
||||
switch strings.ToLower(config.Cfg.Service) {
|
||||
case "github":
|
||||
return GitHub{}, nil
|
||||
case "gitea":
|
||||
|
@ -25,8 +25,9 @@ func Parse(s string) (Service, error) {
|
|||
|
||||
// Service defines how a struct can be a Changelog Service
|
||||
type Service interface {
|
||||
Changelog(*config.Config, string) (Changelog, error)
|
||||
Contributors(*config.Config, string) ([]string, error)
|
||||
Changelog(string) (Changelog, error)
|
||||
Contributors(string) ([]string, error)
|
||||
BaseURL() string
|
||||
}
|
||||
|
||||
// Entry defines a changelog entry (PR title and index)
|
||||
|
|
Loading…
Reference in New Issue