开发者

How do I count the number of commits made in to all repos hosted by gitosis on my server

开发者 https://www.devze.com 2023-03-20 20:44 出处:网络
I am trying to found out the total number of commits made across all repositories hosted on a gitosis install I have. Anyone have any ideas to how I may开发者_Go百科 do this?There are certain ways to

I am trying to found out the total number of commits made across all repositories hosted on a gitosis install I have. Anyone have any ideas to how I may开发者_Go百科 do this?


There are certain ways to count the number of commits like:

git rev-list --all | wc -l

or for a branch

git log branch --pretty=oneline | wc -l

Can you use that on each repo or write a script that goes to each of the repo, runs any of the above and get the count?


ls /path/to/repos/ | xargs -I % git --git-dir=/path/to/repos/%/.git rev-list --all 2>/dev/null | wc -l

That works fairly well for me. You can grep -v zip or use a more specific find query to just find specific directories, too.

Update: use rev-list --all instead of log --pretty=oneline.


For newer versions of git (tested on 2.14.1), the command git rev-list --count HEAD will work, and give the same result as git rev-list --all | wc -l.


I am not aware of a feature in gitosis that do it, but since gitosis saves all the repositories in one directory it is quite simple.

For instance, the default gitosis installation (well, or at least mine :)) stores the repositories in ~git/repositories.

Go to that directory and execute something similar to this:

for rep in `find . -maxdepth 1 -mindepth 1 -type d -print`; do 
    echo $rep; 
    (cd $rep && git log -pretty=oneline | wc -l); 
done

Can probably do it neater, but it shows the repository followed by the commit count.


On my gitosis server i use this command

cd /path/to/repos/
ls | xargs -I % git --git-dir=% rev-list --all 2>/dev/null | wc -l

And in gitorious server i use

array=($(ls /path/to/repos/))
for i in ${array[@]}; do cd /path/to/repos/$i; ls | xargs -I % git --git-dir=% rev-list --all 2>/dev/null | wc -l; done

This will show the commits for all projects, you should add on your own


I would recommend making an "inspection repository". I use gitolite but the process would be the same:

First create a repo that gathers commits from all the repositories:

git init --bare all && cd all
ssh gitolite@gitserver | grep @W | xargs -i{} git remote add {} gitolite@gitserver:{}.git
git fetch --all

Now you should be able to get a count by doing a line count:

git log --all --format=%h | wc -l

Hope this helps.

0

精彩评论

暂无评论...
验证码 换一张
取 消