From e4554c37b7c13c014b9374a512641916131d47a9 Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Thu, 8 Oct 2020 16:30:46 -0700 Subject: [PATCH] datasette publish heroku --tar option, closes #969 --- datasette/publish/heroku.py | 14 ++++++++++++-- docs/datasette-publish-heroku-help.txt | 3 +++ tests/test_publish_heroku.py | 14 ++++++++++++-- 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/datasette/publish/heroku.py b/datasette/publish/heroku.py index 0aa29feb..24305de5 100644 --- a/datasette/publish/heroku.py +++ b/datasette/publish/heroku.py @@ -24,6 +24,10 @@ def publish_subcommand(publish): default="datasette", help="Application name to use when deploying", ) + @click.option( + "--tar", + help="--tar option to pass to Heroku, e.g. --tar=/usr/local/bin/gtar", + ) def heroku( files, metadata, @@ -44,6 +48,7 @@ def publish_subcommand(publish): about, about_url, name, + tar, ): fail_if_publish_binary_not_installed( "heroku", "Heroku", "https://cli.heroku.com" @@ -127,8 +132,13 @@ def publish_subcommand(publish): call( ["heroku", "config:set", "-a", app_name, "{}={}".format(key, value)] ) - - call(["heroku", "builds:create", "-a", app_name, "--include-vcs-ignore"]) + tar_option = [] + if tar: + tar_option = ["--tar", tar] + call( + ["heroku", "builds:create", "-a", app_name, "--include-vcs-ignore"] + + tar_option + ) @contextmanager diff --git a/docs/datasette-publish-heroku-help.txt b/docs/datasette-publish-heroku-help.txt index b2caa2cc..991bd8f4 100644 --- a/docs/datasette-publish-heroku-help.txt +++ b/docs/datasette-publish-heroku-help.txt @@ -26,4 +26,7 @@ Options: --about TEXT About label for metadata --about_url TEXT About URL for metadata -n, --name TEXT Application name to use when deploying + --tar TEXT --tar option to pass to Heroku, e.g. + --tar=/usr/local/bin/gtar + --help Show this message and exit. diff --git a/tests/test_publish_heroku.py b/tests/test_publish_heroku.py index e0035a83..c7a38031 100644 --- a/tests/test_publish_heroku.py +++ b/tests/test_publish_heroku.py @@ -55,12 +55,22 @@ def test_publish_heroku(mock_call, mock_check_output, mock_which): runner = CliRunner() with runner.isolated_filesystem(): open("test.db", "w").write("data") - result = runner.invoke(cli.cli, ["publish", "heroku", "test.db"]) + result = runner.invoke( + cli.cli, ["publish", "heroku", "test.db", "--tar", "gtar"] + ) assert 0 == result.exit_code, result.output mock_call.assert_has_calls( [ mock.call( - ["heroku", "builds:create", "-a", "f", "--include-vcs-ignore"] + [ + "heroku", + "builds:create", + "-a", + "f", + "--include-vcs-ignore", + "--tar", + "gtar", + ] ), ] )