Skip to content

Commit 1888570

Browse files
committed
fix(parser): Fix pattern_defaults
1 parent 2e11591 commit 1888570

File tree

3 files changed

+15
-12
lines changed

3 files changed

+15
-12
lines changed

libvcs/parse/git.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -275,10 +275,11 @@ def __post_init__(self):
275275
groups = match.groupdict()
276276
setattr(self, "matcher", matcher.label)
277277
for k, v in groups.items():
278-
if v is None and k in matcher.pattern_defaults:
279-
setattr(self, k, matcher.pattern_defaults[v])
280-
else:
281-
setattr(self, k, v)
278+
setattr(self, k, v)
279+
280+
for k, v in matcher.pattern_defaults.items():
281+
if getattr(self, k, None) is None:
282+
setattr(self, k, matcher.pattern_defaults[k])
282283

283284
@classmethod
284285
def is_valid(cls, url: str, is_explicit: Optional[bool] = None) -> bool:

libvcs/parse/hg.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -189,10 +189,11 @@ def __post_init__(self):
189189
groups = match.groupdict()
190190
setattr(self, "matcher", matcher.label)
191191
for k, v in groups.items():
192-
if v is None and k in matcher.pattern_defaults:
193-
setattr(self, k, matcher.pattern_defaults[v])
194-
else:
195-
setattr(self, k, v)
192+
setattr(self, k, v)
193+
194+
for k, v in matcher.pattern_defaults.items():
195+
if getattr(self, k, None) is None:
196+
setattr(self, k, matcher.pattern_defaults[k])
196197

197198
@classmethod
198199
def is_valid(cls, url: str, is_explicit: Optional[bool] = False) -> bool:

libvcs/parse/svn.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,10 +183,11 @@ def __post_init__(self):
183183
groups = match.groupdict()
184184
setattr(self, "matcher", matcher.label)
185185
for k, v in groups.items():
186-
if v is None and k in matcher.pattern_defaults:
187-
setattr(self, k, matcher.pattern_defaults[v])
188-
else:
189-
setattr(self, k, v)
186+
setattr(self, k, v)
187+
188+
for k, v in matcher.pattern_defaults.items():
189+
if getattr(self, k, None) is None:
190+
setattr(self, k, matcher.pattern_defaults[k])
190191

191192
@classmethod
192193
def is_valid(cls, url: str, is_explicit: Optional[bool] = False) -> bool:

0 commit comments

Comments
 (0)