From: dsc Date: Fri, 25 May 2012 18:09:15 +0000 (-0700) Subject: Adds Python packaging and updates README. X-Git-Url: http://git.less.ly:3516/?a=commitdiff_plain;h=00627fd573f921f0db5058c70df93d833f34dad3;p=gerrit-stats.git Adds Python packaging and updates README. --- diff --git a/README.md b/README.md index a85f0ba..cd6fa46 100644 --- a/README.md +++ b/README.md @@ -1,23 +1,76 @@ # Gerrit Code-Review Stats + +`gerrit-stats` generates code-review stats based from Gerrit commits. + + +## Installation + +This package is not in PyPi, as it is WMF-specific. Install it by cloning the repo, and then using `pip` or `easy_install`: + +```sh +git clone git@less.ly:gerrit-stats.git +pip install gerrit-stats +``` + + +## Workflow + This initial version generates two metrics on a day-by-day basis: -1) Number of commits that have been completely untouched, no -1, -2, +1, +2 -2) Number of commits with only +1 -Unfortunately, it proves (AFAIK) impossible to determine the number of commits per day. Gerrit's search is so broken that it is not even funny. The NOT operator does not work and you cannot use any logic when querying for is: +1. Number of commits that have been completely untouched (no `-1`, `-2`, `+1`, `+2` rating) +2. Number of commits with only `+1` + +Unfortunately, it proves (AFAIK) impossible to determine the number of commits per day. Gerrit's +search is so broken that it is not even funny. The NOT operator does not work and you cannot use any +logic when querying for `is:`. + +This means that it is hard to put these numbers in context. + +1. The scripts will query all gerrit repos, except for the repos that are mentioned in the + settings.ignore_repos variable. Currently repos containing the word 'test' are ignored. +2. Queries are run using the SSH interface, each repo has it's own dataset. If the file does not + exist a new file is created with a header line, if the file already exists then the new + observation is appended. + + +## Roadmap + +### Todo + +- This script needs to be puppetized and launched from a cronjob every day at 11:59PM UTC. + Andrew, maybe you can have a look at this next week? +- We need to figure out a way to get total commits per day. +- Right now each repository has it's own dataset but we need to add functionality in Limn to + make logical groups of datasets where the values are summed. + + +### Known Issues + +- Adding a new metric to existing datasets might not work because of the mismatch between number + of headings and number of fields. +- To run gerrit-stats you need an active gerrit ssh account. + + +## Feedback + +Bugs? Feature requests? Feedback? Contact [Diederik van Liere](mailto:dvanliere@wikimedia.org). + -This means that it is hard to put these numbers in context. +## License -Workflow: -1) The scripts will query all gerrit repos, except for the repos that are mentioned in the settings.ignore_repos variable. Currently repos containing the word 'test' are ignored -2) Queries are run using the SSH interface, each repo has it's own dataset. If the file does not exist a new file is created with a header line, if the file already exists then the new observation is appended. +Copyright (C) 2012 Diederik van Liere, Wikimedia Foundation -Todolist: -1) This script needs to be puppetized and launched from a cronjob every day at 11:59PM UTC. Andrew, maybe you can have a look at this next week? -2) We need to figure out a way to get total commits per day -3) RIght now each repository has it's own dataset but we need to add functionality in Limn to make logical groups of datasets where the values are summed. +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. -Known Issues -1) Adding a new metric to existing datasets might not work because of the mismatch between number of headings and number of fields. -2) To run gerrit-stats you need an active gerrit ssh account. +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. diff --git a/gerritstats/__init__.py b/gerritstats/__init__.py new file mode 100755 index 0000000..57a582b --- /dev/null +++ b/gerritstats/__init__.py @@ -0,0 +1,31 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +""" +gerrit-stats: Generate codereview stats based from Gerrit commits +Copyright (C) 2012 Diederik van Liere, Wikimedia Foundation + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +""" + +__version__ = '0.1.0' +VERSION = tuple(map(int, __version__.split('.'))) + +from classes import Gerrit, Settings, Metric, Repo +from stats import main + + +if __name__== '__main__': + main() + diff --git a/classes.py b/gerritstats/classes.py similarity index 100% rename from classes.py rename to gerritstats/classes.py diff --git a/stats.py b/gerritstats/stats.py old mode 100644 new mode 100755 similarity index 98% rename from stats.py rename to gerritstats/stats.py index fca1ad5..242974c --- a/stats.py +++ b/gerritstats/stats.py @@ -168,7 +168,7 @@ def construct_dataset(settings, repos, metric, output, gerrit): def main(): gerrit = Gerrit() settings = Settings(gerrit) - print 'Fetching list of all gerrit repositories...' + print 'Fetching list of all gerrit repositories...\n' repos = create_repo_set(gerrit, settings) for metric in settings.metrics.itervalues(): @@ -184,4 +184,4 @@ def main(): if __name__== '__main__': - main() \ No newline at end of file + main() diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..bb4fbaa --- /dev/null +++ b/setup.py @@ -0,0 +1,51 @@ +#!python +# -*- coding: utf-8 -*- +import sys, os, re +from os.path import dirname, abspath, join +from setuptools import setup, find_packages + +HERE = abspath(dirname(__file__)) +readme = open(join(HERE, 'README.md'), 'rU').read() + +package_file = open(join(HERE, 'gerritstats/__init__.py'), 'rU') +__version__ = re.sub( + r".*\b__version__\s+=\s+'([^']+)'.*", + r'\1', + [ line.strip() for line in package_file if '__version__' in line ].pop(0) +) + + +setup( + name = 'gerrit-stats', + version = __version__, + description = 'Generate codereview stats based from Gerrit commits', + long_description = readme, + url = 'http://git.less.ly/?p=gerrit-stats.git', + + author = 'Diederik van Liere', + author_email = 'dvanliere@wikimedia.org', + + packages = find_packages(), + entry_points = { 'console_scripts':['gerrit-stats = gerritstats:main'] }, + + # install_requires = [ + # "bunch >= 1.0", + # "PyYAML >= 3.10", + # ], + + keywords = ['gerrit', 'stats'], + classifiers = [ + "Development Status :: 4 - Beta", + "Environment :: Console", + "Intended Audience :: Developers", + "Topic :: Utilities" + "Topic :: Software Development :: Libraries :: Python Modules", + "Programming Language :: Python", + "Programming Language :: Python :: 2.6", + "Programming Language :: Python :: 2.7", + "Operating System :: OS Independent", + "License :: OSI Approved :: GPLv2 License", + ], + zip_safe = False, + license = "GPLv2", +)