diff --git a/github_release.py b/github_release.py index 102a7a9..6ed05f7 100755 --- a/github_release.py +++ b/github_release.py @@ -1,4 +1,5 @@ #!/usr/bin/env python2.7 +# -*- coding: utf-8 -*- from __future__ import print_function @@ -370,7 +371,7 @@ def patch_release(repo_name, current_tag_name, **values): response = _request( 'PATCH', url, data=json.dumps(data), - headers={'Content-Type': 'application/json'}) + headers={'Content-Type': 'application/json; charset=utf-8'}) response.raise_for_status() # In case a new tag name was provided, remove the old one. @@ -456,7 +457,7 @@ def gh_release_create(repo_name, tag_name, asset_pattern=None, name=None, response = _request( 'POST', GITHUB_API + '/repos/{0}/releases'.format(repo_name), data=json.dumps(data), - headers={'Content-Type': 'application/json'}) + headers={'Content-Type': 'application/json; charset=utf-8'}) response.raise_for_status() print_release_info(response.json(), title="created '%s' release" % tag_name) @@ -983,7 +984,7 @@ def gh_ref_create(repo_name, reference, sha): response = _request( 'POST', GITHUB_API + '/repos/{0}/git/refs'.format(repo_name), data=json.dumps(data), - headers={'Content-Type': 'application/json'}) + headers={'Content-Type': 'application/json; charset=utf-8'}) response.raise_for_status() print_ref_info(response.json()) diff --git a/tests/__init__.py b/tests/__init__.py index af88266..72fe91d 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import datetime as dt import errno @@ -148,8 +149,11 @@ def run(*popenargs, **kwargs): # def read_version_file(): - with open("VERSION") as content: - return content.readline().strip() + try: + with open("VERSION") as content: + return content.readline().strip() + except IOError: + return None # @@ -258,6 +262,8 @@ def do_commit(version=None, branch=None, release_tag=None, push=False): commit_date = generate_commit_date() if version is None: version = read_version_file() + if version is None: + version = "0.0.0" msg = "Update to %s.dev%s" % (version, commit_date.strftime("%Y%m%d")) if release_tag is not None: msg = "%s %s" % (PROJECT_NAME, release_tag) diff --git a/tests/conftest.py b/tests/conftest.py index e1abe9a..d93d8b8 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import os diff --git a/tests/test_cli.py b/tests/test_cli.py index 4c04304..ca59d76 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import pytest @@ -50,7 +51,7 @@ ([], "release", "edit", ["1.0.0", "--tag-name", "new_tag", "--target-commitish", "1234567", "--name", "new_name", - "--body", "new_body"]), + "--body", u"new_body with utf-8 char …"]), ([], "release", "delete", ["1.0.0"]), ([], "release", "delete", ["*a", "--keep-pattern", "1*"]), ([], "release", "publish", ["1.0.0"]), diff --git a/tests/test_distribution.py b/tests/test_distribution.py index b7ab729..d2f82be 100644 --- a/tests/test_distribution.py +++ b/tests/test_distribution.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import pytest diff --git a/tests/test_integration_asset.py b/tests/test_integration_asset.py index 6e205aa..9f5a894 100644 --- a/tests/test_integration_asset.py +++ b/tests/test_integration_asset.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- from . import ( check_releases, diff --git a/tests/test_integration_commit.py b/tests/test_integration_commit.py index 2b86984..d78e82c 100644 --- a/tests/test_integration_commit.py +++ b/tests/test_integration_commit.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- from . import ( do_commit, diff --git a/tests/test_integration_ref.py b/tests/test_integration_ref.py index 6f8f7c6..eb44b22 100644 --- a/tests/test_integration_ref.py +++ b/tests/test_integration_ref.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- from . import ( do_commit, diff --git a/tests/test_integration_release_create.py b/tests/test_integration_release_create.py index 4760fcb..d298948 100644 --- a/tests/test_integration_release_create.py +++ b/tests/test_integration_release_create.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- from . import ( check_releases, diff --git a/tests/test_integration_release_delete.py b/tests/test_integration_release_delete.py index b433fdd..0a419f1 100644 --- a/tests/test_integration_release_delete.py +++ b/tests/test_integration_release_delete.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- from . import ( check_releases, diff --git a/tests/test_integration_release_edit.py b/tests/test_integration_release_edit.py index bdf5d97..f05c0fb 100644 --- a/tests/test_integration_release_edit.py +++ b/tests/test_integration_release_edit.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import pytest @@ -137,7 +138,7 @@ def test_edit_name_and_body(release_type): # Edit release ghr.gh_release_edit( REPO_NAME, "0.1.0", - name="name-edited", body="body-edited" + name="name-edited", body=u"body-edited with utf-8 char …" ) assert (check_releases([ @@ -145,7 +146,7 @@ def test_edit_name_and_body(release_type): "draft": params["draft"], "prerelease": params["prerelease"], "name": "name-edited", - "body": "body-edited"}, + "body": u"body-edited with utf-8 char …"}, ]))