Skip to content
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

Create annotated, signed tags #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .bumpversion.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ current_version = 0.1.1
files = setup.py
commit = True
tag = True
tag_options = -m "bumpversion v{new_version}"

9 changes: 7 additions & 2 deletions bumpversion/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import os
import warnings
import re
import shlex
import sre_constants
import subprocess
from string import Formatter
Expand Down Expand Up @@ -121,6 +122,8 @@ def main(args=None):
parser3.add_argument('--message', '-m', metavar='COMMIT_MSG',
help='Commit message',
default='Bump version: {current_version} → {new_version}')
parser3.add_argument('--tag-options', metavar='TAG_OPTIONS',
dest='tag_options', help='Extra tag options for the tag command, e.g. --sign')

files = []
if 'files' in defaults:
Expand Down Expand Up @@ -185,5 +188,7 @@ def main(args=None):
subprocess.check_call(
["git", "commit", "-m", args.message.format(**formatargs)])
if args.tag:
subprocess.check_call(
["git", "tag", "v{new_version}".format(**formatargs)])
tag_args = ["git", "tag", "v{new_version}".format(**formatargs)]
if args.tag_options:
tag_args.extend(shlex.split(args.tag_options.format(**formatargs)))
subprocess.check_call(tag_args)
19 changes: 19 additions & 0 deletions tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def test_usage_string(tmpdir, capsys):
usage: py.test [-h] [--config-file FILE] [--bump PART] [--parse REGEX]
[--serialize FORMAT] [--current-version VERSION] [--dry-run]
--new-version VERSION [--commit] [--tag] [--message COMMIT_MSG]
[--tag-options TAG_OPTIONS]
file [file ...]

Bumps version strings
Expand Down Expand Up @@ -50,6 +51,9 @@ def test_usage_string(tmpdir, capsys):
--message COMMIT_MSG, -m COMMIT_MSG
Commit message (default: Bump version:
{current_version} → {new_version})
--tag-options TAG_OPTIONS
Extra tag options for the tag command, e.g. --sign
(default: None)
""".lstrip()


Expand Down Expand Up @@ -220,6 +224,21 @@ def test_git_commit(tmpdir):

assert 'v47.1.3' in tag_out

describe_out = subprocess.call(["git", "describe"])
assert 128 == describe_out

main(['--current-version', '47.1.3', '--commit', '--tag', '--tag-options', '"-m \\"test v{new_version}-tag\\""', 'VERSION'])

assert '47.1.4' == tmpdir.join("VERSION").read()

tag_out = subprocess.check_output(["git", "tag"])

assert 'v47.1.4' in tag_out

describe_out = subprocess.check_output(["git", "describe"])

assert 'v47.1.4' in describe_out


def test_bump_version_ENV(tmpdir):

Expand Down