Skip to content

Commit

Permalink
feat: add property for issue tracker status
Browse files Browse the repository at this point in the history
Add property to GitProject class that denotes whether issue tracker is
enabled on the specific project or not.

Fixes packit#664

Signed-off-by: Matej Focko <[email protected]>
  • Loading branch information
mfocko committed Mar 10, 2022
1 parent 80d1985 commit af86295
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ogr/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -1357,6 +1357,11 @@ def parent(self) -> Optional["GitProject"]:
"""Parent project if the project is a fork, otherwise `None`."""
raise NotImplementedError()

@property
def has_issues(self) -> bool:
"""`True` if issues are enabled on the project."""
raise NotImplementedError()

def get_branches(self) -> List[str]:
"""
Returns:
Expand Down
4 changes: 4 additions & 0 deletions ogr/services/github/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ def description(self) -> str:
def description(self, new_description: str) -> None:
self.github_repo.edit(description=new_description)

@property
def has_issues(self) -> bool:
return self.github_repo.has_issues

def _construct_fork_project(self) -> Optional["GithubProject"]:
gh_user = self.github_instance.get_user()
user_login = gh_user.login
Expand Down
4 changes: 4 additions & 0 deletions ogr/services/gitlab/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ def __eq__(self, o: object) -> bool:
and self.service == o.service
)

@property
def has_issues(self) -> bool:
return self.gitlab_repo.issues_enabled

def _construct_fork_project(self) -> Optional["GitlabProject"]:
user_login = self.service.user.get_username()
try:
Expand Down
5 changes: 5 additions & 0 deletions ogr/services/pagure/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,11 @@ def description(self) -> str:
def description(self, new_description: str) -> None:
raise OperationNotSupported("Not possible on Pagure")

@property
def has_issues(self) -> bool:
options = self._call_project_api("options", method="GET")
return options["settings"]["issue_tracker"]

def get_owners(self) -> List[str]:
project = self.get_project_info()
return project["access_users"]["owner"]
Expand Down
6 changes: 6 additions & 0 deletions tests/integration/github/test_generic_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,3 +256,9 @@ def test_delete(self):
repo="delete-project", namespace="shreyaspapi"
)
project.delete()

def test_has_issues(self):
project = self.hello_world_project

assert project.has_issues
assert not project.get_fork().has_issues, "Forks don't have issues by default"
6 changes: 6 additions & 0 deletions tests/integration/gitlab/test_generic_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,3 +233,9 @@ def test_delete(self):
repo="delete-project", namespace="shreyaspapi"
)
project.delete()

def test_has_issues(self):
assert self.project.has_issues
assert not self.service.get_project(
namespace="redhat/centos-stream/rpms", repo="firefox"
).has_issues
4 changes: 4 additions & 0 deletions tests/integration/pagure/test_generic_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,3 +142,7 @@ def test_get_sha_from_branch(self):
def test_get_sha_from_branch_non_existing(self):
commit_sha = self.ogr_project.get_sha_from_branch("non-existing")
assert commit_sha is None

def test_has_issues(self):
assert self.ogr_project.has_issues
assert not self.ogr_project.get_fork().has_issues, "Forks don't have issues"

0 comments on commit af86295

Please sign in to comment.