Skip to content

Commit 7d1f1b6

Browse files
committed
Migrate GitHub abd GitLab integrations to new request system #350
Signed-off-by: tdruez <[email protected]>
1 parent 32619c0 commit 7d1f1b6

File tree

2 files changed

+6
-42
lines changed

2 files changed

+6
-42
lines changed

workflow/integrations/github.py

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,7 @@ def create_issue(self, repo_id, title, body="", labels=None):
7171
if labels:
7272
data["labels"] = labels
7373

74-
response = self.session.post(
75-
url,
76-
json=data,
77-
timeout=self.default_timeout,
78-
)
79-
response.raise_for_status()
80-
return response.json()
74+
return self.post(url, json=data)
8175

8276
def update_issue(self, repo_id, issue_id, title=None, body=None, state=None, labels=None):
8377
"""Update an existing GitHub issue."""
@@ -92,26 +86,14 @@ def update_issue(self, repo_id, issue_id, title=None, body=None, state=None, lab
9286
if labels:
9387
data["labels"] = labels
9488

95-
response = self.session.patch(
96-
url,
97-
json=data,
98-
timeout=self.default_timeout,
99-
)
100-
response.raise_for_status()
101-
return response.json()
89+
return self.patch(url, json=data)
10290

10391
def post_comment(self, repo_id, issue_id, comment_body):
10492
"""Post a comment on an existing GitHub issue."""
10593
url = f"{self.api_url}/repos/{repo_id}/issues/{issue_id}/comments"
10694
data = {"body": comment_body}
10795

108-
response = self.session.post(
109-
url,
110-
json=data,
111-
timeout=self.default_timeout,
112-
)
113-
response.raise_for_status()
114-
return response.json()
96+
return self.post(url, json=data)
11597

11698
@staticmethod
11799
def extract_github_repo_path(url):

workflow/integrations/gitlab.py

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,7 @@ def create_issue(self, repo_id, title, body="", labels=None):
7676
# GitLab expects a comma-separated string for labels
7777
data["labels"] = ",".join(labels)
7878

79-
response = self.session.post(
80-
url,
81-
json=data,
82-
timeout=self.default_timeout,
83-
)
84-
response.raise_for_status()
85-
return response.json()
79+
return self.post(url, json=data)
8680

8781
def update_issue(self, repo_id, issue_id, title=None, body=None, state_event=None, labels=None):
8882
"""Update an existing GitLab issue."""
@@ -99,27 +93,15 @@ def update_issue(self, repo_id, issue_id, title=None, body=None, state_event=Non
9993
# GitLab expects a comma-separated string for labels
10094
data["labels"] = ",".join(labels)
10195

102-
response = self.session.put(
103-
url,
104-
json=data,
105-
timeout=self.default_timeout,
106-
)
107-
response.raise_for_status()
108-
return response.json()
96+
return self.put(url, json=data)
10997

11098
def post_comment(self, repo_id, issue_id, comment_body):
11199
"""Post a comment on an existing GitLab issue."""
112100
project_path = quote(repo_id, safe="")
113101
url = f"{self.api_url}/projects/{project_path}/issues/{issue_id}/notes"
114102
data = {"body": comment_body}
115103

116-
response = self.session.post(
117-
url,
118-
json=data,
119-
timeout=self.default_timeout,
120-
)
121-
response.raise_for_status()
122-
return response.json()
104+
return self.post(url, json=data)
123105

124106
@staticmethod
125107
def extract_gitlab_project_path(url):

0 commit comments

Comments
 (0)