From bfe238a9e60bf10e0d276b51a4a250508add91bb Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Mon, 5 Feb 2024 09:30:37 +0100 Subject: [PATCH] gitbug: Correctly expand user home directory Previously, providing '~' as part of the path to a gitbug remote would not correctly expand to the user's home directory and error out with directory not found. This commit fixes the behavior to correctly expand the path instead, aligning behavior with that of the taskrc configuration option and other services' path expansion. --- bugwarrior/services/gitbug.py | 3 +-- tests/test_gitbug.py | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/bugwarrior/services/gitbug.py b/bugwarrior/services/gitbug.py index eef5dec7..9b65e693 100644 --- a/bugwarrior/services/gitbug.py +++ b/bugwarrior/services/gitbug.py @@ -1,6 +1,5 @@ import logging import os -import pathlib import signal import subprocess import sys @@ -17,7 +16,7 @@ class GitBugConfig(config.ServiceConfig): service: typing_extensions.Literal['gitbug'] - path: pathlib.Path + path: config.ExpandedPath import_labels_as_tags: bool = False label_template: str = '{{label}}' diff --git a/tests/test_gitbug.py b/tests/test_gitbug.py index bfaaae33..fc743206 100644 --- a/tests/test_gitbug.py +++ b/tests/test_gitbug.py @@ -4,9 +4,9 @@ import dateutil import pydantic -from bugwarrior.services.gitbug import GitBugClient, GitBugService +from bugwarrior.services.gitbug import GitBugClient, GitBugConfig, GitBugService -from .base import AbstractServiceTest, ServiceTest +from .base import AbstractServiceTest, ConfigTest, ServiceTest # NOTE: replace with stdlib dataclasses.dataclass once python-3.6 is dropped @@ -83,3 +83,13 @@ def test_issues(self): } self.assertEqual(issue.get_taskwarrior_record(), expected) + + +class TestGitBugConfig(ConfigTest): + def setUp(self): + super().setUp() + self.config = GitBugConfig(service="gitbug", path="~/custom-gitbug-repo") + + def test_home_path_expansion(self): + expected = self.tempdir + "/custom-gitbug-repo" + self.assertEqual(self.config.path, expected)