Github API V3 Search Repo issues - github

I'm trying to get 3 repos with highest numbers of stars in given language. I have 3 issues with it:
search is using legacy pagination style and per_page does not seem to work
language parameter is also not respected, I get php, java etc
i'm sorting by start but in result i get detailed repo info with everything
but stars count...
curl "https://api.github.com/legacy/repos/search/foobar?sort=stars&order=desc&language=VimL&per_page=3"

First of all, per_page isn't listed as an accepted parameter. With that in mind, it could be invalidating the rest of your parameters being sent. If removing that does in fact fix the issue, you should contact GitHub support directly. If in fact you do this, be sure to include "API" in the topic so it gets routed directly to the API team so you can get your answer faster.
Re:
i'm sorting by start but in result i get detailed repo info with everything but stars count.
The legacy API (as you already noted this was) returned old style (v2) Repository information. If you want information about the stars you'll have to make a direct call to /repos/:user/:repo after you find the repositories you want.

Related

GitHub: filter for issues that are either assigned to somebody or somebody is mentioned

Is there an option how to show all issues that are either assigned to me or that I'm mentioned in at the same time? Filtering by using the dropdown menu allows only to check for one of those and using is:open assignee:#me mentions:#me filters for all issues for which both constraints are true (basically & instead of |)
The first answer to this question from 8 years ago suggests it is not possible to use an "or" query. Does this still hold true?
What is the best alternative to filter for all issues that are relevant for me, ideally in the whole organization - third party tools?
The involves:user may be useful here:
Search by a user that's involved in an issue or pull request
You can use the involves qualifier to find issues that in some way involve a certain user. The involves qualifier is a logical OR between the author, assignee, mentions, and commenter qualifiers for a single user. In other words, this qualifier finds issues and pull requests that were either created by a certain user, assigned to that user, mention that user, or were commented on by that user.
Simply searching for the user's Github handle may be useful too.
Using a tool like gh (github cli) will allow you to lest and filter items too. A script can easily concatenate the results:
gh issue list --search "involves:#me is:open"
You can have it spit out json as well by adding --json, that way you can parse and further process the results as well.

How to get a github usesr top laguages used using a github api

is there and way to get a users most used languages just like github gives us
like this:
https://github-readme-stats.vercel.app/api/top-langs/?username=rjoydip
using GitHub API
Apprently not, if I interpret correctly the anuraghazra/github-readme-stats/src/fetchers/top-languages-fetcher.js#fetchTopLanguages() function used to get those stats.
It has to iterate on all repositories, and get languages from each one.

Azure Pipeline build specific pull requests

I have a list of pull requests, each linked to the specific work items. I want to run a pipeline only for some of the work items. Therefore I would like to somehow automatically cherry-pick only commits/pull requests related to work items I want to build. Either using tags on work items or something similar. In the build, I need only the files which were changed, so I was thinking of using git diff.
Is that possible using the Azure Pipelines?
If I understand your request correctly, you need to run the build pipeline only for those pull requests which meet certain requirements, for example, are linked to the work items tagged with specific words. Although I'm sure there's no out-of-the-box solution to this, I think it is possible to achieve with the Conditions concept and the REST API.
I would follow these steps:
The very first build step in the build job should be a script to find out if this particular pull request being built is related to the target work items. It can be a PowerShell build step, which should:
Get the pull request ID - it is available as a predefined system variable called System.PullRequest.PullRequestId
Make a REST API call to get work item IDs related to this pull request. It will return a collection of {id, url} pairs, where id is an ID of the work item in question
For each found work item ID, make a REST API call to get the details of the work item, in particular, you're interested in the System.Tags property of the response
Again, for each work item, parse the System.Tags property value to find out if it contains necessary tags
If at least one related work item contains the tags you're interested in, set the flag variable called i.e. ShouldRunTheRestOfThePipeline to true
Conditionalize the further steps of the job with the custom condition. You can read more about the syntax of the expression here. In particular, the Q&A section describes how to use the variable set in the previous build step in a subsequent step's condition
Now, regarding your notes about taking only changed files. In fact, the pull request nature is to keep the changed files compared to the target branch it is created against. So, you don't need to do any extra actions to git diff - the pull request already contains all you need.
Finally, I would suggest you reconsider the requirements of this setup, 'cause it sounds a bit unnatural to me. There are other options for how not to trigger a pipeline. For example, it can be decided based on the branch/tag name, both include and exclude options are available. Or, you can specify file paths to include or exclude, for instance, never trigger a pipeline if only docs/* were changed. The wildcard syntax is supported, which makes this tool even more flexible.
Hope this can help you build a suitable solution to your specific scenario.

How do you keep track of your comments on GitHub issues?

I want to find all the GitHub issues that I commented on. I tried searching for commenter:mbigras type:issue like the Searching issues and pull requests GitHub article suggests. But that method returns fewer results than the public activity section of my profile.
See both attached images:
Search method
Doesn't display current results:
Profile method
Gets mixed up with other public activity:
Is there a way to get the full history of my comments on GitHub?
EDIT
author:mbigras type:issue gives wider results but still not the full history:
What I'm looking for is a way to quickly view all my comment/issue history in all issues.
EDIT
I emailed GitHub about this. Search doesn't match the public activity section because search indexes issues by creation date and not last active date.
How do you keep organized about which issues you've commented on?
Search for commenter:username in the main Github search box.
For example commenter:gavinandresen
To see recent activity, select Recently updated from Sort dropdown
You can also narrow the search: is:issue commenter:gavinandresen
I have also been very frustrated when I could not find an issue that I have commented on a while ago. I even did not remember the project it was in. I knew only the problem I was referring to.
Then, I went to the Notification settings on Github and saw there is an Include your own updates option that is unchecked by default.
Once you check it, Github will send you an e-mail notification about every comment or PR you make. They you probably want to add an appropriate label and filter for emails so Github messages do not clutter an inbox.
My life has changed since then. Now, every time I want to find something I have written on Github, I just search for it in the e-mail notifications.
You can view all the issues on Github you have commented on by going to https://github.com/notifications/subscriptions and selecting Reason as Comment.
This will show all the issues that you've commented on.
You can also filter the issues by selecting other reason such as Assign, Author, Manual, Mention, etc. but you can select only one reason at a time. Also, you can filter the issues by repository by selecting the concerned repository from dropdown after clicking Repository
Search All GitHub using the search term is:issue author:#me
You can also check the following links.
For all your subscriptions
https://github.com/notifications/subscriptions
For all your issues
https://github.com/issues
For all your pull requests
https://github.com/pulls
In case someone is interested to know how to find these links, go to github's resi api documentation. The URL's are not explicitly described there. However, look for the page names bellow REFERENCE.
If you lowercase the relevant word (for example Issues become issues, Pulls become pulls) and put that after https://github.com/, you most probably will find what you are looking for.
This might be a little late, but there's also another way to find what issues/PRs you have participated in. This method also brings in a lot more things you might be interested in too!
When you are on the website main page, on github.com, use the keyboard shortcuts as described here to open your pull requests or issues. The shortcut for these is in particular [g, i] for issues and [g, p] for pull requests (I remember g by go, but whatever works for you.)
After you go to the page directed by these shortcuts you are greeted by an entire screen of goodies you can use! The search bar can be edited and the buttons can be used to make your experience fast!
Type involves:<your username> in the search box on the GitHub's main page. This will find all the issues that you commented on, was assigned to or mentioned in.
For example, if your username on GitHub is unclebob, the search query should look like:
involves:unclebob
Or if you're logged in to GitHub, then simply:
involves:#me
Note the difference between involves and similar search qualifiers - author and commenter:
author will find only the issues that were started by you; if you comment on the issue that was started by someone else, author query won't return it in the search results.
E.g., compare involves:unclebob and author:unclebob type:issue.
commenter will find only those issues where you commented second or later (creator of the first comment in an issue is considered its author and not a commenter); if you start an issue and then never comment on it, the commenter query won't return it in the search results.
E.g., compare involves:unclebob and commenter:unclebob.
In other words, when it comes to searching comments, author and commenter return only a subset of involves' results. So I recommend using involves not to miss anything.
Also, since Github is on the web, any HTTP search engine works, eg Google, Bing, etc. This works to the extent of your search engine's quality and the uniqueness of the writer name.
(Indeed, I actually do this all the time when I need to find any previously written web (engine)-accessible publication, including those on StackExchange. Names I use are 1 in probably an infinity, so Google often works better than forum search options.)
(Sample Google link.)
If you want to search for multiple users in a single search, use it like in the global search bar without the OR logical conjugation:
commenter:FantomX1 commenter:FantomX1-github
since the similar google way approach with 'OR' would not work
commenter:FantomX1 OR commenter:FantomX1-github

How can I see all the issues I'm watching on Github?

Github has a great feature where you can "watch" an issue. This is handy for getting notifications about progress on that issue.
However, sometimes you want to find the status of an issue you know you've flagged to watch, but can't remember what it was. This is particularly interesting, imho, for projects that are not your own projects. E.g. watching a bug in a library that your project uses but you don't contribute to frequently.
What I tried: Note that this is different from watching a repo. I tried searching github help (for "watch issue" and "subscribe issue" with no luck. I read the Unsubscribing from Conversations with some hope, but it didn't quite apply. While looking at the issues for the repository that I (think! I) subscribed to, I tried the various search criteria dropdowns with no luck. Last but not least, I read how to subscribe here at SO in case it mentioned how to see the subscribed list.
To those who might flag this as not being about programming, I can only ask for a better place to put this? As Github is a commonly used programming tool, I view this as highly relevant.
You can see all the GitHub issues you are currently subscribed to at https://github.com/notifications/subscriptions
You can navigate to this page from any page by clicking the notification/bell icon on the top right and then selecting "Manage notifications" > "Subscriptions" from the left menu panel.
Github does not have any option to list all the watched issues.
Marking labels on such issues also does not solve the purpose.
But github sends notification whenever there is any change in the issue. So you can check all the notification at a single place https://github.com/notifications
By default, this will show unread notifications (also indicated by a mailbox with a number in the top right corner). From that page you can choose "All Notifications", or https://github.com/notifications?all=1 to see all the issues being watched that have had at least one update since you subscribed to it.
According to the GitHub API v3 documentation1, there is a way to list subscribed issues in owned repositories, member repositories, and organization repositories. However, it does not list subscribed issues from any arbitrary repository in which you are not involved.
On Unix you can access the API like this (just enter your GitHub password when propmted):
curl --user "MyUserName" https://api.github.com/issues?filter=subscribed
Output:
[
{
"url": "https://api.github.com/repos/owner1/repoA/issues/3",
"repository_url": "https://api.github.com/repos/owner1/repoA",
...etc...
Or use this command to format the output as a list of links to the issues:
curl --user "MyUserName" https://api.github.com/issues?filter=subscribed | \
grep '"url"' | grep -o 'https://api.github.com/repos/.*/issues/[0-9]*' | \
sed 's#https://api.github.com/repos/#https://github.com/#'
Output:
https://github.com/owner1/repoA/issues/3
https://github.com/owner1/repoB/issues/14
https://github.com/owner2/repoC/issues/1
1 Since my edit to the first answer mentioning the GitHub API was rejected, I'm adding the examples here.
The following method does not work for subscribe-only issues.
As a workaround you can enter this into the search box, either on https://github.com/, or on https://github.com/issues/
is:open is:issue involves:YourUserName
This will show you all issues in which you are involved in some way, but not issues you are only subscribed to. The GitHub help page states:
The involves qualifier is just a logical OR between the author, assignee, mentions and commenter qualifiers for the same user.
If you want to see all the issues for a certain project that you have been part of i.e, interacted with that issue in any way. Do this;
In the search of Github issues do this.
is:issue commenter:<username here>
This will list all the issues that you are watching.
Seems you can fetch this information via Github API
https://developer.github.com/v3/issues/#parameters
GET /orgs/:org/issues
Parameters
Name Type Description
filter string Indicates which sorts of issues to return. Can be one of:
* assigned: Issues assigned to you
* created: Issues created by you
* mentioned: Issues mentioning you
* subscribed: Issues you're subscribed to updates for
* all: All issues the authenticated user can see, regardless of participation or creation
Default: assigned