Skip to content
This repository was archived by the owner on Jan 28, 2022. It is now read-only.

Commit 65b81ee

Browse files
committed
Fix branches regex and bump_version tool
1 parent 345236a commit 65b81ee

File tree

3 files changed

+48
-13
lines changed

3 files changed

+48
-13
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ cache: pip
33
branches:
44
only:
55
- master
6-
- /^v\d+\.\d+(\.\d+)?$/
6+
- /^\d+\.\d+(\.\d+)?$/
77

88
python:
99
- "3.6"

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
import setuptools
44

5-
setuptools.setup(setup_requires=['pbr>=5.0.0'], pbr=True)
5+
setuptools.setup(setup_requires=['pbr>=5.2.1'], pbr=True)

tools/bump_version

Lines changed: 46 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/usr/bin/env python3
22

3+
import contextlib
34
import subprocess
45

56

@@ -13,10 +14,30 @@ def exec_cmd(cmd, input=None):
1314
return str(stdout, 'utf-8')
1415

1516

17+
@contextlib.contextmanager
18+
def disable_show_signature():
19+
local_flag = exec_cmd(
20+
["git", "config", "--local", "--get", "log.showSignature"]
21+
).strip()
22+
exec_cmd(
23+
["git", "config", "--local", "log.showSignature",
24+
"false"]
25+
)
26+
yield
27+
if local_flag:
28+
exec_cmd(
29+
["git", "config", "--local", "log.showSignature", local_flag]
30+
)
31+
else:
32+
exec_cmd(
33+
["git", "config", "--local", "--unset", "log.showSignature"]
34+
)
35+
36+
1637
def get_diff(tag):
17-
return exec_cmd([
38+
return [l for l in exec_cmd([
1839
"git", "log", "--pretty=%h %s", "--no-merges", "{}..HEAD".format(tag)
19-
]).splitlines()
40+
]).splitlines() if not l.startswith("gpg")]
2041

2142

2243
def get_last_tag():
@@ -61,36 +82,44 @@ def show(tag):
6182
return exec_cmd(["git", "show", tag])
6283

6384

64-
def create_tag(tag, annotation):
65-
exec_cmd(["git", "tag", "-s", "-F-", tag], input=annotation)
85+
def create_tag(tag, annotation, sign):
86+
cmd = ["git", "tag"]
87+
if sign:
88+
cmd.append("--sign")
89+
exec_cmd(cmd + ["-F-", tag], input=annotation)
6690

6791

6892
def delete_tag(tag):
6993
exec_cmd(["git", "tag", "-d", tag])
7094

7195

7296
def sdist(tag):
73-
create_tag(tag, 'sdist')
97+
create_tag(tag, 'sdist', False)
7498
exec_cmd(["python", "setup.py", "sdist"])
7599
delete_tag(tag)
76100

77101

78-
def bump(tag, annotation):
102+
def bump(tag, annotation, sign):
79103
sdist(tag)
80104
exec_cmd(["git", "add", "AUTHORS", "ChangeLog"])
81-
exec_cmd(["git", "commit", "-m", "Bump version %s" % tag])
105+
cmd = ["git", "commit"]
106+
if sign:
107+
cmd.append("--sign")
108+
exec_cmd(cmd + ["-m", "Bump version %s" % tag])
82109
sdist(tag)
83110
exec_cmd(["git", "add", "ChangeLog"])
84-
exec_cmd(["git", "commit", "--amend", "--no-edit"])
85-
create_tag(tag, annotation)
111+
exec_cmd(cmd + ["--amend", "--no-edit"])
112+
create_tag(tag, annotation, sign)
86113

87114

88115
def main(args):
89-
tag, annotation = get_info(args.version)
116+
with disable_show_signature():
117+
tag, annotation = get_info(args.version)
90118
if args.dry_run:
91119
print(annotation)
92120
else:
93-
bump(tag, annotation)
121+
with disable_show_signature():
122+
bump(tag, annotation, args.sign)
94123
print(show(tag))
95124

96125
a = input('Push new tag? [y/N]: ')
@@ -108,6 +137,12 @@ if __name__ == '__main__':
108137
help="specify version, otherwise the current version "
109138
"will be incremented by 1")
110139
parser.add_argument(
140+
'-s',
141+
'--sign',
142+
action='store_true',
143+
help="sign a tag and commits")
144+
parser.add_argument(
145+
'-r',
111146
'--dry-run',
112147
action='store_true',
113148
help="print tag's number and annotation")

0 commit comments

Comments
 (0)