Skip to content

Commit

Permalink
Merge pull request #1312 from getnikola/fix-1311
Browse files Browse the repository at this point in the history
fix #1311 -- make github_deploy work on Python 3.
  • Loading branch information
Kwpolska committed Jun 2, 2014
2 parents e2df1fe + 4ad86a0 commit 4564590
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Features
Bugfixes
--------

* made github_deploy compatible with Python 3 (Issue #1311)
* rebuild stuff on TranslatableSettings’ change (Issue #1297)
* made bootstrap-jinja and bootstrap3-jinja work again, assets were missing
(Issue #1309)
Expand Down
15 changes: 10 additions & 5 deletions nikola/plugins/command/github_deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@
from nikola import __version__


def uni_check_output(*args, **kwargs):
o = subprocess.check_output(*args, **kwargs)
return o.decode('utf-8')


class CommandGitHubDeploy(Command):
""" Deploy site to GitHub pages. """
name = 'github_deploy'
Expand Down Expand Up @@ -122,7 +127,7 @@ def _commit_and_push(self):
source = self._source_branch
remote = self._remote_name

source_commit = subprocess.check_output(['git', 'rev-parse', source])
source_commit = uni_check_output(['git', 'rev-parse', source])
commit_message = (
'Nikola auto commit.\n\n'
'Source commit: %s'
Expand Down Expand Up @@ -213,7 +218,7 @@ def _ensure_git_repo(self):
"""

try:
remotes = subprocess.check_output(['git', 'remote'])
remotes = uni_check_output(['git', 'remote'])
except subprocess.CalledProcessError as e:
self.logger.notice('github_deploy needs a git repository!')
sys.exit(e.returncode)
Expand All @@ -237,7 +242,7 @@ def _exit_if_output_committed(self):
subprocess.check_call(['git', 'checkout', source])

output_folder = self.site.config['OUTPUT_FOLDER']
output_log = subprocess.check_output(
output_log = uni_check_output(
['git', 'ls-files', '--', output_folder]
)

Expand All @@ -251,9 +256,9 @@ def _exit_if_output_committed(self):
def _prompt_continue(self):
""" Show uncommitted changes, and ask if user wants to continue. """

changes = subprocess.check_output(['git', 'status', '--porcelain'])
changes = uni_check_output(['git', 'status', '--porcelain'])
if changes.strip():
changes = subprocess.check_output(['git', 'status']).strip()
changes = uni_check_output(['git', 'status']).strip()
message = (
"You have the following changes:\n%s\n\n"
"Anything not committed, and unknown to Nikola may be lost, "
Expand Down

0 comments on commit 4564590

Please sign in to comment.