Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support --exclude-from for rsync publishing using excludes.txt #2659

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions pelican/tools/pelican_quickstart.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@ class _DEFAULT_PATH_TYPE(str):
_DEFAULT_PATH = _DEFAULT_PATH_TYPE(os.curdir)


RSYNC_EXCLUDES = """\
# Files to exclude with rsync(1) during publishing.
# See the INCLUDE/EXCLUDE PATTERN RULES section of the rsync man page.

.DS_Store
"""


def ask(question, answer=str, default=None, length=None):
if answer == str:
r = ''
Expand Down Expand Up @@ -347,6 +355,13 @@ def main():
fd.close()
except OSError as e:
print('Error: {0}'.format(e))
try:
with open(os.path.join(CONF['basedir'], 'rsync_excludes.txt'),
'w', 'utf-8') as fd:
fd.write(RSYNC_EXCLUDES)
fd.close()
except OSError as e:
print('Error: {0}'.format(e))

print('Done. Your new project is available at %s' % CONF['basedir'])

Expand Down
2 changes: 1 addition & 1 deletion pelican/tools/templates/Makefile.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ ssh_upload: publish

{% set upload = upload + ["rsync_upload"] %}
rsync_upload: publish
rsync -e "ssh -p $(SSH_PORT)" -P -rvzc --cvs-exclude --delete $(OUTPUTDIR)/ $(SSH_USER)@$(SSH_HOST):$(SSH_TARGET_DIR)
rsync -e "ssh -p $(SSH_PORT)" -P -rvzc --cvs-exclude --exclude-from=rsync_excludes.txt --delete $(OUTPUTDIR)/ $(SSH_USER)@$(SSH_HOST):$(SSH_TARGET_DIR)

{% endif %}
{% if dropbox %}
Expand Down
2 changes: 1 addition & 1 deletion pelican/tools/templates/tasks.py.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def publish(c):
"""Publish to production via rsync"""
c.run('pelican -s {settings_publish}'.format(**CONFIG))
c.run(
'rsync --delete --exclude ".DS_Store" -pthrvz -c '
'rsync --delete --exclude-from=rsync_excludes.txt -pthrvz -c '
'-e "ssh -p {ssh_port}" '
'{} {ssh_user}@{ssh_host}:{ssh_path}'.format(
CONFIG['deploy_path'].rstrip('/') + '/',
Expand Down