Skip to content

Commit

Permalink
chore: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
phil65 committed Nov 15, 2024
1 parent 3b5b13f commit e6d137a
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 24 deletions.
11 changes: 9 additions & 2 deletions src/githarbor/core/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,18 @@ class BaseRepository:
"""Base repository class. All methods raise FeatureNotSupportedError by default."""

url_patterns: ClassVar[list[str]] = []
_owner: str = ""
_name: str = ""

@property
def name(self):
def name(self) -> str:
"""The name of the repository."""
raise NotImplementedError
return self._name

@property
def owner(self) -> str:
"""The owner of the repository."""
return self._owner

@property
def default_branch(self):
Expand Down
5 changes: 0 additions & 5 deletions src/githarbor/providers/azurerepository.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,6 @@ def from_url(cls, url: str, **kwargs: Any) -> AzureRepository:
token=kwargs.get("token"),
)

@property
def name(self) -> str:
"""Repository name."""
return self._name

@property
def default_branch(self) -> str:
"""Default branch name."""
Expand Down
4 changes: 0 additions & 4 deletions src/githarbor/providers/gitearepository.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,6 @@ def from_url(cls, url: str, **kwargs: Any) -> GiteaRepository:
url=f"{parsed.scheme}://{parsed.netloc}",
)

@property
def name(self) -> str:
return self._name

@property
def default_branch(self) -> str:
return self._repo.default_branch
Expand Down
4 changes: 0 additions & 4 deletions src/githarbor/providers/githubrepository.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,6 @@ def from_url(cls, url: str, **kwargs: Any) -> GitHubRepository:

return cls(parts[0], parts[1], token=kwargs.get("token"))

@property
def name(self) -> str:
return self._name

@property
def default_branch(self) -> str:
return self._repo.default_branch
Expand Down
4 changes: 0 additions & 4 deletions src/githarbor/providers/gitlabrepository.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,6 @@ def from_url(cls, url: str, **kwargs: Any) -> GitLabRepository:
url=f"{parsed.scheme}://{parsed.netloc}",
)

@property
def name(self) -> str:
return self._name

@property
def default_branch(self) -> str:
return self._repo.default_branch
Expand Down
7 changes: 2 additions & 5 deletions src/githarbor/providers/localrepository.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ def __init__(self, path: str | os.PathLike[str]) -> None:
try:
self.path = UPath(path)
self.repo = git.Repo(self.path)
self._name = self.path.name
self._owner = self.path.parent.name # or None?
except (git.InvalidGitRepositoryError, git.NoSuchPathError) as e:
msg = f"Not a valid git repository: {path}"
raise ResourceNotFoundError(msg) from e
Expand All @@ -42,11 +44,6 @@ def from_url(cls, url: str, **_: Any) -> LocalRepository:
def supports_url(cls, url: str) -> bool:
return UPath(url).exists()

@property
def name(self) -> str:
"""Get repository name from directory name."""
return self.path.name

@property
def default_branch(self) -> str:
return self.repo.active_branch.name
Expand Down

0 comments on commit e6d137a

Please sign in to comment.