git / python> git log analysis (v0.1, v0.2)> calculate total working time in minutes from git log

Something suddenly occurred to me that we can calculate total working time from git log by and large.

To do so, and to study python, I tried to make a python script.

Program v0.1 @ github v0.2 @ github

How to use

~~Firstly, you need to create tmp.log file by git log command at the repository you want to investigate.~~

In version v0.2 and later, you do not need to run git log command. Instead, the script automatically make tmp.log file.

$ git log --pretty=format:'%h %ad %s' --date=iso > tmp.log

Then, you can obtain the total working time by the script:

$ ./git_log_analysis.py

The output is as follows. The last line includes the total working time in minutes (e.g. 764).

...
2015-11-13 21:11:06 801 750 # sec, min
2015-11-13 12:53:26 29860 750 # sec, min
2015-11-13 12:44:36 530 758 # sec, min
2015-11-13 12:37:53 403 764 # sec, min
2015-11-13 07:12:08 19545 764 # sec, min

Uncertainty in the calculation

The script takes the elapsing time more than and equal to 4 hours as zero. This is for my case. The user can modify according to their commiting style.

def calcElapsedTimeInMinutes(diff_sec):
    diff_min = diff_sec / 60
    diff_hr = diff_min / 60
    if diff_hr >= 4:
        return 0
    else:
        return diff_min

The script only takes the two datetime difference. Therefore, there might have the various uncertainties including:

Link Related (in Japanese) http://qiita.com/7of9/items/e1e151794f80fb9c24fc

Recommended Posts

git / python> git log analysis (v0.1, v0.2)> calculate total working time in minutes from git log
git / python> git log analysis (v0.1, v0.2)> Implementation to estimate work time from git log
Get time series data from k-db.com in Python
Let's parse the git commit log in Python!
Survival time analysis learned in Python 2 -Kaplan-Meier estimator
Convert date timezone (time difference) in Python (from string)
Output the time from the time the program was started in python
Python: Time Series Analysis
Association analysis in Python
Regression analysis in Python
[Understand in the shortest time] Python basics for data analysis
[Python] Display the elapsed time in hours, minutes, and seconds (00:00:00)
Working with LibreOffice in Python
OCR from PDF in Python
Working with sounds in Python
Axisymmetric stress analysis in Python
Wrapping git operations in Python
Simple regression analysis in Python
How to calculate "xx time" in one shot with Python timedelta