Skip to content

Commit

Permalink
Use gh.CurrentRepository() to get the owner and repo
Browse files Browse the repository at this point in the history
  • Loading branch information
leofeyer committed Mar 20, 2023
1 parent 7cb8efc commit b99e91c
Showing 1 changed file with 3 additions and 51 deletions.
54 changes: 3 additions & 51 deletions api/changelog.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,19 @@ func Changelog(milestone string, version string) error {
s := spinner.New(spinner.CharSets[11], 120*time.Millisecond)
s.Start()

owner, err := getOwner()
repo, err := gh.CurrentRepository()
if err != nil {
s.Stop()
return err
}

repo, err := getRepo()
items, err := getItems(milestone, repo.Owner(), repo.Name())
if err != nil {
s.Stop()
return err
}

items, err := getItems(milestone, owner, repo)
if err != nil {
s.Stop()
return err
}

r := strings.NewReader(getContent(items, owner, repo, version))
r := strings.NewReader(getContent(items, repo.Owner(), repo.Name(), version))
atomic.WriteFile("./CHANGELOG.md", r)

s.Stop()
Expand Down Expand Up @@ -84,48 +78,6 @@ func getItems(milestone string, owner string, repo string) ([]Item, error) {
return items, nil
}

func getOwner() (string, error) {
data, _, err := gh.Exec("repo", "view", "--json", "owner")
if err != nil {
return "", err
}

type Result struct {
Owner struct {
Login string `json:"login"`
}
}

var r Result

err = json.Unmarshal(data.Bytes(), &r)
if err != nil {
return "", err
}

return r.Owner.Login, nil
}

func getRepo() (string, error) {
data, _, err := gh.Exec("repo", "view", "--json", "name")
if err != nil {
return "", err
}

type Result struct {
Name string `json:"name"`
}

var r Result

err = json.Unmarshal(data.Bytes(), &r)
if err != nil {
return "", err
}

return r.Name, nil
}

func getTags(milestone string) ([]Item, error) {
args := []string{
"tag",
Expand Down

0 comments on commit b99e91c

Please sign in to comment.