diff --git a/.gitignore b/.gitignore index e809549..d657fc6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,7 @@ +*.egg-info/ *.pyc *.pyo +.tox/ /*.html +build/ +dist/ diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..96e6c17 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,7 @@ +include completions/git-imerge +include COPYING +include t/create-test-repo +include t/test-conflicted +include t/test-drop +include t/test-unconflicted +include tox.ini diff --git a/Makefile b/Makefile index 672f69d..7eb4995 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,3 @@ - -BIN=git-imerge -PREFIX=/usr/local - RST := \ README.rst \ TODO.rst @@ -20,13 +16,3 @@ html: $(module)/talk.html $(module)/talk.html: $(module)/talk.rst rst2s5 --theme=small-white --current-slide $< $@ - -install: $(BIN) - @mkdir -p $(DESTDIR)$(PREFIX)/bin - install $(BIN) $(DESTDIR)$(PREFIX)/bin - @mkdir -p $(DESTDIR)/etc/bash_completion.d - cp -f git-imerge.bashcomplete $(DESTDIR)/etc/bash_completion.d/git-imerge - -uninstall: - rm $(DESTDIR)$(PREFIX)/bin/$(BIN) - rm -f $(DESTDIR)/etc/bash_completion.d/git-imerge diff --git a/README.rst b/README.rst index 93857ec..ec3d219 100644 --- a/README.rst +++ b/README.rst @@ -48,9 +48,8 @@ command. An incremental merge can be interrupted and resumed arbitrarily, or even pushed to a server to allow somebody else to work on it. -``git-imerge`` comes with a Bash completion script. It can be installed -by copying ``git-imerge.bashcomplete`` to the place where usually completion -scripts are installed on your system, e.g. /etc/bash_completion.d/. +``git-imerge`` comes with a Bash completion script, ``completions/git-imerge``, +that is installed automatically when installing ``git-imerge``. Requirements @@ -66,16 +65,24 @@ Requirements * Python 3.x, version 3.3 or later. - The script tries to use a Python interpreter called ``python`` in - your ``PATH``. If your Python interpreter has a different name or - is not in your ``PATH``, please adjust the first line of the script - accordingly. - * A recent version of Git. Bash completion requires Git's completion being available. +Installation +============ + +``git-imerge`` is available on PyPI_, so you can install it with ``pip``:: + + $ pip install git-imerge + + +or using ``setup.py`` if you have downloaded the source package locally:: + + $ python setup.py install + + Instructions ============ @@ -399,6 +406,22 @@ line or change the default in your configuration:: git config --global imerge.editmergemessages true +Testing +======= + +``git-imerge`` uses tox_ to run tests. To run the test suite with the system's +default Python:: + + $ tox + +To run with a specific Python version, such as 3.7, pass the ``-e`` argument to +tox:: + + $ tox -e py37 + +.. _tox: https://tox.readthedocs.io/ + + License ======= @@ -423,5 +446,3 @@ References * http://softwareswirl.blogspot.com/2009/04/truce-in-merge-vs-rebase-war.html * http://softwareswirl.blogspot.com/2009/08/upstream-rebase-just-works-if-history.html * http://softwareswirl.blogspot.com/2009/08/rebase-with-history-implementation.html - - diff --git a/git-imerge.bashcomplete b/completions/git-imerge similarity index 100% rename from git-imerge.bashcomplete rename to completions/git-imerge diff --git a/git-imerge b/gitimerge.py old mode 100755 new mode 100644 similarity index 99% rename from git-imerge rename to gitimerge.py index 743fa24..fe99c30 --- a/git-imerge +++ b/gitimerge.py @@ -1,4 +1,3 @@ -#! /usr/bin/env python # -*- coding: utf-8 -*- # Copyright 2012-2013 Michael Haggerty @@ -4137,11 +4136,15 @@ def main(args): parser.error('Unrecognized subcommand') -if __name__ == '__main__': +def climain(): try: main(sys.argv[1:]) except Failure as e: sys.exit(str(e)) +if __name__ == "__main__": + climain() + + # vim: set expandtab ft=python: diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..4b346a5 --- /dev/null +++ b/setup.py @@ -0,0 +1,44 @@ +import errno +import subprocess + +from setuptools import setup + +data_files = [] +try: + completionsdir = subprocess.check_output( + ["pkg-config", "--variable=completionsdir", "bash-completion"] + ) +except OSError as e: + if e.errno != errno.ENOENT: + raise +else: + completionsdir = completionsdir.strip().decode('utf-8') + if completionsdir: + data_files.append((completionsdir, ["completions/git-imerge"])) + + +setup( + name="gitimerge", + description="Incremental merge for git", + url="https://github.com/mhagger/git-imerge", + author="Michael Haggerty", + author_email="mhagger@alum.mit.edu", + license="GPLv2+", + version="1.1.0", + py_modules=["gitimerge"], + data_files=data_files, + entry_points={"console_scripts": ["git-imerge = gitimerge:climain"]}, + python_requires=">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*", + classifiers=[ + "Development Status :: 5 - Production/Stable", + "License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)", + "Programming Language :: Python", + "Programming Language :: Python :: 2", + "Programming Language :: Python :: 2.7", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.4", + "Programming Language :: Python :: 3.5", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", + ], +) diff --git a/t/reset-test-repo b/t/reset-test-repo index f0a938c..fb9adc3 100755 --- a/t/reset-test-repo +++ b/t/reset-test-repo @@ -2,7 +2,7 @@ BASE="$(dirname "$(cd $(dirname "$0") && pwd)")" TMP="$BASE/t/tmp/main" -GIT_IMERGE="$BASE/git-imerge" +GIT_IMERGE="git-imerge" cd "$TMP" diff --git a/t/test-conflicted b/t/test-conflicted index 16d1f4d..4927e10 100755 --- a/t/test-conflicted +++ b/t/test-conflicted @@ -7,7 +7,7 @@ set -x BASE="$(dirname "$(cd $(dirname "$0") && pwd)")" TMP="$BASE/t/tmp/main" -GIT_IMERGE="$BASE/git-imerge" +GIT_IMERGE="git-imerge" cd "$TMP" diff --git a/t/test-drop b/t/test-drop index cef07b3..bc9caa7 100755 --- a/t/test-drop +++ b/t/test-drop @@ -15,7 +15,7 @@ modify() { BASE="$(dirname "$(cd $(dirname "$0") && pwd)")" TMP="$BASE/t/tmp/drop" -GIT_IMERGE="$BASE/git-imerge" +GIT_IMERGE="git-imerge" rm -rf "$TMP" mkdir -p "$TMP" diff --git a/t/test-unconflicted b/t/test-unconflicted index e89ed5a..23b4bd3 100755 --- a/t/test-unconflicted +++ b/t/test-unconflicted @@ -7,7 +7,7 @@ set -x BASE="$(dirname "$(cd $(dirname "$0") && pwd)")" TMP="$BASE/t/tmp/main" -GIT_IMERGE="$BASE/git-imerge" +GIT_IMERGE="git-imerge" cd "$TMP" diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..b1a54cb --- /dev/null +++ b/tox.ini @@ -0,0 +1,9 @@ +[tox] +envlist = py + +[testenv] +commands = + /bin/sh t/create-test-repo + /bin/sh t/test-unconflicted + /bin/sh t/test-conflicted + /bin/sh t/test-drop