Skip to content

Commit

Permalink
Use parsed owner & repo name when retrieving commit history
Browse files Browse the repository at this point in the history
Fixes #22.
  • Loading branch information
muesli committed Dec 17, 2021
1 parent 6a1aa7b commit 860d6d2
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion git.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type Client interface {
Repository(owner string, name string) (vcs.Repo, error)
Repositories(owner string) ([]vcs.Repo, error)
Branches(owner string, name string) ([]vcs.Branch, error)
History(owner string, name string, max int, since time.Time) ([]vcs.Commit, error)
History(repo vcs.Repo, max int, since time.Time) ([]vcs.Commit, error)

GetUsername() (string, error)
IssueURL(owner string, name string, number int) string
Expand Down
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ func parseRepository() {
os.Exit(1)
}

r.LastRelease.CommitsSince, err = client.History(r.Owner, r.Name, *maxCommits, r.LastRelease.PublishedAt)
r.LastRelease.CommitsSince, err = client.History(r, *maxCommits, r.LastRelease.PublishedAt)
if err != nil {
fmt.Println(err)
os.Exit(1)
Expand Down Expand Up @@ -194,7 +194,7 @@ func parseAllProjects() {

go func(repo vcs.Repo) {
var err error
repo.LastRelease.CommitsSince, err = client.History(repo.Owner, repo.Name, *maxCommits, repo.LastRelease.PublishedAt)
repo.LastRelease.CommitsSince, err = client.History(repo, *maxCommits, repo.LastRelease.PublishedAt)
if err != nil {
fmt.Println(err)
os.Exit(1)
Expand Down
6 changes: 3 additions & 3 deletions vcs/github/commit.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ type QLCommit struct {
}
}

func (c *Client) History(owner string, name string, max int, since time.Time) ([]vcs.Commit, error) {
func (c *Client) History(repo vcs.Repo, max int, since time.Time) ([]vcs.Commit, error) {
var commits []vcs.Commit //nolint

variables := map[string]interface{}{
"owner": githubv4.String(owner),
"name": githubv4.String(name),
"owner": githubv4.String(repo.Owner),
"name": githubv4.String(repo.Name),
"since": githubv4.GitTimestamp{Time: since},
}

Expand Down
6 changes: 3 additions & 3 deletions vcs/gitlab/gitlab.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ func (c *Client) Branches(owner string, name string) ([]vcs.Branch, error) {
return i, nil
}

func (c *Client) History(owner string, name string, max int, since time.Time) ([]vcs.Commit, error) {
func (c *Client) History(repo vcs.Repo, max int, since time.Time) ([]vcs.Commit, error) {
var commits []vcs.Commit

page := 0
Expand All @@ -246,7 +246,7 @@ func (c *Client) History(owner string, name string, max int, since time.Time) ([
if !since.IsZero() {
opt.Since = &since
}
h, resp, err := c.api.Commits.ListCommits(owner+"/"+name, &opt)
h, resp, err := c.api.Commits.ListCommits(repo.NameWithOwner, &opt)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -300,7 +300,7 @@ func (c *Client) repoFromAPI(p *gitlab.Project) vcs.Repo {
return vcs.Repo{
Owner: p.Namespace.Path,
Name: p.Name,
NameWithOwner: p.NameWithNamespace,
NameWithOwner: p.PathWithNamespace,
URL: p.WebURL,
Description: p.Description,
Stargazers: p.StarCount,
Expand Down

0 comments on commit 860d6d2

Please sign in to comment.