Skip to content

Commit efe4f69

Browse files
committed
Normalize strings
1 parent 6c49609 commit efe4f69

File tree

3 files changed

+144
-144
lines changed

3 files changed

+144
-144
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ repos:
1313
hooks:
1414
- id: black
1515
name: black
16-
entry: black --skip-string-normalization
16+
entry: black
1717
- repo: local
1818
hooks:
1919
- id: composer-validate

scripts/make_release.py

Lines changed: 81 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@
1111

1212

1313
# The owner and repository name. For example, octocat/Hello-World.
14-
GITHUB_REPOSITORY = os.getenv('GITHUB_REPOSITORY')
14+
GITHUB_REPOSITORY = os.getenv("GITHUB_REPOSITORY")
1515

16-
GITHUB_TOKEN = os.getenv('GITHUB_TOKEN')
17-
GITHUB_REF_NAME = os.getenv('GITHUB_REF_NAME')
16+
GITHUB_TOKEN = os.getenv("GITHUB_TOKEN")
17+
GITHUB_REF_NAME = os.getenv("GITHUB_REF_NAME")
1818

1919
CURRENT_FILE = Path(__file__)
2020
ROOT = CURRENT_FILE.parents[1]
21-
CHANGELOG_PATH = ROOT / 'CHANGELOG.md'
22-
LIBRARY_FILE_PATH = ROOT / 'src/Curl/Curl.php'
21+
CHANGELOG_PATH = ROOT / "CHANGELOG.md"
22+
LIBRARY_FILE_PATH = ROOT / "src/Curl/Curl.php"
2323

2424
# TODO: Adjust number of recent pull requests to include likely number of
2525
# pull requests since the last release.
@@ -35,32 +35,32 @@ def main():
3535
# git tag --list | sort --reverse --version-sort
3636
tags = sorted(
3737
local_repo.tags,
38-
key=lambda tag: list(map(int, tag.name.split('.'))),
38+
key=lambda tag: list(map(int, tag.name.split("."))),
3939
reverse=True,
4040
)
4141

4242
most_recent_tag = tags[0]
43-
print('most_recent_tag: {}'.format(most_recent_tag))
43+
print("most_recent_tag: {}".format(most_recent_tag))
4444
most_recent_tag_datetime = most_recent_tag.commit.committed_datetime
45-
print('most_recent_tag_datetime: {}'.format(most_recent_tag_datetime))
45+
print("most_recent_tag_datetime: {}".format(most_recent_tag_datetime))
4646

4747
# Find merged pull requests since the most recent tag.
4848
github_repo = Github(login_or_token=GITHUB_TOKEN).get_repo(GITHUB_REPOSITORY)
4949
recent_pulls = github_repo.get_pulls(
50-
state='closed',
51-
sort='updated',
52-
direction='desc',
50+
state="closed",
51+
sort="updated",
52+
direction="desc",
5353
)[:RECENT_PULL_REQUEST_LIMIT]
5454

5555
pull_request_changes = []
5656

5757
# Group pull requests by semantic version change type.
5858
pull_request_by_type = {
59-
'major': [],
60-
'minor': [],
61-
'patch': [],
62-
'cleanup': [],
63-
'unspecified': [],
59+
"major": [],
60+
"minor": [],
61+
"patch": [],
62+
"cleanup": [],
63+
"unspecified": [],
6464
}
6565

6666
# Track if any pull request is missing a semantic version change type.
@@ -85,16 +85,16 @@ def main():
8585
continue
8686

8787
pull_labels = {label.name for label in pull.labels}
88-
if 'major-incompatible-changes' in pull_labels:
89-
group_name = 'major'
90-
elif 'minor-backwards-compatible-added-functionality' in pull_labels:
91-
group_name = 'minor'
92-
elif 'patch-backwards-compatible-bug-fixes' in pull_labels:
93-
group_name = 'patch'
94-
elif 'cleanup-no-release-required' in pull_labels:
95-
group_name = 'cleanup'
88+
if "major-incompatible-changes" in pull_labels:
89+
group_name = "major"
90+
elif "minor-backwards-compatible-added-functionality" in pull_labels:
91+
group_name = "minor"
92+
elif "patch-backwards-compatible-bug-fixes" in pull_labels:
93+
group_name = "patch"
94+
elif "cleanup-no-release-required" in pull_labels:
95+
group_name = "cleanup"
9696
else:
97-
group_name = 'unspecified'
97+
group_name = "unspecified"
9898
pulls_missing_semver_label.append(pull)
9999
pull_request_by_type[group_name].append(pull)
100100

@@ -103,80 +103,80 @@ def main():
103103
# pprint.pprint('merged at: {}'.format(pull.merged_at))
104104
# print(pull.html_url)
105105

106-
if group_name in ['major', 'minor', 'patch']:
106+
if group_name in ["major", "minor", "patch"]:
107107
pull_request_changes.append(
108-
'- {} ([#{}]({}))'.format(pull.title, pull.number, pull.html_url)
108+
"- {} ([#{}]({}))".format(pull.title, pull.number, pull.html_url)
109109
)
110110

111111
# print('-' * 10)
112112

113113
# pprint.pprint(pull_request_changes)
114114

115115
if not pull_request_changes:
116-
print('No merged pull requests since the most recent tag release were found')
116+
print("No merged pull requests since the most recent tag release were found")
117117
return
118118

119119
# Raise error if any pull request is missing a semantic version change type.
120120
if pulls_missing_semver_label:
121121
error_message = (
122-
'Merged pull request(s) found without semantic version label:\n'
123-
'{}'.format(
124-
'\n'.join(
125-
' {}'.format(pull.html_url) for pull in pulls_missing_semver_label
122+
"Merged pull request(s) found without semantic version label:\n"
123+
"{}".format(
124+
"\n".join(
125+
" {}".format(pull.html_url) for pull in pulls_missing_semver_label
126126
)
127127
)
128128
)
129129
raise Exception(error_message)
130130

131131
# pprint.pprint(pull_request_by_type)
132-
if pull_request_by_type.get('major'):
133-
highest_semantic_version = 'major'
134-
php_file_path = 'scripts/bump_major_version.php'
135-
elif pull_request_by_type.get('minor'):
136-
highest_semantic_version = 'minor'
137-
php_file_path = 'scripts/bump_minor_version.php'
138-
elif pull_request_by_type.get('patch'):
139-
highest_semantic_version = 'patch'
140-
php_file_path = 'scripts/bump_patch_version.php'
132+
if pull_request_by_type.get("major"):
133+
highest_semantic_version = "major"
134+
php_file_path = "scripts/bump_major_version.php"
135+
elif pull_request_by_type.get("minor"):
136+
highest_semantic_version = "minor"
137+
php_file_path = "scripts/bump_minor_version.php"
138+
elif pull_request_by_type.get("patch"):
139+
highest_semantic_version = "patch"
140+
php_file_path = "scripts/bump_patch_version.php"
141141
else:
142142
highest_semantic_version = None
143-
php_file_path = ''
144-
print('highest_semantic_version: {}'.format(highest_semantic_version))
143+
php_file_path = ""
144+
print("highest_semantic_version: {}".format(highest_semantic_version))
145145

146146
# Bump version and get next semantic version.
147-
command = ['php', php_file_path]
148-
print('running command: {}'.format(command))
147+
command = ["php", php_file_path]
148+
print("running command: {}".format(command))
149149
proc = subprocess.Popen(
150150
command, shell=False, stdout=subprocess.PIPE, stdin=subprocess.PIPE
151151
)
152152
stdout, stderr = proc.communicate()
153-
print('stdout: {}'.format(stdout))
154-
print('stderr: {}'.format(stderr))
153+
print("stdout: {}".format(stdout))
154+
print("stderr: {}".format(stderr))
155155
result = json.loads(stdout)
156156
pprint.pprint(result)
157157

158-
release_version = result['new_version']
158+
release_version = result["new_version"]
159159
today = datetime.today()
160-
print('today: {} (tzinfo={})'.format(today, today.tzinfo))
160+
print("today: {} (tzinfo={})".format(today, today.tzinfo))
161161
today = today.replace(tzinfo=timezone.utc)
162-
print('today: {} (tzinfo={})'.format(today, today.tzinfo))
163-
release_date = today.strftime('%Y-%m-%d')
164-
print('release_date: {}'.format(release_date))
165-
release_title = '{} - {}'.format(release_version, release_date)
166-
print('release_title: {}'.format(release_title))
162+
print("today: {} (tzinfo={})".format(today, today.tzinfo))
163+
release_date = today.strftime("%Y-%m-%d")
164+
print("release_date: {}".format(release_date))
165+
release_title = "{} - {}".format(release_version, release_date)
166+
print("release_title: {}".format(release_title))
167167

168-
release_content = ''.join(
168+
release_content = "".join(
169169
[
170-
'## {}\n',
171-
'\n',
172-
'{}',
170+
"## {}\n",
171+
"\n",
172+
"{}",
173173
]
174-
).format(release_title, '\n'.join(pull_request_changes))
174+
).format(release_title, "\n".join(pull_request_changes))
175175

176176
old_content = CHANGELOG_PATH.read_text()
177177
new_content = old_content.replace(
178-
'<!-- CHANGELOG_PLACEHOLDER -->',
179-
'<!-- CHANGELOG_PLACEHOLDER -->\n\n{}'.format(release_content),
178+
"<!-- CHANGELOG_PLACEHOLDER -->",
179+
"<!-- CHANGELOG_PLACEHOLDER -->\n\n{}".format(release_content),
180180
)
181181
# print(new_content[:800])
182182
CHANGELOG_PATH.write_text(new_content)
@@ -195,19 +195,19 @@ def main():
195195
# print(local_repo.git.diff(cached=True, color='always'))
196196

197197
local_repo.git.commit(
198-
message=result['message'],
199-
author='{} <{}>'.format(
200-
local_repo.git.config('--get', 'user.name'),
201-
local_repo.git.config('--get', 'user.email'),
198+
message=result["message"],
199+
author="{} <{}>".format(
200+
local_repo.git.config("--get", "user.name"),
201+
local_repo.git.config("--get", "user.email"),
202202
),
203203
)
204204

205-
print('diff after commit:')
205+
print("diff after commit:")
206206
# git log --max-count=1 --patch --color=always
207-
print(local_repo.git.log(max_count='1', patch=True, color='always'))
207+
print(local_repo.git.log(max_count="1", patch=True, color="always"))
208208

209209
# Push local changes.
210-
server = 'https://{}@github.com/{}.git'.format(GITHUB_TOKEN, GITHUB_REPOSITORY)
210+
server = "https://{}@github.com/{}.git".format(GITHUB_TOKEN, GITHUB_REPOSITORY)
211211
print(
212212
'pushing changes to branch "{}" of repository "{}"'.format(
213213
GITHUB_REF_NAME, GITHUB_REPOSITORY
@@ -216,35 +216,35 @@ def main():
216216
local_repo.git.push(server, GITHUB_REF_NAME)
217217

218218
# Create tag and release.
219-
tag = result['new_version']
220-
tag_message = result['message']
221-
release_name = 'Release {}'.format(release_version)
219+
tag = result["new_version"]
220+
tag_message = result["message"]
221+
release_name = "Release {}".format(release_version)
222222
release_message = (
223-
'See [change log](https://github.com/php-curl-class/php-curl-class/blob/master/CHANGELOG.md) for changes.\n'
224-
'\n'
225-
'https://github.com/php-curl-class/php-curl-class/compare/{}...{}'.format(
226-
result['old_version'],
227-
result['new_version'],
223+
"See [change log](https://github.com/php-curl-class/php-curl-class/blob/master/CHANGELOG.md) for changes.\n"
224+
"\n"
225+
"https://github.com/php-curl-class/php-curl-class/compare/{}...{}".format(
226+
result["old_version"],
227+
result["new_version"],
228228
)
229229
)
230230
commit_sha = local_repo.head.commit.hexsha
231-
print('tag: {}'.format(tag))
231+
print("tag: {}".format(tag))
232232
print('tag_message: "{}"'.format(tag_message))
233233
print('release_name: "{}"'.format(release_name))
234234
print('release_message: "{}"'.format(release_message))
235-
print('commit_sha: {}'.format(commit_sha))
235+
print("commit_sha: {}".format(commit_sha))
236236

237237
github_repo.create_git_tag_and_release(
238238
tag=tag,
239239
tag_message=tag_message,
240240
release_name=release_name,
241241
release_message=release_message,
242242
object=commit_sha,
243-
type='commit',
243+
type="commit",
244244
draft=False,
245245
)
246-
print('created tag and release')
246+
print("created tag and release")
247247

248248

249-
if __name__ == '__main__':
249+
if __name__ == "__main__":
250250
main()

0 commit comments

Comments
 (0)