From 7647e8232223abcf8651a08fbeb6ffb0cc28ce09 Mon Sep 17 00:00:00 2001 From: Chris Ward Date: Tue, 28 Apr 2015 10:58:47 +0200 Subject: [PATCH] docs to sphinx; githooks; rpm build fix --- .gitignore | 8 ++ Makefile | 14 ++- README.rst | 68 +++++------ docs/Makefile | 53 +++++++++ docs/conf.py | 224 ++++++++++++++++++++++++++++++++++++ docs/index.rst | 24 ++++ docs/man.1.rst | 149 ++++++++++++++++++++++++ docs/notes.rst | 16 --- docs/overview.rst | 1 + docs/release-notes.rst | 40 +++++++ git-hooks/commit-msg.py | 71 ++++++++++++ git-hooks/pre-commit.py | 120 +++++++++++++++++++ source/setup.py => setup.py | 13 +-- status-report.spec | 4 +- 14 files changed, 738 insertions(+), 67 deletions(-) create mode 100644 docs/Makefile create mode 100644 docs/conf.py create mode 100644 docs/index.rst create mode 100644 docs/man.1.rst delete mode 100644 docs/notes.rst create mode 120000 docs/overview.rst create mode 100644 docs/release-notes.rst create mode 100755 git-hooks/commit-msg.py create mode 100755 git-hooks/pre-commit.py rename source/setup.py => setup.py (84%) diff --git a/.gitignore b/.gitignore index 4cdb3667..0ec6e7f2 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,11 @@ pip-log.txt # coveralls code coverage .coverage + +# sphinx docs +_build +_static +_templates + +# rpm build files +tmp/ diff --git a/Makefile b/Makefile index f72ee358..81601533 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,7 @@ PACKAGE = status-report-$(VERSION) DOCS = $(TMP)/$(PACKAGE)/docs EXAMPLES = $(TMP)/$(PACKAGE)/examples CSS = --stylesheet=style.css --link-stylesheet -FILES = LICENSE README \ +FILES = LICENSE README.rst \ Makefile status-report.spec \ docs examples source @@ -23,13 +23,17 @@ endif all: push clean +# Looking for HTML docs? Could copy them too or just check out http://status-report.readthedocs.org/ +# To build locally; cd docs; make html +#rst2man README | gzip > $(DOCS)/status-report.1.gz +#rst2html README $(CSS) > $(DOCS)/index.html +#rst2man $(DOCS)/notes.rst | gzip > $(DOCS)/status-report-notes.1.gz +#rst2html $(DOCS)/notes.rst $(CSS) > $(DOCS)/notes.html + build: mkdir -p $(TMP)/{SOURCES,$(PACKAGE)} cp -a $(FILES) $(TMP)/$(PACKAGE) - rst2man README | gzip > $(DOCS)/status-report.1.gz - rst2html README $(CSS) > $(DOCS)/index.html - rst2man $(DOCS)/notes.rst | gzip > $(DOCS)/status-report-notes.1.gz - rst2html $(DOCS)/notes.rst $(CSS) > $(DOCS)/notes.html + cd docs && make man SPHINXOPTS=-Q && gzip -c _build/man/status-report.1 > $(DOCS)/status-report.1.gz tarball: build cd $(TMP) && tar cfj SOURCES/$(PACKAGE).tar.bz2 $(PACKAGE) diff --git a/README.rst b/README.rst index 0b2827a4..ab50a3ed 100644 --- a/README.rst +++ b/README.rst @@ -17,22 +17,15 @@ .. image:: https://pypip.in/license/status_report/badge.svg :target: https://pypi.python.org/pypi/status_report/ - :alt: License .. image:: https://landscape.io/github/psss/status-report/master/landscape.svg :target: https://landscape.io/github/psss/status-report/master - :alt: Code Health ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Generate status report stats for selected date range ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -:Manual section: 1 -:Manual group: User Commands -:Date: April 2015 - - DESCRIPTION ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Comfortably generate status report stats (e.g. list of committed @@ -53,6 +46,25 @@ Generate stats for the last week:: See status-report --help for complete list of available stats. +INSTALLATION +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Install directly from Fedora/Copr repository or use PIP:: + + # Basic dependencies for buiding/installing pip packages + sudo yum install gcc krb5-devel + sudo yum install python-devel python-pip python-virtualenv + + # Upgrade to the latest pip/setup/virtualenv installer code + sudo pip install -U pip setuptools virtualenv + + # Install into a python virtual environment (OPTIONAL) + virtualenv --no-site-packages ~/virtenv_statusreport + source ~/virtenv_statusreport/bin/activate + + # Install status_report (sudo required if not in a virtualenv) + pip install status_report + + CONFIGURATION ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The config file ~/.status-report is used to store both general @@ -87,41 +99,25 @@ settings and configuration of individual reports:: See also examples link for some more inspiration. -QUICK INSTALL (pip) -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -sudo yum install gcc krb5-devel -virtualenv --no-site-packages ~/virtenv_statusreport -source ~/virtenv_statusreport/bin/activate -pip install -U pip setuptools -pip install status_report DOCKER INSTALL ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Fedora: https://fedoraproject.org/wiki/Getting_started_with_docker -Feodra: https://fedoraproject.org/wiki/Docker +To build and execute in a docker container, run:: -RUN TESTS (pytest) -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -pip install pytest -py.test source/tests + make run_docker -INSTALLATION -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Install directly from Fedora/Copr repository or use PIP:: +See LINKS section below for more docker resources. - # Basic dependencies for buiding/installing pip packages - sudo yum install gcc krb5-devel - sudo yum install python-devel python-pip python-virtualenv - # Upgrade to the latest pip/setup/virtualenv installer code - sudo pip install -U pip setuptools virtualenv - - # Install into a python virtual environment (OPTIONAL) - virtualenv --no-site-packages ~/virtenv_statusreport - source ~/virtenv_statusreport/bin/activate +GIT COMMIT HOOKS +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +If you're planning to make commits to this project, please enable +the following git hooks:: - # Install status_report (sudo required if not in a virtualenv) - pip install status_report + # UPDATE according to the correct absolute git path + PATH = ~/status-report/git-hooks + ln -s $(PATH)/pre-commit.py .git/hooks/pre-commit + ln -s $(PATH)/commit-msg.py .git/hooks/commit-msg TESTS @@ -157,6 +153,10 @@ https://github.com/psss/status-report PIP repo: https://pypi.python.org/pypi/status_report/ +Docker Guides: +https://fedoraproject.org/wiki/Getting_started_with_docker +https://fedoraproject.org/wiki/Docker + AUTHORS ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/Makefile b/docs/Makefile new file mode 100644 index 00000000..504bb5f4 --- /dev/null +++ b/docs/Makefile @@ -0,0 +1,53 @@ +# Makefile for Sphinx documentation +# + +# You can set these variables from the command line. +SPHINXOPTS = +SPHINXBUILD = sphinx-build +PAPER = +BUILDDIR = _build + +# User-friendly check for sphinx-build +ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1) +$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/) +endif + +# Internal variables. +PAPEROPT_a4 = -D latex_paper_size=a4 +PAPEROPT_letter = -D latex_paper_size=letter +ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . +# the i18n builder cannot share the environment and doctrees with the others +I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . + +.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest coverage gettext + +help: + @echo "Please use \`make ' where is one of" + @echo " html to make standalone HTML files" + @echo " latexpdf to make LaTeX files and run them through pdflatex" + @echo " text to make text files" + @echo " man to make manual pages" + +clean: + rm -rf $(BUILDDIR)/* + +html: + $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html + @echo + @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." + +latexpdf: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo "Running LaTeX files through pdflatex..." + $(MAKE) -C $(BUILDDIR)/latex all-pdf + @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." + +text: + $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text + @echo + @echo "Build finished. The text files are in $(BUILDDIR)/text." + +man: + $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man + @echo + @echo "Build finished. The manual pages are in $(BUILDDIR)/man." diff --git a/docs/conf.py b/docs/conf.py new file mode 100644 index 00000000..28e61b69 --- /dev/null +++ b/docs/conf.py @@ -0,0 +1,224 @@ +# -*- coding: utf-8 -*- +# +# status-report documentation build configuration file, created by +# sphinx-quickstart on Mon Apr 27 17:44:03 2015. +# +# This file is execfile()d with the current directory set to its +# containing dir. +# +# Note that not all possible configuration values are present in this +# autogenerated file. +# +# All configuration values have a default; values that are commented out +# serve to show the default. + +import os + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +#sys.path.insert(0, os.path.abspath('.')) + +# -- General configuration ------------------------------------------------ + +# If your documentation needs a minimal Sphinx version, state it here. +#needs_sphinx = '1.0' + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. +extensions = [ + # 'sphinx.ext.autodoc', +] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# The suffix(es) of source filenames. +# You can specify multiple suffix as a list of string: +# source_suffix = ['.rst', '.md'] +source_suffix = '.rst' + +# The encoding of source files. +#source_encoding = 'utf-8-sig' + +# The master toctree document. +master_doc = 'index' +master_man = 'man.1' + +# General information about the project. +project = u'status-report' +copyright = u'2015, Petr Šplíchal' +author = u'Petr Šplíchal' + +# The version info for the project you're documenting, acts as replacement for +# |version| and |release|, also used in various other places throughout the +# built documents. +# +# The short X.Y version. +version = '0.4' +# The full version, including alpha/beta/rc tags. +release = '-1' + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +# +# This is also used if you do content translation via gettext catalogs. +# Usually you set "language" from the command line for these cases. +language = None + +# There are two options for replacing |today|: either, you set today to some +# non-false value, then it is used: +#today = '' +# Else, today_fmt is used as the format for a strftime call. +#today_fmt = '%B %d, %Y' + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +exclude_patterns = ['_build'] + +# The reST default role (used for this markup: `text`) to use for all +# documents. +#default_role = None + +# If true, '()' will be appended to :func: etc. cross-reference text. +#add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +#add_module_names = True + +# If true, sectionauthor and moduleauthor directives will be shown in the +# output. They are ignored by default. +#show_authors = False + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'sphinx' + +# A list of ignored prefixes for module index sorting. +#modindex_common_prefix = [] + +# If true, keep warnings as "system message" paragraphs in the built documents. +#keep_warnings = False + +# If true, `todo` and `todoList` produce output, else they produce nothing. +todo_include_todos = False + + +# -- Options for HTML output ---------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +html_theme = 'alabaster' + +# 1.3.1 sphinx READTHEDOCS build compat +# SEE: +# https://github.com/shabda/pysaml2/commit/d55bfeebe +on_rtd = os.environ.get('READTHEDOCS', None) == 'True' + +if on_rtd: # only import and set the theme if we're building docs locally + html_theme = 'sphinx_rtd_theme' + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +#html_theme_options = {} + +# Add any paths that contain custom themes here, relative to this directory. +#html_theme_path = [] + +# The name for this set of Sphinx documents. If None, it defaults to +# " v documentation". +#html_title = None + +# A shorter title for the navigation bar. Default is the same as html_title. +#html_short_title = None + +# The name of an image file (relative to this directory) to place at the top +# of the sidebar. +#html_logo = None + +# The name of an image file (within the static path) to use as favicon of the +# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 +# pixels large. +#html_favicon = None + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ['_static'] + +# Add any extra paths that contain custom files (such as robots.txt or +# .htaccess) here, relative to this directory. These files are copied +# directly to the root of the documentation. +#html_extra_path = [] + +# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, +# using the given strftime format. +#html_last_updated_fmt = '%b %d, %Y' + +# If true, SmartyPants will be used to convert quotes and dashes to +# typographically correct entities. +#html_use_smartypants = True + +# Custom sidebar templates, maps document names to template names. +#html_sidebars = {} + +# Additional templates that should be rendered to pages, maps page names to +# template names. +#html_additional_pages = {} + +# If false, no module index is generated. +#html_domain_indices = True + +# If false, no index is generated. +#html_use_index = True + +# If true, the index is split into individual pages for each letter. +#html_split_index = False + +# If true, links to the reST sources are added to the pages. +#html_show_sourcelink = True + +# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. +#html_show_sphinx = True + +# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. +#html_show_copyright = True + +# If true, an OpenSearch description file will be output, and all pages will +# contain a tag referring to it. The value of this option must be the +# base URL from which the finished HTML is served. +#html_use_opensearch = '' + +# This is the file name suffix for HTML files (e.g. ".xhtml"). +#html_file_suffix = None + +# Language to be used for generating the HTML full-text search index. +# Sphinx supports the following languages: +# 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja' +# 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr' +#html_search_language = 'en' + +# A dictionary with options for the search language support, empty by default. +# Now only 'ja' uses this config value +#html_search_options = {'type': 'default'} + +# The name of a javascript file (relative to the configuration directory) that +# implements a search results scorer. If empty, the default will be used. +#html_search_scorer = 'scorer.js' + +# Output file base name for HTML help builder. +htmlhelp_basename = 'status-reportdoc' + +# -- Options for manual page output --------------------------------------- + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [ + (master_man, 'status-report', u'status-report Documentation', + [author], 1) +] + +# If true, show URL addresses after external links. +#man_show_urls = False diff --git a/docs/index.rst b/docs/index.rst new file mode 100644 index 00000000..2aa604a4 --- /dev/null +++ b/docs/index.rst @@ -0,0 +1,24 @@ +.. status-report documentation master file, created by + sphinx-quickstart on Mon Apr 27 17:44:03 2015. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +Welcome to status-report's documentation! +========================================= + +Contents: + +.. toctree:: + :maxdepth: 2 + + overview + release-notes + + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` + diff --git a/docs/man.1.rst b/docs/man.1.rst new file mode 100644 index 00000000..25c6645b --- /dev/null +++ b/docs/man.1.rst @@ -0,0 +1,149 @@ + +====================== + status-report +====================== + +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + Generate status report stats for selected date range +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +:Manual section: 1 +:Manual group: User Commands +:Date: April 2015 + + +DESCRIPTION +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Comfortably generate status report stats (e.g. list of committed +changes) for given week, month, quarter, year or selected date +range. By default all available stats for this week are reported. + + +EXAMPLES +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Generate all stats for current week:: + + status-report + +Generate stats for the last week:: + + status-report last week + +See status-report --help for complete list of available stats. + + +INSTALLATION +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Install directly from Fedora/Copr repository or use PIP:: + + # Basic dependencies for buiding/installing pip packages + sudo yum install python-devel python-pip python-virtualenv + sudo yum install gcc krb5-devel + + # Upgrade to the latest pip/setup/virtualenv installer code + sudo pip install -U pip setuptools virtualenv + + # Install into a python virtual environment (OPTIONAL) + virtualenv --no-site-packages ~/virtenv_statusreport + source ~/virtenv_statusreport/bin/activate + + # Install status_report (sudo required if not in a virtualenv) + pip install status_report + + +CONFIGURATION +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The config file ~/.status-report is used to store both general +settings and configuration of individual reports:: + + [general] + email = "Petr Šplíchal" + width = 79 + + [header] + type = header + highlights = Highlights + joy = Joy of the week ;-) + + [footer] + type = footer + next = Plans, thoughts, ideas... + status = Status: Green | Yellow | Orange | Red + + [tools] + type = git + apps = /home/psss/git/apps + + [tests] + type = git + tests = /home/psss/git/tests/* + + [trac] + type = trac + prefix = TT + url = https://some.trac.com/trac/project/rpc + +See also examples link for some more inspiration. + + +DOCKER INSTALL +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +To build and execute in a docker container, run:: + + make run_docker + +See LINKS section below for more docker resources. + + +TESTS +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +To run tests using pytest:: + + # sudo required if not in a virtualenv + pip install pytest coveralls + coverage run --source=status_report -m py.test source/tests + coverage report + + +LINKS +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Project page: +http://psss.fedorapeople.org/status-report/ + +Release notes: +http://psss.fedorapeople.org/status-report/notes.html + +Examples: +http://psss.fedorapeople.org/status-report/examples/ + +Download: +http://psss.fedorapeople.org/status-report/download/ + +Copr repo: +http://copr.fedoraproject.org/coprs/psss/status-report/ + +Git repo: +https://github.com/psss/status-report + +PIP repo: +https://pypi.python.org/pypi/status_report/ + +Docker Guides: +https://fedoraproject.org/wiki/Getting_started_with_docker +https://fedoraproject.org/wiki/Docker + + +AUTHORS +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Petr Šplíchal, Karel Šrot, Lukáš Zachar, Matěj Cepl, Ondřej Pták, +Chris Ward. + + +COPYRIGHT +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Copyright (c) 2015 Red Hat, Inc. All rights reserved. + +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. diff --git a/docs/notes.rst b/docs/notes.rst deleted file mode 100644 index bdc92595..00000000 --- a/docs/notes.rst +++ /dev/null @@ -1,16 +0,0 @@ - -====================== - Release Notes -====================== - -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - status-report release notes -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -:Manual section: 1 -:Manual group: User Commands -:Date: April 2015 - -status-report 0.1 -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -The first status-report release ever. diff --git a/docs/overview.rst b/docs/overview.rst new file mode 120000 index 00000000..89a01069 --- /dev/null +++ b/docs/overview.rst @@ -0,0 +1 @@ +../README.rst \ No newline at end of file diff --git a/docs/release-notes.rst b/docs/release-notes.rst new file mode 100644 index 00000000..347ab67b --- /dev/null +++ b/docs/release-notes.rst @@ -0,0 +1,40 @@ + +====================== + Release Notes +====================== + +:Manual section: 1 +:Manual group: User Commands +:Date: April 2015 + +status-report 0.4-1 +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +* Sun Apr 26 2015 Chris Ward 0.4-1 +- Snippet saving and reporting functionality added +- Refactor of Stat classes; don't fetch during __init__() +- Docker builds enabled [langdon@redhat.com] +- More tests! + +status-report 0.3-1 +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +* Thu Apr 23 2015 Petr Šplíchal 0.3-1 +- Update README with PIP and test information +- Enable travis-ci and some tests +- A couple of adjustments after the nitrate cleanup +- Remove nitrate dependency, adjust user handling + +status-report 0.2-1 +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +* Wed Apr 22 2015 Petr Šplíchal 0.2-1 +- Incorporated package review feedback [BZ#1213739] +- Include essential gitignore patterns +- Handle custom stats as a plugin as well +- Handle header & footer as other plugins +- Plugin detection finalized including sort order +- Style cleanup and adjustments for plugin detection +- The first version of the plugin detection support + +status-report 0.1-1 +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +* Mon Apr 20 2015 Petr Šplíchal 0.1-0 +- Initial packaging. diff --git a/git-hooks/commit-msg.py b/git-hooks/commit-msg.py new file mode 100755 index 00000000..76e76cd7 --- /dev/null +++ b/git-hooks/commit-msg.py @@ -0,0 +1,71 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# status-report - Generate status report stats +# Author: Petr Šplíchal +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2012 Red Hat, Inc. All rights reserved. +# +# This copyrighted material is made available to anyone wishing +# to use, modify, copy, or redistribute it subject to the terms +# and conditions of the GNU General Public License version 2. +# +# 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. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +""" +Git commit-msg hook for stats-report. + +FROM: http://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks +The commit-msg hook takes one parameter, which again is the path to +a temporary file that contains the commit message written by the +developer. If this script exits non-zero, Git aborts the commit +process, so you can use it to validate your project state or commit +message before allowing a commit to go through. +""" + +from status_report.utils import log, LOG_DEBUG + +# Turn on DEBUG so we can get a full log on each commit +log.setLevel(LOG_DEBUG) + +import sys + + +def main(): + py, msg_pth = sys.argv + msg_summary = open(msg_pth).readlines()[0] + k = len(msg_summary) + x = k - 50 - 1 + if len(msg_summary) > 50: + log.error("Commit Message Check: FAIL") + log.error("Your commit message:") + log.error("\n{0}{1}{2}".format(msg_summary, '^' * 50, 'X' * x)) + log.error(""" +<<<<| Commit msg summary must be <= 50 chars >>>>| +-------------------------------------------------- +This is my commit message summary; Max length >>>| + +After a line break (\\n) , the full description of +the commit can be included though. No Problem.""") + sys.exit(1) + else: + log.warn("Commit Message Check: PASS") + +if __name__ == '__main__': + main() + sys.exit(0) + +sys.exit(1) diff --git a/git-hooks/pre-commit.py b/git-hooks/pre-commit.py new file mode 100755 index 00000000..28c3533c --- /dev/null +++ b/git-hooks/pre-commit.py @@ -0,0 +1,120 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# status-report - Generate status report stats +# Author: Petr Šplíchal +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2012 Red Hat, Inc. All rights reserved. +# +# This copyrighted material is made available to anyone wishing +# to use, modify, copy, or redistribute it subject to the terms +# and conditions of the GNU General Public License version 2. +# +# 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. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +""" +Git pre-commit hooks for stats-report. +""" + +import argparse +import sys +import subprocess +from status_report.utils import log, LOG_DEBUG + +# Turn on DEBUG so we can get a full log on each commit +log.setLevel(LOG_DEBUG) + + +def run(cmd): + cmd = cmd if isinstance(cmd, list) else cmd.split() + try: + process = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + except Exception as error: + log.error("'{0}' failed: {1}".format(cmd, error)) + raise + output, errors = process.communicate() + if process.returncode != 0 or errors: + if output: + log.error(output) + if errors: + log.error(errors) + sys.exit(process.returncode) + return output, errors + + +def run_tests(): + ''' + Run all the available tests. + ''' + # Try to run make build + cmd = "py.test source/tests" + return run(cmd) + + +def make_rpm(): + ''' + Make sure we haven't broken the rpm source builds + ''' + # Try to run make build + cmd = 'make build' + return run(cmd) + + +def main(): + """ Main function handling configuration files etc """ + parser = argparse.ArgumentParser( + description='Git python commit hooks') + parser.add_argument( + '--make-rpm', action='store_const', const=True, default=True, + help='Build RPMs from source') + parser.add_argument( + '--run-tests', action='store_const', const=True, default=True, + help='Run all available tests') + parser.add_argument( + '--stash-first', action='store_const', const=True, default=False, + help='Run all available tests') + args = parser.parse_args() + + # make sure we're working with only the staged content! + if args.stash_first: + run('git stash -q --keep-index') + + try: + results = [] + if args.make_rpm: + log.debug('RPM Build: START') + results.append({'make_rpm': make_rpm()}) + log.warn('RPM Build: PASS') + if args.run_tests: + log.debug('TESTS RUN: START') + results.append({'run_tests': run_tests()}) + log.warn('TESTS RUN: PASS') + finally: + # make sure we return things back to how they started + if args.stash_first: + run('git stash pop -q') + + if all(results): + sys.exit(0) + else: + sys.exit(1) + +if __name__ == '__main__': + main() + sys.exit(0) + +sys.exit(1) diff --git a/source/setup.py b/setup.py similarity index 84% rename from source/setup.py rename to setup.py index 089377ec..77e436f8 100755 --- a/source/setup.py +++ b/setup.py @@ -2,19 +2,12 @@ # -*- coding: utf-8 -*- # Author: "Chris Ward" -import os import re from setuptools import setup -script_pth = os.path.dirname(os.path.realpath(__file__)) -# make sure we're working from the root where (this) setup.py is -os.chdir(script_pth) -# get the parents directory path to find spec and README -parent_pth = os.path.realpath('../') - # Parse the version and release from master spec file # RPM spec file is in the parent directory -spec_pth = os.path.join(parent_pth, 'status-report.spec') +spec_pth = 'status-report.spec' with open(spec_pth) as f: lines = "\n".join(l.rstrip() for l in f) version = re.search('Version: (.+)', lines).group(1).rstrip() @@ -23,7 +16,7 @@ # acceptable version schema: major.minor[.patch][sub] __version__ = '.'.join([version, release]) __pkg__ = 'status_report' -__pkgdir__ = {'status_report': 'status_report'} +__pkgdir__ = {'status_report': 'source/status_report'} __pkgs__ = [ 'status_report', 'status_report.plugins', @@ -41,7 +34,7 @@ __deplinks__ = [] # README is in the parent directory -readme_pth = os.path.join(parent_pth, 'README.rst') +readme_pth = 'README.rst' with open(readme_pth) as _file: readme = _file.read() diff --git a/status-report.spec b/status-report.spec index 99a1d773..52345817 100644 --- a/status-report.spec +++ b/status-report.spec @@ -30,13 +30,13 @@ mkdir -p %{buildroot}%{python_sitelib}/status_report/plugins install -pm 755 source/status-report %{buildroot}%{_bindir} install -pm 644 source/status_report/*.py %{buildroot}%{python_sitelib}/status_report install -pm 644 source/status_report/plugins/*.py %{buildroot}%{python_sitelib}/status_report/plugins -install -pm 644 docs/*.1.gz %{buildroot}%{_mandir}/man1 +install -pm 644 docs/_build/man/*.1.gz %{buildroot}%{_mandir}/man1 %files %{_mandir}/man1/* %{_bindir}/status-report %{python_sitelib}/* -%doc README examples +%doc README.rst examples %{!?_licensedir:%global license %%doc} %license LICENSE