Skip to content

Commit 58c89d8

Browse files
committed
alternate vcs: Fix _get_mod on windows
1 parent 02aa801 commit 58c89d8

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/towncrier/_vcs.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ def list_changed_files_compared_to_branch(
1717

1818

1919
def _get_mod(base_directory: str) -> VCSMod:
20+
base_directory = os.path.abspath(base_directory)
2021
if os.path.exists(os.path.join(base_directory, ".git")):
2122
from . import _git
2223

@@ -27,12 +28,14 @@ def _get_mod(base_directory: str) -> VCSMod:
2728
hg: VCSMod = _hg
2829

2930
return hg
30-
elif base_directory == "/":
31-
from . import _novcs
32-
33-
return _novcs
3431
else:
35-
return _get_mod(os.path.dirname(base_directory))
32+
parent = os.path.dirname(base_directory)
33+
if parent == base_directory:
34+
from . import _novcs
35+
36+
return _novcs
37+
38+
return _get_mod(parent)
3639

3740

3841
def get_default_compare_branch(

src/towncrier/test/test_hg.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Copyright (c) Amber Brown, 2015
22
# See LICENSE for details.
33

4+
import os.path
45

56
from pathlib import Path
67
from subprocess import check_call
@@ -71,7 +72,7 @@ def test_hg(self):
7172
self.assertEqual(["main", "otherbranch"], branches)
7273

7374
self.assertEqual(
74-
["changes/000.misc.rst"],
75+
[os.path.join("changes", "000.misc.rst")],
7576
_hg.list_changed_files_compared_to_branch(".", "main", False),
7677
)
7778

0 commit comments

Comments
 (0)