Reputation: 95
In GitLab I am able to see who has forked my repository by clicking the following link:
Does anyone know if there is a similar capability within Azure DevOps?
I was able to find the following API call however it doesn't seem to work:
https://learn.microsoft.com/en-us/rest/api/azure/devops/git/forks/list?view=azure-devops-rest-6.0
-> I pass it a repo and various container ids where I know there are forks of that repo and it returns empty results.
Even when I find a fork in Azure devops by manually traversing the UI I cannot find a place to view where that repo was forked from.
Any help on the above would be greatly appreciated.
Upvotes: 4
Views: 1863
Reputation: 156654
If you create a pull request for a repository that has been forked, its "into" options will include a select box that includes the list of forks from that repository.
Upvotes: 2
Reputation: 76910
Even when I find a fork in Azure devops by manually traversing the UI I cannot find a place to view where that repo was forked from.
You could use the REST API Forks - Get Fork Sync Requests to retrieve all requested fork sync operations on this repository:
GET https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryNameOrId}/forkSyncRequests?api-version=6.0-preview.1
As the test result:
We could to know the repo ID where current repo was forked from.
And we could use the Repositories - List to know the name of the Repo:
Update:
In GitLab I am able to see who has forked my repository by clicking the link. Does anyone know if there is a similar capability within Azure DevOps?
If you want to know who forks your repo, you could just use your REST API
GET https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryNameOrId}/forks/{collectionId}?api-version=6.0-preview.1
And we could use the oraganiztion id for the collectionId
. We could use following RETS API to get the oraganiztion id:
Post https://dev.azure.com/{organization1}/_apis/Contribution/HierarchyQuery?api-version=5.0-preview.1
Body:
{
"contributionIds": ["ms.vss-features.my-organizations-data-provider"],
"dataProviderContext":
{
"properties":{}
}
}
The test result:
Upvotes: 1