summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Muehlhaeuser <muesli@gmail.com>2021-12-17 22:26:43 +0100
committerChristian Muehlhaeuser <muesli@gmail.com>2021-12-17 22:59:22 +0100
commit860d6d219b8dd89e4b69acb027a4c9c5e8704a8b (patch)
treec0dce7e2a37de1b00c4376a01a8a1cf76f6e06e9
parent6a1aa7b6da466b8940ebf2d2bf72fe4b47dbb029 (diff)
Use parsed owner & repo name when retrieving commit history
Fixes #22.
-rw-r--r--git.go2
-rw-r--r--main.go4
-rw-r--r--vcs/github/commit.go6
-rw-r--r--vcs/gitlab/gitlab.go6
4 files changed, 9 insertions, 9 deletions
diff --git a/git.go b/git.go
index ab5094e..22fc0c7 100644
--- a/git.go
+++ b/git.go
@@ -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
diff --git a/main.go b/main.go
index 71d65ad..75ba9c1 100644
--- a/main.go
+++ b/main.go
@@ -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)
@@ -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)
diff --git a/vcs/github/commit.go b/vcs/github/commit.go
index 0a1bd2b..982ddd4 100644
--- a/vcs/github/commit.go
+++ b/vcs/github/commit.go
@@ -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},
}
diff --git a/vcs/gitlab/gitlab.go b/vcs/gitlab/gitlab.go
index e1b76fa..d6a4a60 100644
--- a/vcs/gitlab/gitlab.go
+++ b/vcs/gitlab/gitlab.go
@@ -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
@@ -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
}
@@ -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,