praqma / git-metrics Goto Github PK
View Code? Open in Web Editor NEWUtil script(s) to scrape data from git repositories to help teams improve.
Util script(s) to scrape data from git repositories to help teams improve.
Given this input:
python git_metrics.py release-lead-time [--tag-pattern=<fn_match>] [--earliest-date=<timestamp>] <path_to_git_repo> > repo_data.csv
I don't understand what an example tag-pattern would be etc
Tried running the below command after cloning the repository on local, but except for the column details not getting any output in the repo_data.csv file
python git_metrics.py release-lead-time --tag-pattern=v* C:\Users****\OneDrive\Desktop\try_metrics\new_ones > repo_data.csv
Repository cloned
https://github.com/malikdaman24/new_one
hi, may i know what is the output unit for gitMetrics.TaskDuration as it does not seem to be seconds or milliseconds.
i ran a puppeteer task and used this this code:
console.log(gitMetrics.Timestamp)
console.log(gitMetrics.TaskDuration)
the output was the fallowing:
87282.848162
0.052738
it did not make sense to me.
the first number is clearly in ms. but the second one does not make sense if it was in seconds because it not close to the first one. Thank you.
Regards,
$ pip install -r requirements.txt
Collecting pytest (from -r requirements.txt (line 1))
Downloading https://files.pythonhosted.org/packages/76/52/fc48d02492d9e6070cb672d9133382e83084f567f88eff1c27bd2c6c27a8/pytest-3.5.1-py2.py3-none-any.whl (192kB)
100% |████████████████████████████████| 194kB 2.0MB/s
Requirement already satisfied: docopt in /usr/local/lib/python2.7/dist-packages (from -r requirements.txt (line 2))
Collecting matplotlib (from -r requirements.txt (line 3))
Downloading https://files.pythonhosted.org/packages/33/da/6409d32c46778ed20308e83bc501ff2ff8a9cbda5dd7b26362c5e99a6149/matplotlib-2.2.2-cp27-cp27mu-manylinux1_x86_64.whl (12.6MB)
100% |████████████████████████████████| 12.6MB 106kB/s
Collecting pandas (from -r requirements.txt (line 4))
Downloading https://files.pythonhosted.org/packages/6b/b5/76538d8a202f8c368d30c18892d33664d1a3b2c078af8513ee5b5d172629/pandas-0.22.0-cp27-cp27mu-manylinux1_x86_64.whl (24.3MB)
100% |████████████████████████████████| 24.3MB 46kB/s
Requirement already satisfied: requests in /usr/lib/python2.7/dist-packages (from -r requirements.txt (line 5))
Requirement already satisfied: setuptools in /usr/lib/python2.7/dist-packages (from pytest->-r requirements.txt (line 1))
Collecting py>=1.5.0 (from pytest->-r requirements.txt (line 1))
Downloading https://files.pythonhosted.org/packages/67/a5/f77982214dd4c8fd104b066f249adea2c49e25e8703d284382eb5e9ab35a/py-1.5.3-py2.py3-none-any.whl (84kB)
100% |████████████████████████████████| 92kB 3.5MB/s
Collecting more-itertools>=4.0.0 (from pytest->-r requirements.txt (line 1))
Downloading https://files.pythonhosted.org/packages/4a/88/c28e2a2da8f3dc3a391d9c97ad949f2ea0c05198222e7e6af176e5bf9b26/more_itertools-4.1.0-py2-none-any.whl (47kB)
100% |████████████████████████████████| 51kB 4.9MB/s
Collecting funcsigs; python_version < "3.0" (from pytest->-r requirements.txt (line 1))
Downloading https://files.pythonhosted.org/packages/69/cb/f5be453359271714c01b9bd06126eaf2e368f1fddfff30818754b5ac2328/funcsigs-1.0.2-py2.py3-none-any.whl
Requirement already satisfied: six>=1.10.0 in /usr/lib/python2.7/dist-packages (from pytest->-r requirements.txt (line 1))
Collecting attrs>=17.4.0 (from pytest->-r requirements.txt (line 1))
Downloading https://files.pythonhosted.org/packages/b5/60/4e178c1e790fd60f1229a9b3cb2f8bc2f4cc6ff2c8838054c142c70b5adc/attrs-17.4.0-py2.py3-none-any.whl
Collecting pluggy<0.7,>=0.5 (from pytest->-r requirements.txt (line 1))
Downloading https://files.pythonhosted.org/packages/82/05/43e3947125a2137cba4746135c75934ceed1863f27e050fc560052104a71/pluggy-0.6.0-py2-none-any.whl
Collecting cycler>=0.10 (from matplotlib->-r requirements.txt (line 3))
Downloading https://files.pythonhosted.org/packages/f7/d2/e07d3ebb2bd7af696440ce7e754c59dd546ffe1bbe732c8ab68b9c834e61/cycler-0.10.0-py2.py3-none-any.whl
Collecting numpy>=1.7.1 (from matplotlib->-r requirements.txt (line 3))
Downloading https://files.pythonhosted.org/packages/76/4d/418dda252cf92bad00ab82d6b2a856e7843b47a5c2f084aed34b14b67d64/numpy-1.14.2-cp27-cp27mu-manylinux1_x86_64.whl (12.1MB)
100% |████████████████████████████████| 12.1MB 78kB/s
Collecting backports.functools-lru-cache (from matplotlib->-r requirements.txt (line 3))
Downloading https://files.pythonhosted.org/packages/03/8e/2424c0e65c4a066e28f539364deee49b6451f8fcd4f718fefa50cc3dcf48/backports.functools_lru_cache-1.5-py2.py3-none-any.whl
Collecting subprocess32 (from matplotlib->-r requirements.txt (line 3))
Downloading https://files.pythonhosted.org/packages/b8/2f/49e53b0d0e94611a2dc624a1ad24d41b6d94d0f1b0a078443407ea2214c2/subprocess32-3.2.7.tar.gz (54kB)
100% |████████████████████████████████| 61kB 4.0MB/s
Collecting kiwisolver>=1.0.1 (from matplotlib->-r requirements.txt (line 3))
Downloading https://files.pythonhosted.org/packages/3a/62/a8c9bef3059d55ab38e41fe9cba4fad773bfc04e47290bab84db1c18262e/kiwisolver-1.0.1-cp27-cp27mu-manylinux1_x86_64.whl (951kB)
100% |████████████████████████████████| 952kB 964kB/s
Collecting pytz (from matplotlib->-r requirements.txt (line 3))
Downloading https://files.pythonhosted.org/packages/dc/83/15f7833b70d3e067ca91467ca245bae0f6fe56ddc7451aa0dc5606b120f2/pytz-2018.4-py2.py3-none-any.whl (510kB)
100% |████████████████████████████████| 512kB 2.2MB/s
Collecting python-dateutil>=2.1 (from matplotlib->-r requirements.txt (line 3))
Downloading https://files.pythonhosted.org/packages/0c/57/19f3a65bcf6d5be570ee8c35a5398496e10a0ddcbc95393b2d17f86aaaf8/python_dateutil-2.7.2-py2.py3-none-any.whl (212kB)
100% |████████████████████████████████| 215kB 2.7MB/s
Collecting pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 (from matplotlib->-r requirements.txt (line 3))
Downloading https://files.pythonhosted.org/packages/6a/8a/718fd7d3458f9fab8e67186b00abdd345b639976bc7fb3ae722e1b026a50/pyparsing-2.2.0-py2.py3-none-any.whl (56kB)
100% |████████████████████████████████| 61kB 3.9MB/s
Installing collected packages: py, more-itertools, funcsigs, attrs, pluggy, pytest, cycler, numpy, backports.functools-lru-cache, subprocess32, kiwisolver, pytz, python-dateutil, pyparsing, matplotlib, pandas
Exception:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/commands/install.py", line 342, in run
prefix=options.prefix_path,
File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/req/req_set.py", line 784, in install
**kwargs
File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/req/req_install.py", line 851, in install
self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/req/req_install.py", line 1064, in move_wheel_files
isolated=self.isolated,
File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/wheel.py", line 345, in move_wheel_files
clobber(source, lib_dir, True)
File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/wheel.py", line 316, in clobber
ensure_dir(destdir)
File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/utils/__init__.py", line 83, in ensure_dir
os.makedirs(path)
File "/usr/lib/python2.7/os.py", line 157, in makedirs
mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/py-1.5.3.dist-info'
You are using pip version 9.0.1, however version 10.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
$ pip install --upgrade pip
Collecting pip
Downloading https://files.pythonhosted.org/packages/0f/74/ecd13431bcc456ed390b44c8a6e917c1820365cbebcb6a8974d1cd045ab4/pip-10.0.1-py2.py3-none-any.whl (1.3MB)
100% |████████████████████████████████| 1.3MB 851kB/s
Installing collected packages: pip
Found existing installation: pip 9.0.1
Uninstalling pip-9.0.1:
Exception:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/commands/install.py", line 342, in run
prefix=options.prefix_path,
File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/req/req_set.py", line 778, in install
requirement.uninstall(auto_confirm=True)
File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/req/req_install.py", line 754, in uninstall
paths_to_remove.remove(auto_confirm)
File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/req/req_uninstall.py", line 115, in remove
renames(path, new_path)
File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/utils/__init__.py", line 267, in renames
shutil.move(old, new)
File "/usr/lib/python2.7/shutil.py", line 314, in move
rmtree(src)
File "/usr/lib/python2.7/shutil.py", line 261, in rmtree
rmtree(fullname, ignore_errors, onerror)
File "/usr/lib/python2.7/shutil.py", line 266, in rmtree
onerror(os.remove, fullname, sys.exc_info())
File "/usr/lib/python2.7/shutil.py", line 264, in rmtree
os.remove(fullname)
OSError: [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/EGG-INFO/requires.txt'
You are using pip version 9.0.1, however version 10.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Then obviously the script fails also.
I saw in the readme I need to use python3, so ran again but deps are still missing:
$ python3 git_metrics.py --help
Traceback (most recent call last):
File "git_metrics.py", line 23, in <module>
import docopt
ModuleNotFoundError: No module named 'docopt'
(Ubuntu 17.04 install python 3 https://askubuntu.com/questions/946112/what-with-python-3-6 )
It worked for me to use Python 3, and pip3 matching matchin python3:
sudo apt-get install python3-pip
pip3 install -r requirements.txt
I tried running below commands, but did not get the output. Can you please help me with the issue? It would help if you can provide a sample or an example? I might be not providing the correct inputs.
python git_metrics.py release-lead-time [--tag-pattern=v*] [--earliest-date=10-06-2020] https://github.com/malikdaman24/test_metrics > repo_data.csv
It would really help if by giving an example you can explain what logic have been used to calculate all these metrics; as people like me who are not good technically, can use this to better understand the output.
$ python3 git_metrics.py open-branches --master-branch=master --plot /home/bue/github-repos/jenkinsci/configuration-as-code-plugin
Traceback (most recent call last):
File "/usr/lib/python3.6/tkinter/__init__.py", line 37, in <module>
import _tkinter
ModuleNotFoundError: No module named '_tkinter'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "git_metrics.py", line 138, in <module>
main()
File "git_metrics.py", line 71, in main
plot_open_branches_metrics(data)
File "/home/bue/github-repos/praqma/git-metrics/git_metrics_open_branches.py", line 7, in plot_open_branches_metrics
import matplotlib.pyplot as plt
File "/home/bue/.local/lib/python3.6/site-packages/matplotlib/pyplot.py", line 115, in <module>
_backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
File "/home/bue/.local/lib/python3.6/site-packages/matplotlib/backends/__init__.py", line 62, in pylab_setup
[backend_name], 0)
File "/home/bue/.local/lib/python3.6/site-packages/matplotlib/backends/backend_tkagg.py", line 4, in <module>
from . import tkagg # Paint image to Tk photo blitter extension.
File "/home/bue/.local/lib/python3.6/site-packages/matplotlib/backends/tkagg.py", line 5, in <module>
from six.moves import tkinter as Tk
File "/home/bue/.local/lib/python3.6/site-packages/six.py", line 92, in __get__
result = self._resolve()
File "/home/bue/.local/lib/python3.6/site-packages/six.py", line 115, in _resolve
return _import_module(self.mod)
File "/home/bue/.local/lib/python3.6/site-packages/six.py", line 82, in _import_module
__import__(name)
File "/usr/lib/python3.6/tkinter/__init__.py", line 39, in <module>
raise ImportError(str(msg) + ', please install the python3-tk package')
ImportError: No module named '_tkinter', please install the python3-tk package
sudo apt install python3-tk
solved it
In addition to showing the amount of time, a given commit haven't been integrated, one could also measure how much (as in changed lines of code) change is laying on a given branch:
git log --numstat --pretty="%H" commit1..commit2 | awk 'NF==3 {plus+=$1; minus+=$2} END {printf("+%d, -%d\n", plus, minus)}'
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.