Skip to content
Permalink
Browse files

Fix #2198 -- github_deploy custom commit messages

Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed Dec 27, 2015
1 parent 55f7bb1 commit d65ccc2326d6a28f0e6db3332f7b3a24c6a8af3a
Showing with 24 additions and 13 deletions.
  1. +2 −0 CHANGES.txt
  2. +1 −1 docs/man/nikola.rst
  3. +2 −1 docs/manual.txt
  4. +19 −11 nikola/plugins/command/github_deploy.py
@@ -4,6 +4,8 @@ New in master
Features
--------

* Allow for customizing ``github_deploy`` commit messages with ``-m``
(Issue #2198)
* Commit to source branch automatically in ``github_deploy``
if ``GITHUB_COMMIT_SOURCE`` is set to True (Issue #2186)
* Hugo-like shortcodes (Issue #1707)
@@ -92,7 +92,7 @@ The most basic commands needed to get by are:
check for dangling links or unknown files
``nikola deploy [[preset [preset...]]``
deploy the site using the ``DEPLOY_COMMANDS`` setting
``nikola github_deploy```
``nikola github_deploy [-m COMMIT_MESSAGE]```
deploy the site to GitHub Pages
``nikola serve [-p PORT] [-a ADDRESS] [-d|--detach] [-b|--browser] [-6|--ipv6]``
start development web server
@@ -1199,7 +1199,8 @@ sure you have ``nikola`` and ``git`` installed on your PATH.

If you want to use a custom domain, create your ``CNAME`` file in
``files/CNAME`` on the source branch. Nikola will copy it to the
output directory.
output directory. To add a custom commit message, use the ``-m`` option,
followed by your message.

Comments and Annotations
------------------------
@@ -61,7 +61,7 @@ class CommandGitHubDeploy(Command):

name = 'github_deploy'

doc_usage = ''
doc_usage = '[-m COMMIT_MESSAGE]'
doc_purpose = 'deploy the site to GitHub Pages'
doc_description = dedent(
"""\
@@ -71,10 +71,19 @@ class CommandGitHubDeploy(Command):
"""
)

cmd_options = [
{
'name': 'commit_message',
'short': 'm',
'long': 'message',
'default': 'Nikola auto commit.',
'type': str,
'help': 'Commit message (default: Nikola auto commit.)',
},
]
logger = None

def _execute(self, command, args):
def _execute(self, options, args):
"""Run the deployment."""
self.logger = get_logger(CommandGitHubDeploy.name, STDERR_HANDLER)

@@ -93,7 +102,7 @@ def _execute(self, command, args):
os.unlink(f)

# Commit and push
self._commit_and_push()
self._commit_and_push(options['commit_message'])

return

@@ -112,18 +121,17 @@ def _run_command(self, command, xfail=False):
)
raise SystemError(e.returncode)

def _commit_and_push(self):
def _commit_and_push(self, commit_first_line):
"""Commit all the files and push."""
source = self.site.config['GITHUB_SOURCE_BRANCH']
deploy = self.site.config['GITHUB_DEPLOY_BRANCH']
remote = self.site.config['GITHUB_REMOTE_NAME']
autocommit = self.site.config['GITHUB_COMMIT_SOURCE']

try:
if autocommit:
commit_message = (
'Nikola auto commit.\n\n'
'Nikola version: {0}'.format(__version__)
'{0}\n\n'
'Nikola version: {1}'.format(commit_first_line, __version__)
)
e = self._run_command(['git', 'checkout', source], True)
if e != 0:
@@ -138,9 +146,9 @@ def _commit_and_push(self):

source_commit = uni_check_output(['git', 'rev-parse', source])
commit_message = (
'Nikola auto commit.\n\n'
'Source commit: {0}'
'Nikola version: {1}'.format(source_commit, __version__)
'{0}\n\n'
'Source commit: {1}'
'Nikola version: {2}'.format(commit_first_line, source_commit, __version__)
)
output_folder = self.site.config['OUTPUT_FOLDER']

0 comments on commit d65ccc2

Please sign in to comment.
You can’t perform that action at this time.