Can you get commit information of a pullrequest using the pullrequest ID (without knowing the issue number)? - github-api

I have the pull request id of all the pull requests in a public repository. I was wondering if I could use this information to get the commit level information using Github api? I understand that this is fairly simple if the issue number is known. Unfortunately, i do not have the issue number for the pull requests.

The best you can do is to search all issues based on repo name,type (:pr) and date of creation. Using the api, the above search would translate into - https://api.github.com/search/issues?q=repo:km-Poonacha/testissues+type:pr+created:2017-06-16. I think one of the problems of using the id is that each pullrequest has an issue id and a different pullrequest id.

GitHub does not have any endpoints that allow you to filter using PullRequestevent ID. So, I guess the method you used by filtering based on type and date of creation is the best you can do for now.

Related

What does atlOrigin query parameter mean in Jira URL?

When I open a Jira issue link from a third party or copy from a clipboard I always find the URL looks like this:
https://mycompany.atlassian.net/browse/comapnyAlias-issueNumber?atlOrigin=longCharacters
I am curious what does atlOrigin means? and why do they use it?
There is a small explanation here https://developer.atlassian.com/developer-guide/client-identification/
Origin ID for links to Atlassian UI
Identify HTML links into our product user interface with a unique atlOrigin query string parameter added to the URL. This is similar to the UTM parameter used for click tracking in marketing web sites. In this context, uniqueness is guaranteed by Atlassian issuing the origin ID. For example, if linking into Jira’s Issue page:
https://devpartisan.atlassian.net/browse/TIS-11?atlOrigin=abc123
We generate a unique value for each integration so if you have more than 1 integration, please make sure we have properly associated each integration to a different origin value.
We do not recommend using this parameter in REST APIs or OAuth 2.0 flows, where this parameter might not be properly ignored.
Result is very Google Search - unfriendly to come up 😕

Can I tell who approved merge requests?

I have GitLab Starter which seems to mean that I am unable to restrict code approvers on a directory basis as everyone needs developer level access.
This is causing slight headaches.
Is there a way in GitLab that I can review who approved groups of merge requests? This way I can at least check after the fact that no one has approved code who should not have.
Is there a way to query the backend database or a way of gaining this information in some GUI screen somewhere?
There will be a way, with the upcoming GitLab 13.5 to clearly see the status of the approval process and who has approved a MR.
In the meantime, you still have the GitLab Merge Request approval API and the merge request API, with a call like GET /merge_requests does include paramters like approver_ids
Returns merge requests which have specified all the users with the given ids as individual approvers.
None returns merge requests without approvers.
Any returns merge requests with an approver.
That could help checking who has approved a MR.
Users on GitLab Starter, Bronze, or higher will also see the approvals_before_merge parameter.

Finding the ObjectId for Annotated Tags

I"m trying to get the objectID(SHa1d) of a commit.
Is there a way to retrieve the value?
You can get the objectId through Refs - List rest api.
https://dev.azure.com/{organization}/_apis/git/repositories/{repositoryId}/refs?filter=tags/&api-version=5.1-preview.1
However, if you want to get the information of annotatedtags from the commit's response, I am afraid this is currently not possible. The commit's response currently does not contain tags information.
Here is a uservoice for the same issue has been submitted on Developer Community forum. You can vote and add your comments for this feedback. Our PM and Product Group are reviewing these suggestion regularly and considering take it as plan.
In addition, you can retrieve tags based on commit id from Repos-> Tags in web UI.
The Commits - Get Commits API for Azure DevOps Git should serve the Commit ID as well in the response, along with retrieving git commits for a project. Check out the examples given in the same page for looking at some sample requests and responses.
Here is one:
Hope this helps!

Anyway for GitHub api v3 to determine and give names of CODEOWNERS

https://help.github.com/en/articles/about-code-owners
From the above documentation I’m trying to determine code and file owners of a particular file. I haven’t been able to find anything that gives this information within the GitHub documentation.
The closest I found was this, GitHub API v3: Determine if user is an Owner of an Organization
But that seems to be answering a slightly different question.
I've built an npm library called codeowners-api which does this . So its not python but in JS.
If you want to use REST you would need to fetch the codeowners file from the Repo in question using Github's get-file API.
After that you take the file and you iterate over the codeowners file until you find the match. You can look at my library's code as reference.
I've also created a chrome extension which gives the reviewer a filter button to see only their relevant files.
https://chrome.google.com/webstore/detail/codeowners/mklphhfajjbikchaodnibnjmeibbonhb
For those whoever get stuck in this situation and can't use that library^, I managed to find a work around where I use .search_issues() and then query repo:x+review:approved+is:open+is:pr, the review does not switch to approved until a Codeowner has approved the PR.
This is the best way I've found to do this:
List requested reviewers for a pull request using the Pull Requests API: https://docs.github.com/en/github-ae#latest/rest/reference/pulls#list-requested-reviewers-for-a-pull-request. This will give you a list of usernames and a list of teams.
Codeowners are essentially just teams or individuals assigned to watch over certain parts of the codebase. In my case, I wanted a list of usernames who are part of each codeowning team. So for each codeowning team that I got in Step 1, I used the Teams API to get lists of the team members: https://docs.github.com/en/rest/reference/teams#list-team-members.
Caveats of this approach:
Step 1 of this approach lists out all of those whose reviews were requested on the PR. While Github automatically requests reviews from codeowning individuals and teams, one can manually request reviews as well. This step does not distinguish between automatic review requests (which suggest codeowner status) and manual review requests.

How can you get a list of pull requests reviewed in a repository by a user from the GitHub API?

On the GitHub website, it is possible to list PRs reviewed by a user for a specific repository with the filter query is:pr reviewed-by:your-github-username. See example.
But I can't find how to replicate this functionality using the GitHub API. Is there a query you can make that will do something like GET /repos/:owner/:repo/pulls/reviewedby/:reviewer?
The search endpoint turned out to be the key. Example request:
https://api.github.com/search/issues?q=+type:pr+repo=facebook/react+reviewed-by:bvaughn

Resources