Skip to content

Commit

Permalink
Support tags in output
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardobranco777 committed Sep 11, 2023
1 parent 87a34a9 commit b902e9f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ RUN zypper -n install \
python3-PyGithub \
python3-python-gitlab \
python3-python-redmine && \
rm -rf /var/cache
zypper clean -a

COPY bugme.py /

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ black:

.PHONY: test
test:
@TZ=Europe/Berlin pytest -v
@TZ=Europe/Berlin pytest -vv
8 changes: 8 additions & 0 deletions bugme.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ class Service:
def __init__(self, url: str):
url = url.rstrip("/")
self.url = url if url.startswith("https://") else f"https://{url}"
self.tag = "".join([s[0] for s in str(urlparse(self.url).hostname).split(".")])

def __repr__(self) -> str:
return f"{self.__class__.__name__}(url='{self.url}')"
Expand Down Expand Up @@ -194,6 +195,7 @@ def _to_item(self, info: Any) -> Item | None:
updated=info.last_change_time,
url=f"{self.url}/show_bug.cgi?id={info.id}",
extra=info.__dict__,
tag=f"{self.tag}#{info.id}",
)


Expand All @@ -208,6 +210,7 @@ def __init__(self, url: str, creds: dict):
# auth = Auth.Token(**creds)
# self.client = Github(auth=auth)
self.client = Github(**creds)
self.tag = "gh"

def get_item(self, item_id: int = -1, **kwargs) -> Item | None:
"""
Expand All @@ -230,6 +233,7 @@ def _to_item(self, info: Any, repo: str) -> Item | None:
updated=info.updated_at,
url=f"{self.url}/{repo}/issues/{info.number}",
extra=info.__dict__["_rawData"],
tag=f"{self.tag}#{repo}#{info.number}",
)


Expand All @@ -242,6 +246,8 @@ def __init__(self, url: str, creds: dict):
super().__init__(url)
ssl_verify = os.environ.get("REQUESTS_CA_BUNDLE", False) if self.url else True
self.client = Gitlab(url=self.url, ssl_verify=ssl_verify, **creds)
hostname = str(urlparse(self.url).hostname)
self.tag = "gl" if hostname == "gitlab.com" else self.tag

def __del__(self):
try:
Expand Down Expand Up @@ -272,6 +278,7 @@ def _to_item(self, info: Any, repo: str) -> Item | None:
updated=info.updated_at,
url=f"{self.url}/{repo}/-/issues/{info.iid}",
extra=info.asdict(),
tag=f"{self.tag}#{repo}#{info.iid}",
)


Expand Down Expand Up @@ -304,6 +311,7 @@ def _to_item(self, info: Any) -> Item | None:
updated=info.updated_on,
url=f"{self.url}/issues/{info.id}",
extra=info.raw(),
tag=f"{self.tag}#{info.id}",
)


Expand Down

0 comments on commit b902e9f

Please sign in to comment.