diff --git a/.lgtm b/.lgtm deleted file mode 100644 index d39781b..0000000 --- a/.lgtm +++ /dev/null @@ -1,3 +0,0 @@ -pattern = "(?)LGTM" -self_approval_off = true -ignore_maintainers_file = true diff --git a/gitea/fork.go b/gitea/fork.go index 5722249..f7e5cc8 100644 --- a/gitea/fork.go +++ b/gitea/fork.go @@ -13,10 +13,7 @@ import ( // ListForks list a repository's forks func (c *Client) ListForks(user, repo string) ([]*Repository, error) { forks := make([]*Repository, 10) - err := c.getParsedResponse("GET", - fmt.Sprintf("/repos/%s/%s/forks", user, repo), - nil, nil, &forks) - return forks, err + return forks, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/forks", user, repo), nil, nil, &forks) } // CreateForkOption options for creating a fork @@ -32,8 +29,5 @@ func (c *Client) CreateFork(user, repo string, form CreateForkOption) (*Reposito return nil, err } fork := new(Repository) - err = c.getParsedResponse("POST", - fmt.Sprintf("/repos/%s/%s/forks", user, repo), - jsonHeader, bytes.NewReader(body), &fork) - return fork, err + return fork, c.getParsedResponse("POST", fmt.Sprintf("/repos/%s/%s/forks", user, repo), jsonHeader, bytes.NewReader(body), &fork) } diff --git a/gitea/issue_comment_test.go b/gitea/issue_comment_test.go index c395a5b..6a63d9a 100644 --- a/gitea/issue_comment_test.go +++ b/gitea/issue_comment_test.go @@ -73,7 +73,6 @@ func TestIssueComment(t *testing.T) { }) assert.NoError(t, err) assert.EqualValues(t, "changed my mind", comment.Body) - assert.NotEqual(t, comment.Updated.Unix(), comments[1].Updated.Unix()) // DeleteIssueComment assert.NoError(t, c.DeleteIssueComment(user.UserName, repo.Name, comments[1].ID)) diff --git a/gitea/repo_collaborator.go b/gitea/repo_collaborator.go index bd61a22..646d34f 100644 --- a/gitea/repo_collaborator.go +++ b/gitea/repo_collaborator.go @@ -13,17 +13,12 @@ import ( // ListCollaborators list a repository's collaborators func (c *Client) ListCollaborators(user, repo string) ([]*User, error) { collaborators := make([]*User, 0, 10) - err := c.getParsedResponse("GET", - fmt.Sprintf("/repos/%s/%s/collaborators", user, repo), - nil, nil, &collaborators) - return collaborators, err + return collaborators, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/collaborators", user, repo), nil, nil, &collaborators) } // IsCollaborator check if a user is a collaborator of a repository func (c *Client) IsCollaborator(user, repo, collaborator string) (bool, error) { - status, err := c.getStatusCode("GET", - fmt.Sprintf("/repos/%s/%s/collaborators/%s", user, repo, collaborator), - nil, nil) + status, err := c.getStatusCode("GET", fmt.Sprintf("/repos/%s/%s/collaborators/%s", user, repo, collaborator), nil, nil) if err != nil { return false, err } @@ -51,7 +46,6 @@ func (c *Client) AddCollaborator(user, repo, collaborator string, opt AddCollabo // DeleteCollaborator remove a collaborator from a repository func (c *Client) DeleteCollaborator(user, repo, collaborator string) error { _, err := c.getResponse("DELETE", - fmt.Sprintf("/repos/%s/%s/collaborators/%s", user, repo, collaborator), - nil, nil) + fmt.Sprintf("/repos/%s/%s/collaborators/%s", user, repo, collaborator), nil, nil) return err } diff --git a/gitea/repo_tree.go b/gitea/repo_tree.go index 842ab9b..d258bdf 100644 --- a/gitea/repo_tree.go +++ b/gitea/repo_tree.go @@ -31,11 +31,10 @@ type GitTreeResponse struct { // GetTrees downloads a file of repository, ref can be branch/tag/commit. // e.g.: ref -> master, tree -> macaron.go(no leading slash) func (c *Client) GetTrees(user, repo, ref string, recursive bool) (*GitTreeResponse, error) { - var trees GitTreeResponse + trees := new(GitTreeResponse) var path = fmt.Sprintf("/repos/%s/%s/git/trees/%s", user, repo, ref) if recursive { path += "?recursive=1" } - err := c.getParsedResponse("GET", path, nil, nil, &trees) - return &trees, err + return trees, c.getParsedResponse("GET", path, nil, nil, trees) } diff --git a/gitea/status.go b/gitea/status.go index ba9c18c..43c1486 100644 --- a/gitea/status.go +++ b/gitea/status.go @@ -50,16 +50,13 @@ type CreateStatusOption struct { } // CreateStatus creates a new Status for a given Commit -// -// POST /repos/:owner/:repo/statuses/:sha func (c *Client) CreateStatus(owner, repo, sha string, opts CreateStatusOption) (*Status, error) { body, err := json.Marshal(&opts) if err != nil { return nil, err } - status := &Status{} - return status, c.getParsedResponse("POST", fmt.Sprintf("/repos/%s/%s/statuses/%s", owner, repo, sha), - jsonHeader, bytes.NewReader(body), status) + status := new(Status) + return status, c.getParsedResponse("POST", fmt.Sprintf("/repos/%s/%s/statuses/%s", owner, repo, sha), jsonHeader, bytes.NewReader(body), status) } // ListStatusesOption holds pagination information @@ -68,8 +65,6 @@ type ListStatusesOption struct { } // ListStatuses returns all statuses for a given Commit -// -// GET /repos/:owner/:repo/commits/:ref/statuses func (c *Client) ListStatuses(owner, repo, sha string, opts ListStatusesOption) ([]*Status, error) { statuses := make([]*Status, 0, 10) return statuses, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/commits/%s/statuses?page=%d", owner, repo, sha, opts.Page), nil, nil, &statuses) @@ -87,9 +82,7 @@ type CombinedStatus struct { } // GetCombinedStatus returns the CombinedStatus for a given Commit -// -// GET /repos/:owner/:repo/commits/:ref/status func (c *Client) GetCombinedStatus(owner, repo, sha string) (*CombinedStatus, error) { - status := &CombinedStatus{} + status := new(CombinedStatus) return status, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/commits/%s/status", owner, repo, sha), nil, nil, status) }