Skip to content

Commit 540081e

Browse files
authored
Merge pull request pypa#251 from pypa/bug/206
Fix weirdness with --repository-url
2 parents 1b95130 + 07c7efd commit 540081e

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

docs/changelog.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ Changelog
1919
* Fix ``--skip-existing`` when used to upload a package for the first time.
2020
See also :bug:`220`
2121

22+
* Fix precedence of ``--repository-url`` over ``--repository``. See also
23+
:bug:`206`
24+
2225
* :release:`1.8.1 <2016-08-09>`
2326

2427
* Check if a package exists if the URL is one of:

tests/test_utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ def test_get_repository_config_missing(tmpdir):
121121
}
122122
assert (utils.get_repository_from_config(pypirc, 'foo', repository_url) ==
123123
exp)
124+
assert (utils.get_repository_from_config(pypirc, 'pypi', repository_url) ==
125+
exp)
124126
exp = {
125127
"repository": utils.DEFAULT_REPOSITORY,
126128
"username": None,

twine/utils.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,17 +104,17 @@ def get_config(path="~/.pypirc"):
104104

105105
def get_repository_from_config(config_file, repository, repository_url=None):
106106
# Get our config from the .pypirc file
107+
if repository_url and "://" in repository_url:
108+
# assume that the repository is actually an URL and just sent
109+
# them a dummy with the repo set
110+
return {
111+
"repository": repository_url,
112+
"username": None,
113+
"password": None,
114+
}
107115
try:
108116
return get_config(config_file)[repository]
109117
except KeyError:
110-
if repository_url and "://" in repository_url:
111-
# assume that the repsoitory is actually an URL and just sent
112-
# them a dummy with the repo set
113-
return {
114-
"repository": repository_url,
115-
"username": None,
116-
"password": None,
117-
}
118118
msg = (
119119
"Missing '{repo}' section from the configuration file\n"
120120
"or not a complete URL in --repository.\n"

0 commit comments

Comments
 (0)