Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GHP] Include GitHub events linked to references #12

Closed
elanzini opened this issue Oct 1, 2020 · 5 comments · Fixed by #22 or #29
Closed

[GHP] Include GitHub events linked to references #12

elanzini opened this issue Oct 1, 2020 · 5 comments · Fixed by #22 or #29
Labels
enhancement New feature or request Patches Tracks all issues that have to do with finding and manipulating patch information

Comments

@elanzini
Copy link
Member

elanzini commented Oct 1, 2020

Example

GH issue: issue
PR that mentions it: pr

Problem

The output of API v3 cannot point to the PR.
One possible alternative would be to check if it is possible to perform this using the API v4.

To note: it is important to verify that the PR that mentions it is merged

@elanzini elanzini added enhancement New feature or request Patches Tracks all issues that have to do with finding and manipulating patch information labels Oct 1, 2020
@elanzini
Copy link
Member Author

elanzini commented Oct 1, 2020

This GraphQL query allows to do so:

query {
  repository(owner: "uclouvain", name: "openjpeg") {
    issue(number: 1044) {
      timelineItems(first: 100) {
        nodes {
          ... on ClosedEvent {
            closer {
              ... on PullRequest {
                number
                title
              }
            }
          }
        }
      }
    }
  }
}

Output is:

{
  "data": {
    "repository": {
      "issue": {
        "timelineItems": {
          "nodes": [
            {},
            {},
            {},
            {},
            {},
            {
              "closer": {
                "number": 1160,
                "title": "jp3d/jpwl convert: fix write stack buffer overflow"
              }
            },
            {},
            {}
          ]
        }
      }
    }
  }
}

@elanzini
Copy link
Member Author

It is also possible that the PR is mentioned in the issue as a comment and is not linked to it.
Example: NVD
Issue: 11803

Check here

@elanzini
Copy link
Member Author

We might also want to include the commit where the issue was closed.
Example: hapijs/subtext#72
Commit: hapijs/subtext@1e2aed6

Query:

query {
  repository(owner: "hapijs", name: "subtext") {
    issue(number: 72) {
      timelineItems(first: 100) {
        nodes {
          ... on ClosedEvent {
            closer {
              ... on Commit {
                commitUrl
              }
            }
          }
        }
      }
    }
  }
}

Returns:

{
  "data": {
    "repository": {
      "issue": {
        "timelineItems": {
          "nodes": [
            {},
            {},
            {},
            {
              "closer": {
                "commitUrl": "https://github.com/hapijs/subtext/commit/1e2aed64b7154e1786d866a3b5bdd4f36e9f492d"
              }
            },
            {},
            {}
          ]
        }
      }
    }
  }
}

@elanzini elanzini changed the title [GHP] Include PRs that mention issue [GHP] Include GitHub events linked to references Oct 15, 2020
@elanzini
Copy link
Member Author

Add commits that reference issues:
Example: expressjs/serve-static#26

Query:

query {
  repository(owner: "expressjs", name: "serve-static") {
    issue(number: 26) {
      timelineItems(first: 100) {
        nodes {
          ... on ReferencedEvent {
            commit {
              commitUrl
            }
          }
        }
      }
    }
  }
}

Result:

{
  "data": {
    "repository": {
      "issue": {
        "timelineItems": {
          "nodes": [
            {},
            {},
            {},
            {},
            {},
            {},
            {},
            {},
            {},
            {},
            {},
            {},
            {},
            {},
            {},
            {
              "commit": {
                "commitUrl": "https://github.com/expressjs/serve-static/commit/1bb77964849f82bd9276de30259e9546c6f84e8f"
              }
            },
            {
              "commit": {
                "commitUrl": "https://github.com/expressjs/serve-static/commit/512a4f48e432052998d5165918c50c2cdafade5f"
              }
            },
            {
              "commit": {
                "commitUrl": "https://github.com/hakatashi/kaerema-10/commit/be0135f42aeaafaaea38798a53dec2fbe344f81b"
              }
            },
            {},
            {}
          ]
        }
      }
    }
  }
}

@elanzini
Copy link
Member Author

Add commits referenced in the comments of the issue:
Example: uclouvain/openjpeg#1126

Possible ugly solution is to retrieve all comments and checks for links to commits and/or prs into the content of each:

query {
  repository(owner: "uclouvain", name: "openjpeg") {
    issue(number: 1126) {
      timelineItems(first: 100) {
        nodes {
          ... on IssueComment {
            author {
              login
            }
            body
          }
        }
      }
    }
  }
}

@elanzini elanzini linked a pull request Oct 20, 2020 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Patches Tracks all issues that have to do with finding and manipulating patch information
Projects
None yet
1 participant