0

At work I loaded a project that was unloaded in the solution (only C# code) we work with, and that a colleague (who left since a year) was maintaining. The project is not building now because a class it uses is not defined anymore. And for sure it was defined before, somewhere. I already looked in histories of obvious and less obvious places where this class could have been defined, without success.

Is it possible to find (through visual studio source control explorer or elsewhere, or in Azure devops) the first changeset in which a file contained a reference to (the name of) this class ? The repo is a pure TFS repo (sadly no git)

(I tried ctrl+g in source control explorer, such kind of search is impossible.)

Olórin
  • 3,367
  • 2
  • 22
  • 42
  • Hi, what do you mean 'pure TFS repo(sadly no git)'? Just want to confirm, what the service you are using, Azure DevOps service or DevOps server on-prem? And does the TFS you said means TFVC(Team Foundation version control)? – Bowman Zhu-MSFT Mar 17 '22 at 08:21
  • It's indeed a TFVC with Azure Devops. (Sorry for having been inprecise.) – Olórin Mar 17 '22 at 08:35
  • Shared the detailed steps to get the changes' content, you can have a check. – Bowman Zhu-MSFT Mar 17 '22 at 11:18
  • Thanks a lot for your precise answer, I'll check on monday and will come back at you. – Olórin Mar 19 '22 at 07:04

1 Answers1

0

I found a method to find the class if the class existed before.

You can retrieve all changes in TFVC of Azure DevOps by following the steps below:

1, get all of the changes url in your TFVC:

https://dev.azure.com/<OrganizationName>/<ProjectName>/_apis/tfvc/changesets?api-version=6.0

Just a sample, if you are using Python:

import http.client

conn = http.client.HTTPSConnection("dev.azure.com")
payload = ''
headers = {
  'Authorization': 'Basic <PAT token>',
 
}
conn.request("GET", "/<OrganizationName>/<ProjectName>/_apis/tfvc/changesets?api-version=6.0", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

Detailed steps about how to get PAT token:

https://learn.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=azure-devops&tabs=Windows

This will return a json response, there will list all of the changes url.

2, Send request to those changes urls to show the details:

enter image description here

3, Send request to the changes content urls:

enter image description here

enter image description here

4, After that, you will get the content of the changes, You can store them in your favorite data structure for later retrieval.

Above steps are all GET method. These code are similar so I just share one code sample.

5, Write code to find the specific Class name in each change content:

Examples for string find in Python

After that, you will be able to find it. Above steps is based on Python, you can use other languages.

Documents refer:

https://learn.microsoft.com/en-us/rest/api/azure/devops/tfvc/changesets?view=azure-devops-rest-6.0

Bowman Zhu-MSFT
  • 4,776
  • 1
  • 9
  • 10