Bit Racketeer
Bit Racketeer

Reputation: 583

Export list of all commit details in VSTS / Azure DevOps into file?

I want to export a list of all commits in a repository (date-time, author, comment) into a file (of any format: CSV, XML, JSON, XLS etc.) which I will then analyse in a spreadsheet.

I want to compute stats such as:

This is for a high-level management report so non-technical managers can understand the size of effort without blinding them with actual code & architecture details.

There seems to be no obvious way to do this. I find a few complicated ideas in Git command line documentation but none that yields this info. Admittedly I am not an expert in Git.

Does anyone know a simple easy way to get high-level per-commit info out of VSTS / Azure DevOps or Git command line?

Intuitively this should be really easy but so far I have to copy/paste each screenful of commits into a spreadsheet and build up the info in steps. Crazily manual process. But it's all viewable in the Azure Devops browser interface under Commits so why can't I export it all at once?

Surely I am not the only person on earth who wants to analyse commit activity in this way! But so far I can find nothing online.

Upvotes: 11

Views: 14893

Answers (2)

Sebastian Wróbel
Sebastian Wróbel

Reputation: 61

I was looking for that same :) Looks that management need similar reports everywhere.

And my solution is more simple i think. After reading AvureDevOps API i realise that we can get all information by simple REST query (it can be executed from a browser as it is GET)

https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/commits?api-version=5.1&top$=10000

That give all what you need, including number of changes.

Reference to MS Docs: https://learn.microsoft.com/en-us/rest/api/azure/devops/git/commits/get%20commits?view=azure-devops-rest-5.1

Upvotes: 6

Bit Racketeer
Bit Racketeer

Reputation: 583

Thanks to @Philippe for guiding to the answer:

  • launch MS-DOS command line in the .git subdirectory for the solution
  • issue command: git log --pretty=format:%h,%an,%aD,%s > ./GitLog.csv
  • wait for GitLog.csv file to appear and open in spreadsheet program

Format option meanings:

  • %h = commit hash
  • %an = Author Name
  • %aD = commit date
  • %s = subject (comment of commit)

See here for more: https://git-scm.com/docs/pretty-formats and https://devhints.io/git-log-format

This solution doesn't give number of files or size of each commit, but it's a strong start.

(Philippe if you can move your comment in a proper answer rather, I'll give you the credit for providing the answer)

Upvotes: 18

Related Questions