Skip to content

Commit

Permalink
works
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardobranco777 committed Sep 8, 2023
1 parent a3394bd commit 57f8a7e
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions bugme.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from bugzilla.exceptions import BugzillaError # type: ignore
from redminelib import Redmine # type: ignore
from redminelib.exceptions import BaseRedmineError # type: ignore
from requests.exceptions import RequestException

CREDENTIALS_FILE = os.path.expanduser("~/creds.json")

Expand Down Expand Up @@ -85,11 +86,12 @@ def get_item(string: str) -> Union[Item, None]:
return Item(host="bugzilla.suse.com", id=int(string.split("#", 1)[1]))
if string.startswith("poo#"):
return Item(host="progress.opensuse.org", id=int(string.split("#", 1)[1]))
repo, issue = string.split("#", 2)[1:]
if string.startswith("gh#"):
repo, issue = string.split("#", 2)[1:]
return Item(host="github.com", repo=repo, id=int(issue))
if string.startswith("gl#"):
repo, issue = string.split("#", 2)[1:]
return Item(host="gitlab.com", repo=repo, id=int(issue))
if string.startswith("gsd#"):
return Item(host="gitlab.suse.de", repo=repo, id=int(issue))
return None

Expand All @@ -101,7 +103,7 @@ class Service:

def __init__(self, url: str):
url = url.rstrip("/")
self.url = url if urlparse(url).scheme else f"https://{url}"
self.url = url if url.startswith("https://") else f"https://{url}"

def __enter__(self):
return self
Expand Down Expand Up @@ -235,7 +237,7 @@ def get_item(self, item: Item) -> Union[Item, None]:
info = self.client.projects.get(item.repo, lazy=True).issues.get(
item.id
)
except GitlabError as exc:
except (GitlabError, RequestException) as exc:
logging.error("Gitlab: %s: get_issue(%s): %s", self.url, item.id, exc)
return None
return self._to_item(info, item)
Expand Down Expand Up @@ -308,7 +310,7 @@ def main() -> None:
elif host == "progress.opensuse.org":
clients[host] = MyRedmine(f"https://{host}", creds[host])
elif host.startswith("gitlab"):
clients[host] = MyGitlab("https://{host}", creds[host])
clients[host] = MyGitlab(f"https://{host}", creds[host])
elif host == "github.com":
clients[host] = MyGithub(creds[host])
else:
Expand Down

0 comments on commit 57f8a7e

Please sign in to comment.