vcssync: don't write tailing JSON (bug 1358312); r?glob draft
authorGregory Szorc <gps@mozilla.com>
Thu, 20 Apr 2017 16:53:05 -0700
changeset 10837 8d63b66f93ce1825776535dc09b628c787eac3bb
parent 10836 7239a86ab53d93a595c28bc69039b49c9d58b9ae
child 10838 7329f79c67b36e28f17cee1bdcd88b44d8b9c8ad
push id1636
push userbmo:gps@mozilla.com
push dateFri, 21 Apr 2017 00:31:50 +0000
reviewersglob
bugs1358312
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
vcssync/mozvcssync/gitrewrite/__init__.py
--- 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: