git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Jakub Narębski" <jnareb@gmail.com>
To: Ernesto Maserati <ernesto.2.maserati@gmail.com>, git@vger.kernel.org
Subject: Re: How to generate feature branch statistics?
Date: Wed, 20 Jul 2016 15:56:22 +0200	[thread overview]
Message-ID: <578F8306.3070306@gmail.com> (raw)
In-Reply-To: <CAOHAwykGkfY7M30jT8t0k6Gsdy5QSBHmAPiWYoKibjUgS-G6hg@mail.gmail.com>

W dniu 2016-07-20 o 10:05, Ernesto Maserati pisze:

> I assume that feature branches are not frequently enough merged into
> master. Because of that we discover bugs later than we could with a more
> continuous code integration. I don't want to discuss here whether feature
> branches are good or bad.
> 
> I want just to ask is there a way how to generate a statistic for the
> average duration of feature branches until they are merged to the master? I
> would like to know if it is 1 day, 2 days or lets say 8 or 17 days. Also it
> would be interesting to see the statistical outliers.
> 
> I hope my motivation became clear and what kind of git repository data I
> would like to produce.
> 
> Any ideas?

There are at least two tools to generate statistics about git repository,
namely Gitstat (https://sourceforge.net/projects/gitstat) and GitStats
(https://github.com/hoxu/gitstats), both generating repo statistics as
a web page. You can probably find more... but I don't know if any includes
the statistics you need.

I assume that you have some way of determining if the merge in 'master'
branch is a merge of a topic branch, or of long-lived graduation branch
(e.g. 'maint' or equivalent). To simplify the situation, I assume that
the only merges in master are merges of topic branches:

  git rev-list --min-parents=2 master | 
  while read merge_rev; do 

You might want to add "--grep=maint --invert-grep" or something like
that to exclude merges of 'maint' branch.
	
We can get date of merge (authordate with %ad/%at, or committerdate
with %cd/%ct), as an epoch (seconds since 1970 -- which is good for
comparing datetimes and getting the interval between two events)

     MERGE_DATE=$(git show -s --date=format:%s --pretty=%ad $merge_rev)

Assuming that topic branches are always merged using two-head merge
as a second parent (--first-parent ancestry for master in master branch
only), then we can get the first revision on a merged topic branch with

     FIRST_REV=$(git rev-list $merge_rev^2 ^$merge_rev^1 | tail -1)

We can extract the date from this revision in the same way

     FIRST_DATE=$(git show -s --pretty=%at $FIRST_REV)

Print the difference (here to standard output, you might want to write
to a file)

     echo $(expr $MERGE_DATE - $FIRST_DATE)

And finish the loop.

  done

Then pass the output to some histogramming or statistics tool... or use
a spreadsheet. Note the results are in seconds.

HTH (not checked much)
-- 
Jakub Narębski

  parent reply	other threads:[~2016-07-20 13:56 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-20  8:05 How to generate feature branch statistics? Ernesto Maserati
2016-07-20 13:14 ` Jeff King
2016-07-20 18:49   ` Junio C Hamano
2016-07-20 23:10     ` Jakub Narębski
2016-07-20 23:31       ` Junio C Hamano
2016-07-20 13:56 ` Jakub Narębski [this message]
2016-07-20 18:10   ` Jakub Narębski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=578F8306.3070306@gmail.com \
    --to=jnareb@gmail.com \
    --cc=ernesto.2.maserati@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).