Retrieve list of all commits associated with a Bug Fix using TFS REST - rest

I'm trying to study TFS REST API, but to no avail it is just hard to understand what parameter is what in the sample request given in the documentation.
What i would ultimately like to do is retrieve a list of all the commits done in lets say a particular project that have a bug associated with them. I want to retrieve a list of all these commits but only the ones associated with a bug fix.
Can someone please help me with this?

Not sure which version control system you are using, TFVC or GIT. Assuming you talked about GIT since the commit mentioned in your question.
There is a related REST API to Get a list of commits. For what parameter is what, there are also a detail table with notes. Such as fromDate which stands for Start date to search from.
To retrieve the commits with bug fixed comment
To retrieve a list of all the commits in a particular project you could use the branch parameter. Usually should fix the bug in a QA branch or DEV branch.
GET https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249/commits?api-version=3.0-preview&branch=master
Then you just need to filter the comment with bug keyword commits.
To retrieve the commits related bug workitem
It's more accurate and convenient. First you need to get the bug workitems in your project. Using Get a list of work items Rest API with specific field such as "System.WorkItemType": "Bug", "System.TeamProject": "Your project name"
GET https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/wit/workitems?ids=297,299,300&fields=System.Id,System.Title,System.WorkItemType,Microsoft.VSTS.Scheduling.RemainingWork&api-version=1.0
When you associate a commit with the bug workitem, TFS will automatically add it as a linked item in workitem specified. Then you just need to get a workitem with links and attachments.

Assume you already have the Bug ID, you can use Get a WorkItem with links and attachments api to get all the commits associated with the bug.

Related

Why does GitHub Search (API) returns inconsistent content?

I am trying to fetch all the merged pull requests with a label. But for one repository and specifically, one single PR, the API / Search UI returns inconsistent values.
We all know the we can search in GitHub API in two ways:
Using the Global Search. Search Query returns 1 Result
Using the Project Level Search. Search Query returns 2 Results
Does anyone know what's the difference and why is it happening this way? Should I change my query or actually, it's the same query with different results.
Should we raise a bug in the GitHub API Issues page? Please can someone tell me why is this particular Pull Request not being counted?
I am not completely sure, but on observing the PRs, I can see that the 2 PR are there in repo, but only one is accepted as a contribution, the earlier one got reverted, after merge.
as you can see here: In your first PR that got merged... but later reverted back
so now this PR won't count, as it now longer belongs to the repo,
so it is not shown in Global Search,
But because it exists in log of PRs, it is still accessible from PR tab.
Because of that, Global Search shows just one PR.
I hope this explains the ambiguity we have stumbled upon. :)

Is there a way to create an alias of reviewers that can be added to a github pull request all at once?

The way we do pull requests at my company, we require 5 specific people to be on all pull requests into Repository A, and a different list of 4 people on all pull requests into Repository B. It's kinda a pain to remember which names go where and not leave anyone out.
Is there a way I can create an alias or something that will autofill in the review request fields that will add all the appropriate people?
For instance, I want to create RepositoryAReviewers and RepositoryBReviewers, and then whenever I pull request to either repository I can just put the alias in the review request field and hit submit. Does this exist?
What you want to do is create teams for these groups. For example, when I wish to merge code at work, I use the my-company/my-team-reviewers team, which pings all of the reviewers on my team. my-company is the name of your GitHub organization.
If you additionally want to require all reviews for a certain repository (or certain files within that repository) to be from a certain team, you can use the CODEOWNERS file to do so. That's especially useful if you have a core team for a project that you always want to do reviews, or if teams are responsible for certain subsystems.
A CODEOWNERS file that affects the entire repository would look like this:
* #my-company/core-dev
I had the same problem last week and made a simple chrome extension to create/save lists of usernames and bulk-add these lists as reviewers on my currently open PR
https://chrome.google.com/webstore/detail/github-reviewer-groups/mmgjipidkhkfimmfgcgklooinlcfonah?hl=en&authuser=0
It's open source too, so feel free to try improving it. The repo is here: https://github.com/KhaledAylii/Github-Reviewer-Groups/tree/master

Azure DevOps - Query to find work item by branch

I'm trying to query in Azure DevOps for retrieve all the work items related to a specific branch.
In this way I can figure out all the work done in the latest few month on that specific branch.
But I don't know if is possible or how to formulate the query to specify the branch. It is possible? If yes, which is the correct field?
Query to find work item by branch
For this issue , it is impossible to achieve by default. At present, there are no fields pointing to branches in azure devops, so you cannot query the work items related to a specific branch by specifying field.
As a workaround , agree with Shayki , you can customize a related branch field for the work item in the inherited process and fill it, so that you can retrieve the work item related to a specific branch by specifying the related branch field in the query.
In addition , you could also submit your request for this feature on our UserVoice site , which is our main forum for product suggestions. Thank you for helping us build a better Azure DevOps.

Github API: How to get the top contributors (sorted) for a given repository?

I don't see a clean/obvious way to do this using the github api. So I'm not even sure it's really that easy/feasible to do. Am I forced to compute this locally (eg: query for ALL the commits of a given repo, and then tally them by author?)
If there is a clean 1-2 API call step way, instead of iterating over all the commits, that would be great.
It's not a duplicate, because the other question is asking how to do this with command line. I need to only use the github API because I will be going over 200+ repos and it needs to be fully programatic, as it starts from the list repos api.
Based on comment of Xavier Guihot, I add parameter for query
?q=contributions&order=desc
It become to
https://api.github.com/repos/scala/scala/contributors?q=contributions&order=desc
(You can use this extension https://chrome.google.com/webstore/detail/json-formatter/bcjindcccaagfpapjjmafapmmgkkhgoa?hl=en , it help you easy to view result)

How can I query TFS to get a list of changesets that need to be merged into a parent branch?

We are using TFS2010 for source control, the source repository has 3 main branches; MAIN, REL and DEV
Consider this scenario:
Several developers are working in the REL branch (fixing shipping issues). As they work their changes are checked into the REL branch tested and subsiquently merged back into the MAIN branch.
When developers perform their merge (using the source code explorer in VS2010) if they pick the "selected changesets" option the dialog performs some sort of query and presents them with a list of candidate changesets that exist in the source (REL) branch that have not yet been merged into the target (MAIN) branch.
Given that there may be a delay between the DEV commit and the subsiquent merge we are finding people "forgetting" some changesets.
What I would like to do is create a work item query or Excel report that can reproduce the dialogs query results so we can add this to the projects SharePoint portal.
Specifically: given the current user, and a source and target branch name can I use WIQL or a Excel document to retrieve a list of changesets not currently merged into the target branch.
Can anyone tell if this is possible? and better still tell me how to do it!
The question TFS: List changesets that have not been merged asks a similar question but the aswer alludes to a "write your own code" solution, I would like to pull this off with the "out of the bag" tools; Excel or WIQL.
Take a look # this answer
How can I check which branches a TFS 2008 changeset has been merged into?
They outline the tf merge command to list the changesets that need to be merged.
When I had to do something like this I ran a command similar to the one in the answer above and fed it into a text file, with a little bit of tweaking, you could probably turn it into a .csv then open it in excel and filter it by user etc.
To my knowledge, WIQL is all about retrieving exclusively Work Items - so this aspect is a dead end.