Skip to content

Commit

Permalink
Merge branch 'master' into pages-ivar-set
Browse files Browse the repository at this point in the history
  • Loading branch information
BanzaiMan committed Mar 9, 2018
2 parents 610be4a + aaf5f6a commit a7d69d6
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -289,6 +289,7 @@ This _overrides_ the `gemspec` option.
that supports this option. See https://github.com/travis-ci/dpl/issues/660
for details.
* **docs_dir**: Optional. A path to the directory to upload documentation from. Defaults to 'build/docs'
* **skip_existing**: Optional. When set to `true`, the deployment will not fail if a file with the same name already exists on the server. It won't be uploaded and will not overwrite the existing file. Defaults to `false`.

#### Environment variables:

Expand Down
8 changes: 7 additions & 1 deletion lib/dpl/provider/pypi.rb
Expand Up @@ -32,6 +32,12 @@ def skip_upload_docs?
(options.has_key?(:skip_upload_docs) && options[:skip_upload_docs])
end

def pypi_skip_existing_option
if options.fetch(:skip_existing, false)
' --skip-existing'
end
end

def install_deploy_dependencies
unless context.shell "wget -O - https://bootstrap.pypa.io/get-pip.py | python - --no-setuptools --no-wheel && " \
"pip install --upgrade setuptools twine wheel"
Expand Down Expand Up @@ -89,7 +95,7 @@ def needs_key?

def push_app
context.shell "python setup.py #{pypi_distributions}"
unless context.shell "twine upload -r pypi dist/*"
unless context.shell "twine upload#{pypi_skip_existing_option} -r pypi dist/*"
error 'PyPI upload failed.'
end
context.shell "rm -rf dist/*"
Expand Down
18 changes: 18 additions & 0 deletions spec/provider/pypi_spec.rb
Expand Up @@ -56,6 +56,24 @@
provider.push_app
end

example "with :skip_existing option being false" do
provider.options.update(:skip_existing => false)
expect(provider.context).to receive(:shell).with("python setup.py sdist").and_return(true)
expect(provider.context).to receive(:shell).with("twine upload -r pypi dist/*").and_return(true)
expect(provider.context).to receive(:shell).with("rm -rf dist/*").and_return(true)
expect(provider.context).not_to receive(:shell).with("python setup.py upload_docs -r https://upload.pypi.org/legacy/")
provider.push_app
end

example "with :skip_existing option being true" do
provider.options.update(:skip_existing => true)
expect(provider.context).to receive(:shell).with("python setup.py sdist").and_return(true)
expect(provider.context).to receive(:shell).with("twine upload --skip-existing -r pypi dist/*").and_return(true)
expect(provider.context).to receive(:shell).with("rm -rf dist/*").and_return(true)
expect(provider.context).not_to receive(:shell).with("python setup.py upload_docs -r https://upload.pypi.org/legacy/")
provider.push_app
end

example "with :skip_upload_docs option" do
provider.options.update(:skip_upload_docs => true)
expect(provider.context).to receive(:shell).with("python setup.py sdist").and_return(true)
Expand Down

0 comments on commit a7d69d6

Please sign in to comment.