-1

I am new to stash and git repositories, and trying to learn things.

I was asked to get the stats of stash repositories being created.

I want to find things like:

  1. How many repositories were created each month for each project?
  2. How many total repositories we have in total? e

I need to write a script for doing this from command line.

Can someone share some knowledge on how to proceed on this or a little overview of code if you have already done such kind of stuff.

KyleMit
  • 30,350
  • 66
  • 462
  • 664
  • 1
    "1) How many repositories were created each month for each project? 2) How many total repositories we have in total?" Do you mean how many commits? In many cases you'll only have a single repository per project, and if you have more than one it will probably be a small number and won't change often. – ChrisGPT was on strike Apr 10 '15 at 18:53
  • No I was talking about repositories. I meant as of a project can have various modules and each of them having different repositories but under same project. This way, having for example four projects with few repositories in each and new repositories might come in future. – Anand Varma Apr 10 '15 at 19:36
  • 1
    You just need to use `find` to find out the number of `.git` directories. Your use case is very weird though. – 4ae1e1 Apr 10 '15 at 21:09
  • That would only give me number of repositories I have but there are two things which should be considered too: For this to work, I need to clone all the repositories that exists from stash and I need the stats about the number of repositories created per month. – Anand Varma Apr 10 '15 at 23:16

1 Answers1

0

One option, although not necessarily the only option, would be to write a script/program to scrape the REST APIs. You would need to list the projects, and for each project list all the repositories. From memory Stash doesn't track the created date of repositories so you may need to keep your own

https://developer.atlassian.com/stash/docs/latest/reference/rest-api.html

You could also create a plugin which would do roughly the same thing, but being able to bypass permissions and run faster (avoiding all those network calls).

https://developer.atlassian.com/stash/docs/latest/how-tos/creating-a-stash-plugin.html

Finally, the above suggestion to look at the repositories on disk, on the Stash server (assuming you have access) may be trivial because you'll have the directory created timestamps as well.

https://confluence.atlassian.com/display/STASH/Stash+home+directory

You can also access that directory from a plugin if that helps avoid accessing the server directly.

charleso
  • 1,816
  • 14
  • 12