From 28f36f34d625676cb52782d33c0164ed0161ee4b Mon Sep 17 00:00:00 2001 From: Blaine Chatman Date: Tue, 11 Mar 2014 10:52:04 -0700 Subject: [PATCH 1/2] added --allow-dirty option --- bumpversion/__init__.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/bumpversion/__init__.py b/bumpversion/__init__.py index e8bc309..81acecd 100644 --- a/bumpversion/__init__.py +++ b/bumpversion/__init__.py @@ -568,6 +568,9 @@ def main(original_args=None): parser3.add_argument('--new-version', metavar='VERSION', help='New version that should be in the files', required=not 'new_version' in defaults) + parser3.add_argument('--allow-dirty', action='store_true', default=False, + help='Do not check that version control is non-dirty') + commitgroup = parser3.add_mutually_exclusive_group() @@ -614,7 +617,10 @@ def main(original_args=None): for vcs in VCS: if vcs.is_usable(): - vcs.assert_nondirty() + if args.allow_dirty: + pass + else: + vcs.assert_nondirty() break else: vcs = None From a5231186ac63aa41b1cc9cedae6470ae09ee9937 Mon Sep 17 00:00:00 2001 From: Blaine Chatman Date: Mon, 31 Mar 2014 12:16:23 -0700 Subject: [PATCH 2/2] updated tests to new help string --- tests.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/tests.py b/tests.py index 6e8451a..21cd43c 100644 --- a/tests.py +++ b/tests.py @@ -46,7 +46,7 @@ def _mock_calls_to_string(called_mock): EXPECTED_USAGE = (""" usage: py.test [-h] [--config-file FILE] [--verbose] [--list] [--parse REGEX] [--serialize FORMAT] [--current-version VERSION] [--dry-run] - --new-version VERSION [--commit | --no-commit] + --new-version VERSION [--allow-dirty] [--commit | --no-commit] [--tag | --no-tag] [--tag-name TAG_NAME] [--message COMMIT_MSG] part [file [file ...]] @@ -72,6 +72,8 @@ def _mock_calls_to_string(called_mock): --new-version VERSION New version that should be in the files (default: None) + --allow-dirty Do not check that version control is non-dirty + (default: False) --commit Commit to version control (default: False) --no-commit Do not commit to version control --tag Create a tag in version control (default: False) @@ -83,6 +85,18 @@ def _mock_calls_to_string(called_mock): {current_version} → {new_version}) """ % DESCRIPTION).lstrip() +def _unidiff_output(expected, actual): + """ + Helper function. Returns a string containing the unified diff of two multiline strings. + """ + + import difflib + expected=expected.splitlines(1) + actual=actual.splitlines(1) + + diff=difflib.unified_diff(expected, actual) + + return ''.join(diff) def test_usage_string(tmpdir, capsys): tmpdir.chdir() @@ -91,6 +105,9 @@ def test_usage_string(tmpdir, capsys): main(['--help']) out, err = capsys.readouterr() + import pdb; pdb.set_trace() + + s = _unidiff_output(out, EXPECTED_USAGE) assert err == "" assert out == EXPECTED_USAGE, "Usage string changed to \n\n\n{}\n\n\n".format(out)