Skip to content

Commit

Permalink
gitbug: Correctly expand user home directory
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
marty-oehme authored and ryneeverett committed Feb 13, 2024
1 parent 8fbc9c0 commit bfe238a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
3 changes: 1 addition & 2 deletions bugwarrior/services/gitbug.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import logging
import os
import pathlib
import signal
import subprocess
import sys
Expand All @@ -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}}'
Expand Down
14 changes: 12 additions & 2 deletions tests/test_gitbug.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

0 comments on commit bfe238a

Please sign in to comment.