Skip to content

Search Commits API Results Problem #601

Closed
@amirilovic

Description

@amirilovic

Issue: When calling search commits api (go-github/github/search.go:84) returned results contain correct number of items but each item properties are empty.

As per github search docs https://developer.github.com/v3/search/#search-commits

Search Commits is returning results as:

{
  "total_count": 1,
  "incomplete_results": false,
  "items": [
    {
      "url": "https://api.github.com/repos/octocat/Spoon-Knife/commits/bb4cc8d3b2e14b3af5df699876dd4ff3acd00b7f",
      "sha": "bb4cc8d3b2e14b3af5df699876dd4ff3acd00b7f",
      "html_url": "https://github.com/octocat/Spoon-Knife/commit/bb4cc8d3b2e14b3af5df699876dd4ff3acd00b7f",
      "comments_url": "https://api.github.com/repos/octocat/Spoon-Knife/commits/bb4cc8d3b2e14b3af5df699876dd4ff3acd00b7f/comments",
      "commit": {
        "url": "https://api.github.com/repos/octocat/Spoon-Knife/git/commits/bb4cc8d3b2e14b3af5df699876dd4ff3acd00b7f",
        "author": {
          "date": "2014-02-04T14:38:36-08:00",
          "name": "The Octocat",
          "email": "octocat@nowhere.com"
        },
        "committer": {
          "date": "2014-02-12T15:18:55-08:00",
          "name": "The Octocat",
          "email": "octocat@nowhere.com"
        },
        "message": "Create styles.css and updated README",
        "tree": {
          "url": "https://api.github.com/repos/octocat/Spoon-Knife/git/trees/a639e96f9038797fba6e0469f94a4b0cc459fa68",
          "sha": "a639e96f9038797fba6e0469f94a4b0cc459fa68"
        },
        "comment_count": 8
      },
      "author": {
        // author fields ...
      },
      "committer": {
       // committer fields ...
      },
      "parents": [
        {
          "url": "https://api.github.com/repos/octocat/Spoon-Knife/commits/a30c19e3f13765a3b48829788bc1cb8b4e95cee4",
          "html_url": "https://github.com/octocat/Spoon-Knife/commit/a30c19e3f13765a3b48829788bc1cb8b4e95cee4",
          "sha": "a30c19e3f13765a3b48829788bc1cb8b4e95cee4"
        }
      ],
      "repository": {
       // repo fields ...
      },
      "score": 4.9971514
    }
  ]
}

But in search.go:67 results are deserialized in CommitResult struct which has different layout:

type CommitResult struct {
	Hash           *string     `json:"hash,omitempty"`
	Message        *string     `json:"message,omitempty"`
	AuthorID       *int        `json:"author_id,omitempty"`
	AuthorName     *string     `json:"author_name,omitempty"`
	AuthorEmail    *string     `json:"author_email,omitempty"`
	AuthorDate     *Timestamp  `json:"author_date,omitempty"`
	CommitterID    *int        `json:"committer_id,omitempty"`
	CommitterName  *string     `json:"committer_name,omitempty"`
	CommitterEmail *string     `json:"committer_email,omitempty"`
	CommitterDate  *Timestamp  `json:"committer_date,omitempty"`
	Repository     *Repository `json:"repository,omitempty"`
}

So, returned results are empty.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions