vcssync: don't write tailing JSON (
bug 1358312); r?glob
Python's built-in json serializer adds trailing whitespace after
commas by default. This makes sense for the default serialization
mode. But when putting each entry on its own line, this results in
trailing whitespace on lines.
This commit sets explicit separators when serializing so we don't
produce trailing whitespace. FWIW, I'm pretty sure Python 3 does
this nicer behavior by default.
MozReview-Commit-ID: JJl5JaY1Ft2
--- a/vcssync/mozvcssync/gitrewrite/__init__.py
+++ b/vcssync/mozvcssync/gitrewrite/__init__.py
@@ -191,17 +191,18 @@ def rewrite_commit_message(message, summ
return github3.users.User(data, github_client)
if github_client:
user = github_client.user(login)
if user and github_cache_dir:
with open(path, 'wb') as fh:
json.dump(user.to_json(), fh, encoding='utf-8',
- indent=2, sort_keys=True)
+ indent=2, sort_keys=True,
+ separators=(',', ': '))
return user
return None
def get_pull_request(number):
pr = None
@@ -214,17 +215,18 @@ def rewrite_commit_message(message, summ
pr = github3.pulls.PullRequest(data, github_client)
if not pr and github_client and github_org and github_repo:
pr = github_client.pull_request(github_org, github_repo, number)
if pr and github_cache_dir:
with open(path, 'wb') as fh:
json.dump(pr.to_json(), fh, encoding='utf-8',
- indent=2, sort_keys=True)
+ indent=2, sort_keys=True,
+ separators=(',', ': '))
user = None
if pr and pr.head.user:
user = get_user(pr.head.user.login)
return pr, user
if normalize_github_merge: