Skip to content
Permalink
Browse files
Fix #2406 -- respect DEPLOY_* in github_deploy
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed Jul 27, 2016
1 parent 90f204e commit 40b2cfedc2ffb1474e9df15f3c1c4b70705e27a7
Showing with 29 additions and 18 deletions.
  1. +3 −1 CHANGES.txt
  2. +3 −15 nikola/plugins/command/deploy.py
  3. +4 −1 nikola/plugins/command/github_deploy.py
  4. +19 −1 nikola/utils.py
@@ -9,6 +9,8 @@ Features
Bugfixes
--------

* Respect ``DEPLOY_DRAFTS`` and ``DEPLOY_FUTURE`` in ``github_deploy``
(Issue #2406)
* Don’t remove ``<!DOCTYPE html>`` if typogrify filters are in use
* Avoid infinite loop if bootstrap3 can't be loaded (Issue #2402)

@@ -1865,4 +1867,4 @@ Bugfixes
* Fix for content displaying too wide
* Changelog

vim: tw=70 syntax=rst
vim: cc=70 tw=70 syntax=rst
@@ -38,15 +38,15 @@
from blinker import signal

from nikola.plugin_categories import Command
from nikola.utils import get_logger, remove_file, STDERR_HANDLER
from nikola.utils import get_logger, clean_before_deployment, STDERR_HANDLER


class CommandDeploy(Command):
"""Deploy site."""

name = "deploy"

doc_usage = "[[preset [preset...]]"
doc_usage = "[preset [preset...]]"
doc_purpose = "deploy the site"
doc_description = "Deploy the site by executing deploy commands from the presets listed on the command line. If no presets are specified, `default` is executed."
logger = None
@@ -87,19 +87,7 @@ def _execute(self, command, args):
"Think about it for 5 seconds, I'll wait :-)\n\n")
time.sleep(5)

deploy_drafts = self.site.config.get('DEPLOY_DRAFTS', True)
deploy_future = self.site.config.get('DEPLOY_FUTURE', False)
undeployed_posts = []
if not (deploy_drafts and deploy_future):
# Remove drafts and future posts
out_dir = self.site.config['OUTPUT_FOLDER']
self.site.scan_posts()
for post in self.site.timeline:
if (not deploy_drafts and post.is_draft) or \
(not deploy_future and post.publish_later):
remove_file(os.path.join(out_dir, post.destination_path()))
remove_file(os.path.join(out_dir, post.source_path))
undeployed_posts.append(post)
undeployed_posts = clean_before_deployment(self.site)

if args:
presets = args
@@ -34,7 +34,7 @@

from nikola.plugin_categories import Command
from nikola.plugins.command.check import real_scan_files
from nikola.utils import get_logger, req_missing, STDERR_HANDLER
from nikola.utils import get_logger, req_missing, clean_before_deployment, STDERR_HANDLER
from nikola.__main__ import main
from nikola import __version__

@@ -100,6 +100,9 @@ def _execute(self, options, args):
for f in only_on_output:
os.unlink(f)

# Remove drafts and future posts if requested (Issue #2406)
clean_before_deployment(self.site)

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

@@ -81,7 +81,7 @@
'adjust_name_for_index_path', 'adjust_name_for_index_link',
'NikolaPygmentsHTML', 'create_redirect', 'TreeNode',
'flatten_tree_structure', 'parse_escaped_hierarchical_category_name',
'join_hierarchical_category_path', 'indent')
'join_hierarchical_category_path', 'clean_before_deployment', 'indent')

# Are you looking for 'generic_rss_renderer'?
# It's defined in nikola.nikola.Nikola (the site object).
@@ -1867,6 +1867,24 @@ def dns_sd(port, inet6):
return None


def clean_before_deployment(site):
"""Clean drafts and future posts before deployment."""
undeployed_posts = []
deploy_drafts = site.config.get('DEPLOY_DRAFTS', True)
deploy_future = site.config.get('DEPLOY_FUTURE', False)
if not (deploy_drafts and deploy_future): # == !drafts || !future
# Remove drafts and future posts
out_dir = site.config['OUTPUT_FOLDER']
site.scan_posts()
for post in site.timeline:
if (not deploy_drafts and post.is_draft) or (not deploy_future and post.publish_later):
for lang in post.translated_to:
remove_file(os.path.join(out_dir, post.destination_path(lang)))
source_path = post.destination_path(lang, post.source_ext(True))
remove_file(os.path.join(out_dir, source_path))
undeployed_posts.append(post)
return undeployed_posts

# Stolen from textwrap in Python 3.4.3.
def indent(text, prefix, predicate=None):
"""Add 'prefix' to the beginning of selected lines in 'text'.

0 comments on commit 40b2cfe

Please sign in to comment.