Skip to content

Commit 28b7a07

Browse files
david-fortinikasteph
authored andcommitted
Let poetry use default branch if none is specified. Resolves: python-poetry/poetry#3366
1 parent d677150 commit 28b7a07

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

poetry/core/packages/vcs_dependency.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ def __init__(
3434
self._source = source
3535

3636
if not any([branch, tag, rev]):
37-
# If nothing has been specified, we assume master
38-
branch = "master"
37+
# If nothing has been specified, we assume nothing and use default branch
38+
branch = ""
3939

4040
self._branch = branch
4141
self._tag = tag
@@ -107,6 +107,12 @@ def base_pep_508_name(self) -> str:
107107
if self.extras:
108108
requirement += "[{}]".format(",".join(self.extras))
109109

110+
if self.branch == "":
111+
if parsed_url.protocol is not None:
112+
requirement += " @ {}+{}".format(self._vcs, self._source)
113+
else:
114+
requirement += " @ {}+ssh://{}".format(self._vcs, parsed_url.format())
115+
return requirement
110116
if parsed_url.protocol is not None:
111117
requirement += " @ {}+{}@{}".format(self._vcs, self._source, self.reference)
112118
else:

tests/masonry/builders/test_sdist.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def test_convert_dependencies():
5555
"A>=1.0,<2.0",
5656
"B>=1.0,<1.1",
5757
"C==1.2.3",
58-
"D @ git+https://github.com/sdispater/d.git@master",
58+
"D @ git+https://github.com/sdispater/d.git",
5959
"E>=1.0,<2.0",
6060
"F>=1.0,<2.0,!=1.3",
6161
]

tests/packages/test_vcs_dependency.py

+9-5
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ def test_to_pep_508():
88
"poetry", "git", "https://github.com/python-poetry/poetry.git"
99
)
1010

11-
expected = "poetry @ git+https://github.com/python-poetry/poetry.git@master"
11+
expected = "poetry @ git+https://github.com/python-poetry/poetry.git"
1212

1313
assert expected == dependency.to_pep_508()
1414

1515

1616
def test_to_pep_508_ssh():
1717
dependency = VCSDependency("poetry", "git", "[email protected]:sdispater/poetry.git")
1818

19-
expected = "poetry @ git+ssh://[email protected]/sdispater/poetry.git@master"
19+
expected = "poetry @ git+ssh://[email protected]/sdispater/poetry.git"
2020

2121
assert expected == dependency.to_pep_508()
2222

@@ -26,7 +26,7 @@ def test_to_pep_508_with_extras():
2626
"poetry", "git", "https://github.com/python-poetry/poetry.git", extras=["foo"]
2727
)
2828

29-
expected = "poetry[foo] @ git+https://github.com/python-poetry/poetry.git@master"
29+
expected = "poetry[foo] @ git+https://github.com/python-poetry/poetry.git"
3030

3131
assert expected == dependency.to_pep_508()
3232

@@ -37,15 +37,19 @@ def test_to_pep_508_in_extras():
3737
)
3838
dependency.in_extras.append("foo")
3939

40-
expected = 'poetry @ git+https://github.com/python-poetry/poetry.git@master ; extra == "foo"'
40+
expected = (
41+
'poetry @ git+https://github.com/python-poetry/poetry.git ; extra == "foo"'
42+
)
4143
assert expected == dependency.to_pep_508()
4244

4345
dependency = VCSDependency(
4446
"poetry", "git", "https://github.com/python-poetry/poetry.git", extras=["bar"]
4547
)
4648
dependency.in_extras.append("foo")
4749

48-
expected = 'poetry[bar] @ git+https://github.com/python-poetry/poetry.git@master ; extra == "foo"'
50+
expected = (
51+
'poetry[bar] @ git+https://github.com/python-poetry/poetry.git ; extra == "foo"'
52+
)
4953

5054
assert expected == dependency.to_pep_508()
5155

0 commit comments

Comments
 (0)