forked from peritus/bumpversion
-
Notifications
You must be signed in to change notification settings - Fork 0
Allow setting tag message with $EDITOR. #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
ryneeverett
wants to merge
2
commits into
ekohl:annotated-tags
from
ryneeverett:annotated-tags-editor
Closed
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -152,7 +152,9 @@ def tag(cls, name, message): | |
| command = ["git", "tag", name] | ||
| if message: | ||
| command += ['--message', message] | ||
| subprocess.check_output(command) | ||
| elif message is None: | ||
| command += ['--annotate'] | ||
| subprocess.call(command) | ||
|
|
||
|
|
||
| class Mercurial(BaseVCS): | ||
|
|
@@ -187,7 +189,9 @@ def tag(cls, name, message): | |
| command = ["hg", "tag", name] | ||
| if message: | ||
| command += ['--message', message] | ||
| subprocess.check_output(command) | ||
| elif message is None: | ||
| command += ['--edit'] | ||
| subprocess.call(command) | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be check_call as well. |
||
|
|
||
| VCS = [Git, Mercurial] | ||
|
|
||
|
|
@@ -786,7 +790,7 @@ def main(original_args=None): | |
| help='Tag name (only works with --tag)', | ||
| default=defaults.get('tag_name', 'v{new_version}')) | ||
|
|
||
| parser3.add_argument('--tag-message', metavar='TAG_MESSAGE', dest='tag_message', | ||
| parser3.add_argument('--tag-message', metavar='TAG_MESSAGE', dest='tag_message', nargs='?', | ||
| help='Tag message', default=defaults.get('tag_message', 'Bump version: {current_version} → {new_version}')) | ||
|
|
||
| parser3.add_argument('--message', '-m', metavar='COMMIT_MSG', | ||
|
|
@@ -804,11 +808,11 @@ def main(original_args=None): | |
| nargs='*', | ||
| help='Files to change', default=file_names) | ||
|
|
||
| args = parser3.parse_args(remaining_argv + positionals) | ||
| args = parser3.parse_args(positionals + remaining_argv) | ||
|
|
||
| if args.dry_run: | ||
| logger.info("Dry run active, won't touch any files.") | ||
|
|
||
| if args.new_version: | ||
| new_version = vc.parse(args.new_version) | ||
|
|
||
|
|
@@ -922,11 +926,13 @@ def main(original_args=None): | |
| vcs.commit(message=commit_message) | ||
|
|
||
| tag_name = args.tag_name.format(**vcs_context) | ||
| tag_message = args.tag_message.format(**vcs_context) | ||
| tag_message = (args.tag_message.format(**vcs_context) | ||
| if args.tag_message is not None else None) | ||
| logger.info("{} '{}' {} in {}".format( | ||
| "Would tag" if not do_tag else "Tagging", | ||
| tag_name, | ||
| "with message '{}'".format(tag_message) if tag_message else "without message", | ||
| ("with message from editor" if tag_message is None else | ||
| "with message '{}'".format(tag_message)), | ||
| vcs.__name__ | ||
| )) | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -79,7 +79,6 @@ def _mock_calls_to_string(called_mock): | |
| [--commit | --no-commit] | ||
| [--tag | --no-tag] | ||
| [--tag-name TAG_NAME] | ||
| [--tag-message TAG_MESSAGE] | ||
| [--message COMMIT_MSG] | ||
| part | ||
| [file [file ...]] | ||
|
|
@@ -121,7 +120,7 @@ def _mock_calls_to_string(called_mock): | |
| --no-tag Do not create a tag in version control | ||
| --tag-name TAG_NAME Tag name (only works with --tag) (default: | ||
| v{new_version}) | ||
| --tag-message TAG_MESSAGE | ||
| --tag-message [TAG_MESSAGE] | ||
| Tag message (default: Bump version: {current_version} | ||
| → {new_version}) | ||
| --message COMMIT_MSG, -m COMMIT_MSG | ||
|
|
@@ -788,6 +787,21 @@ def test_annotated_tag(tmpdir, vcs): | |
| raise ValueError("Unknown VCS") | ||
|
|
||
|
|
||
| @pytest.mark.parametrize(("vcs"), [xfail_if_no_git("git"), xfail_if_no_hg("hg")]) | ||
| def test_annotated_editor_tag(tmpdir, vcs): | ||
| tmpdir.chdir() | ||
| check_call([vcs, "init"]) | ||
| tmpdir.join("VERSION").write("42.5.1") | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be 42.4.1 for the tests to pass. |
||
| check_call([vcs, "add", "VERSION"]) | ||
| check_call([vcs, "commit", "-m", "initial commit"]) | ||
|
|
||
| with mock.patch("bumpversion.logger") as logger: | ||
| main(['patch', '--current-version', '42.4.1', '--commit', '--tag', 'VERSION', '--dry-run', '--tag-message']) | ||
|
|
||
| actual_log ="\n".join(_mock_calls_to_string(logger)[4:]) | ||
| assert "Would tag 'v42.4.2' with message from editor" in actual_log | ||
|
|
||
|
|
||
| @pytest.mark.parametrize(("vcs"), [xfail_if_no_git("git")]) | ||
| def test_vcs_describe(tmpdir, vcs): | ||
| tmpdir.chdir() | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't check the exit status like check_output did. There is check_call. Since the project is marked Python 2.7+ I don't think that'll be a problem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Turns out I was confused with check_output (which is 2.7+), check_call exists since 2.5 so even less of a problem.