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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from github import Github, GithubException
|
3 |
+
import os
|
4 |
+
import requests
|
5 |
+
|
6 |
+
# Załaduj token z pliku .env lub ustaw bezpośrednio
|
7 |
+
GITHUB_TOKEN = os.getenv('GITHUB_TOKEN')
|
8 |
+
g = Github(GITHUB_TOKEN)
|
9 |
+
|
10 |
+
|
11 |
+
def import_repository(owner: str, repo_name: str, vcs_url: str):
|
12 |
+
"""Importuje repozytorium z podanego URL."""
|
13 |
+
try:
|
14 |
+
user = g.get_user()
|
15 |
+
repo = user.get_repo(repo_name) # Sprawdź, czy repozytorium już istnieje
|
16 |
+
return "Repozytorium o tej nazwie już istnieje."
|
17 |
+
except GithubException:
|
18 |
+
pass # Repozytorium nie istnieje, można importować
|
19 |
+
|
20 |
+
headers = {
|
21 |
+
'Authorization': f'token {GITHUB_TOKEN}',
|
22 |
+
'Accept': 'application/vnd.github.v3+json',
|
23 |
+
}
|
24 |
+
import_url = f'https://api.github.com/repos/{owner}/{repo_name}/import'
|
25 |
+
|
26 |
+
payload = {
|
27 |
+
'vcs_url': vcs_url,
|
28 |
+
'vcs': 'git',
|
29 |
+
}
|
30 |
+
|
31 |
+
try:
|
32 |
+
response = requests.put(import_url, json=payload, headers=headers)
|
33 |
+
if response.status_code == 201:
|
34 |
+
return "Import repozytorium został rozpoczęty."
|
35 |
+
else:
|
36 |
+
return f"Nie udało się rozpocząć importu repozytorium. Status: {response.status_code}, Szczegóły: {response.json()}"
|
37 |
+
except Exception as e:
|
38 |
+
return f"Wystąpił błąd podczas próby importu repozytorium: {str(e)}"
|
39 |
+
|
40 |
+
|
41 |
+
def create_repository(name: str):
|
42 |
+
"""Tworzy nowe repozytorium."""
|
43 |
+
try:
|
44 |
+
user = g.get_user()
|
45 |
+
repo = user.create_repo(name=name)
|
46 |
+
return f"Repozytorium {name} zostało utworzone: {repo.html_url}"
|
47 |
+
except GithubException as e:
|
48 |
+
return f"Nie udało się utworzyć repozytorium: {str(e)}"
|
49 |
+
|
50 |
+
|
51 |
+
def create_file(repo_name: str, branch: str, message: str, content: str, path: str):
|
52 |
+
"""Tworzy plik w repozytorium."""
|
53 |
+
try:
|
54 |
+
user = g.get_user()
|
55 |
+
repo = user.get_repo(repo_name)
|
56 |
+
repo.create_file(path, message, content, branch=branch)
|
57 |
+
return f"Plik {path} został utworzony w {repo_name} na gałęzi {branch}"
|
58 |
+
except GithubException as e:
|
59 |
+
return f"Nie udało się utworzyć pliku: {str(e)}"
|
60 |
+
|
61 |
+
|
62 |
+
def get_file(repo_name: str, path: str):
|
63 |
+
"""Pobiera zawartość pliku z repozytorium."""
|
64 |
+
try:
|
65 |
+
user = g.get_user()
|
66 |
+
repo = user.get_repo(repo_name)
|
67 |
+
file_content = repo.get_contents(path)
|
68 |
+
return file_content.decoded_content.decode()
|
69 |
+
except GithubException as e:
|
70 |
+
return f"Nie znaleziono pliku: {str(e)}"
|
71 |
+
|
72 |
+
|
73 |
+
def delete_file(repo_name: str, branch: str, path: str):
|
74 |
+
"""Usuwa plik z repozytorium."""
|
75 |
+
try:
|
76 |
+
user = g.get_user()
|
77 |
+
repo = user.get_repo(repo_name)
|
78 |
+
file_contents = repo.get_contents(path, ref=branch)
|
79 |
+
repo.delete_file(path, "Usuń plik", file_contents.sha, branch=branch)
|
80 |
+
return f"Plik {path} został usunięty z {repo_name} na gałęzi {branch}"
|
81 |
+
except GithubException as e:
|
82 |
+
return f"Nie udało się usunąć pliku: {str(e)}"
|
83 |
+
|
84 |
+
|
85 |
+
def update_file(repo_name: str, branch: str, path: str, message: str, content: str):
|
86 |
+
"""Aktualizuje plik w repozytorium."""
|
87 |
+
try:
|
88 |
+
user = g.get_user()
|
89 |
+
repo = user.get_repo(repo_name)
|
90 |
+
file_contents = repo.get_contents(path, ref=branch)
|
91 |
+
repo.update_file(path, message, content, file_contents.sha, branch=branch)
|
92 |
+
return f"Plik {path} został zaktualizowany w {repo_name} na gałęzi {branch}"
|
93 |
+
except GithubException as e:
|
94 |
+
return f"Nie udało się zaktualizować pliku: {str(e)}"
|
95 |
+
|
96 |
+
|
97 |
+
def list_branches(repo_name: str):
|
98 |
+
"""Listuje gałęzie w repozytorium."""
|
99 |
+
try:
|
100 |
+
user = g.get_user()
|
101 |
+
repo = user.get_repo(repo_name)
|
102 |
+
branches = repo.get_branches()
|
103 |
+
return [branch.name for branch in branches]
|
104 |
+
except GithubException as e:
|
105 |
+
return f"Nie udało się pobrać listy gałęzi: {str(e)}"
|
106 |
+
|
107 |
+
|
108 |
+
def create_branch(repo_name: str, source_branch: str, new_branch: str):
|
109 |
+
"""Tworzy nową gałąź w repozytorium."""
|
110 |
+
try:
|
111 |
+
user = g.get_user()
|
112 |
+
repo = user.get_repo(repo_name)
|
113 |
+
source_branch = repo.get_branch(source_branch)
|
114 |
+
repo.create_git_ref(ref=f"refs/heads/{new_branch}", sha=source_branch.commit.sha)
|
115 |
+
return f"Gałąź {new_branch} została utworzona od {source_branch}"
|
116 |
+
except GithubException as e:
|
117 |
+
return f"Nie udało się utworzyć gałęzi: {str(e)}"
|
118 |
+
|
119 |
+
|
120 |
+
def delete_branch(repo_name: str, branch_name: str):
|
121 |
+
"""Usuwa gałąź z repozytorium."""
|
122 |
+
try:
|
123 |
+
user = g.get_user()
|
124 |
+
repo = user.get_repo(repo_name)
|
125 |
+
repo.get_git_ref(f"heads/{branch_name}").delete()
|
126 |
+
return f"Gałąź {branch_name} została usunięta"
|
127 |
+
except GithubException as e:
|
128 |
+
return f"Nie znaleziono gałęzi lub błąd podczas usuwania: {str(e)}"
|
129 |
+
|
130 |
+
|
131 |
+
def create_pull_request(repo_name: str, title: str, body: str, base: str, head: str):
|
132 |
+
"""Tworzy pull request."""
|
133 |
+
try:
|
134 |
+
user = g.get_user()
|
135 |
+
repo = user.get_repo(repo_name)
|
136 |
+
pr = repo.create_pull(title=title, body=body, base=base, head=head)
|
137 |
+
return f"Pull request utworzony: {pr.html_url}"
|
138 |
+
except GithubException as e:
|
139 |
+
return f"Nie udało się utworzyć pull requesta: {str(e)}"
|
140 |
+
|
141 |
+
|
142 |
+
def list_open_pull_requests(repo_name: str):
|
143 |
+
"""Listuje otwarte pull requesty."""
|
144 |
+
try:
|
145 |
+
user = g.get_user()
|
146 |
+
repo = user.get_repo(repo_name)
|
147 |
+
open_prs = repo.get_pulls(state='open')
|
148 |
+
return [{'title': pr.title, 'url': pr.html_url} for pr in open_prs]
|
149 |
+
except GithubException as e:
|
150 |
+
return f"Nie udało się pobrać listy otwartych pull requestów: {str(e)}"
|
151 |
+
|
152 |
+
|
153 |
+
def create_issue(repo_name: str, title: str, body: str):
|
154 |
+
"""Tworzy issue."""
|
155 |
+
try:
|
156 |
+
user = g.get_user()
|
157 |
+
repo = user.get_repo(repo_name)
|
158 |
+
issue = repo.create_issue(title=title, body=body)
|
159 |
+
return f"Issue utworzone: {issue.html_url}"
|
160 |
+
except GithubException as e:
|
161 |
+
return f"Nie udało się utworzyć issue: {str(e)}"
|
162 |
+
|
163 |
+
|
164 |
+
def list_issues(repo_name: str):
|
165 |
+
"""Listuje issue."""
|
166 |
+
try:
|
167 |
+
user = g.get_user()
|
168 |
+
repo = user.get_repo(repo_name)
|
169 |
+
issues = repo.get_issues(state='open')
|
170 |
+
return [{'title': issue.title, 'url': issue.html_url} for issue in issues]
|
171 |
+
except GithubException as e:
|
172 |
+
return f"Nie udało się pobrać listy issue: {str(e)}"
|
173 |
+
|
174 |
+
|
175 |
+
def add_label_to_issue(repo_name: str, issue_number: int, labels: list[str]):
|
176 |
+
"""Dodaje etykiety do issue."""
|
177 |
+
try:
|
178 |
+
user = g.get_user()
|
179 |
+
repo = user.get_repo(repo_name)
|
180 |
+
issue = repo.get_issue(number=int(issue_number))
|
181 |
+
for label in labels:
|
182 |
+
issue.add_to_labels(label)
|
183 |
+
return f"Dodano etykiety do issue #{issue_number}"
|
184 |
+
except GithubException as e:
|
185 |
+
return f"Nie udało się dodać etykiet do issue: {str(e)}"
|
186 |
+
|
187 |
+
|
188 |
+
def close_issue(repo_name: str, issue_number: int):
|
189 |
+
"""Zamyka issue."""
|
190 |
+
try:
|
191 |
+
user = g.get_user()
|
192 |
+
repo = user.get_repo(repo_name)
|
193 |
+
issue = repo.get_issue(number=int(issue_number))
|
194 |
+
issue.edit(state='closed')
|
195 |
+
return f"Issue #{issue_number} zostało zamknięte"
|
196 |
+
except GithubException as e:
|
197 |
+
return f"Nie udało się zamknąć issue: {str(e)}"
|
198 |
+
|
199 |
+
|
200 |
+
def add_comment_to_issue(repo_name: str, issue_number: int, comment: str):
|
201 |
+
"""Dodaje komentarz do issue."""
|
202 |
+
try:
|
203 |
+
user = g.get_user()
|
204 |
+
repo = user.get_repo(repo_name)
|
205 |
+
issue = repo.get_issue(number=int(issue_number))
|
206 |
+
issue.create_comment(body=comment)
|
207 |
+
return f"Dodano komentarz do issue #{issue_number}"
|
208 |
+
except GithubException as e:
|
209 |
+
return f"Nie udało się dodać komentarza do issue: {str(e)}"
|
210 |
+
|
211 |
+
|
212 |
+
def create_release(repo_name: str, tag: str, name: str, message: str):
|
213 |
+
"""Tworzy release."""
|
214 |
+
try:
|
215 |
+
user = g.get_user()
|
216 |
+
repo = user.get_repo(repo_name)
|
217 |
+
release = repo.create_git_release(tag=tag, name=name, message=message)
|
218 |
+
return f"Release utworzone: {release.html_url}"
|
219 |
+
except GithubException as e:
|
220 |
+
return f"Nie udało się utworzyć release: {str(e)}"
|
221 |
+
|
222 |
+
|
223 |
+
def list_releases(repo_name: str):
|
224 |
+
"""Listuje release."""
|
225 |
+
try:
|
226 |
+
user = g.get_user()
|
227 |
+
repo = user.get_repo(repo_name)
|
228 |
+
releases = repo.get_releases()
|
229 |
+
return [{'tag_name': release.tag_name, 'url': release.html_url} for release in releases]
|
230 |
+
except GithubException as e:
|
231 |
+
return f"Nie udało się pobrać listy release: {str(e)}"
|
232 |
+
|
233 |
+
|
234 |
+
def fork_repository(repo_name: str):
|
235 |
+
"""Forkuje repozytorium."""
|
236 |
+
try:
|
237 |
+
user = g.get_user()
|
238 |
+
repo = g.get_repo(repo_name) # Pobierz repozytorium do forkowania
|
239 |
+
fork = user.create_fork(repo)
|
240 |
+
return f"Fork repozytorium utworzony: {fork.html_url}"
|
241 |
+
except GithubException as e:
|
242 |
+
return f"Nie udało się utworzyć forka repozytorium: {str(e)}"
|
243 |
+
|
244 |
+
|
245 |
+
def list_forks(repo_name: str):
|
246 |
+
"""Listuje forki repozytorium."""
|
247 |
+
try:
|
248 |
+
repo = g.get_repo(repo_name) # Pobierz repozytorium, którego forki chcesz wyświetlić
|
249 |
+
forks = repo.get_forks()
|
250 |
+
return [{'full_name': fork.full_name, 'url': fork.html_url} for fork in forks]
|
251 |
+
except GithubException as e:
|
252 |
+
return f"Nie udało się pobrać listy forków: {str(e)}"
|
253 |
+
|
254 |
+
|
255 |
+
def list_files(owner: str, repo_name: str, path: str = ""):
|
256 |
+
"""Listuje pliki w repozytorium."""
|
257 |
+
try:
|
258 |
+
repo = g.get_repo(f"{owner}/{repo_name}")
|
259 |
+
contents = repo.get_contents(path)
|
260 |
+
files = [{'name': content.name, 'path': content.path,
|
261 |
+
'download_url': content.download_url} for content in contents]
|
262 |
+
return files
|
263 |
+
except GithubException as e:
|
264 |
+
return f"Nie udało się pobrać listy plików: {str(e)}"
|
265 |
+
|
266 |
+
|
267 |
+
with gr.Blocks() as demo:
|
268 |
+
with gr.Tab("Repozytoria"):
|
269 |
+
with gr.Row():
|
270 |
+
import_repo_owner = gr.Textbox(label="Właściciel")
|
271 |
+
import_repo_name = gr.Textbox(label="Nazwa repozytorium")
|
272 |
+
import_repo_vcs_url = gr.Textbox(label="URL VCS")
|
273 |
+
import_repo_button = gr.Button("Importuj repozytorium")
|
274 |
+
import_repo_output = gr.Textbox(label="Wynik")
|
275 |
+
import_repo_button.click(
|
276 |
+
import_repository,
|
277 |
+
inputs=[import_repo_owner, import_repo_name,
|
278 |
+
import_repo_vcs_url],
|
279 |
+
outputs=import_repo_output,
|
280 |
+
api_name="import_repository"
|
281 |
+
)
|
282 |
+
|
283 |
+
with gr.Row():
|
284 |
+
create_repo_name = gr.Textbox(label="Nazwa repozytorium")
|
285 |
+
create_repo_button = gr.Button("Utwórz repozytorium")
|
286 |
+
create_repo_output = gr.Textbox(label="Wynik")
|
287 |
+
create_repo_button.click(
|
288 |
+
create_repository,
|
289 |
+
inputs=create_repo_name,
|
290 |
+
outputs=create_repo_output,
|
291 |
+
api_name="create_repository"
|
292 |
+
)
|
293 |
+
|
294 |
+
with gr.Tab("Pliki"):
|
295 |
+
with gr.Row():
|
296 |
+
create_file_repo_name = gr.Textbox(label="Nazwa repozytorium")
|
297 |
+
create_file_branch = gr.Textbox(label="Gałąź")
|
298 |
+
create_file_message = gr.Textbox(label="Wiadomość commita")
|
299 |
+
create_file_content = gr.Textbox(label="Zawartość pliku")
|
300 |
+
create_file_path = gr.Textbox(label="Ścieżka do pliku")
|
301 |
+
create_file_button = gr.Button("Utwórz plik")
|
302 |
+
create_file_output = gr.Textbox(label="Wynik")
|
303 |
+
create_file_button.click(
|
304 |
+
create_file,
|
305 |
+
inputs=[create_file_repo_name, create_file_branch,
|
306 |
+
create_file_message, create_file_content, create_file_path],
|
307 |
+
outputs=create_file_output,
|
308 |
+
api_name="create_file"
|
309 |
+
)
|
310 |
+
|
311 |
+
with gr.Row():
|
312 |
+
get_file_repo_name = gr.Textbox(label="Nazwa repozytorium")
|
313 |
+
get_file_path = gr.Textbox(label="Ścieżka do pliku")
|
314 |
+
get_file_button = gr.Button("Pobierz plik")
|
315 |
+
get_file_output = gr.Textbox(label="Zawartość pliku")
|
316 |
+
get_file_button.click(
|
317 |
+
get_file,
|
318 |
+
inputs=[get_file_repo_name, get_file_path],
|
319 |
+
outputs=get_file_output,
|
320 |
+
api_name="get_file"
|
321 |
+
)
|
322 |
+
|
323 |
+
with gr.Row():
|
324 |
+
delete_file_repo_name = gr.Textbox(label="Nazwa repozytorium")
|
325 |
+
delete_file_branch = gr.Textbox(label="Gałąź")
|
326 |
+
delete_file_path = gr.Textbox(label="Ścieżka do pliku")
|
327 |
+
delete_file_button = gr.Button("Usuń plik")
|
328 |
+
delete_file_output = gr.Textbox(label="Wynik")
|
329 |
+
delete_file_button.click(
|
330 |
+
delete_file,
|
331 |
+
inputs=[delete_file_repo_name, delete_file_branch,
|
332 |
+
delete_file_path],
|
333 |
+
outputs=delete_file_output,
|
334 |
+
api_name="delete_file"
|
335 |
+
)
|
336 |
+
|
337 |
+
with gr.Row():
|
338 |
+
update_file_repo_name = gr.Textbox(label="Nazwa repozytorium")
|
339 |
+
update_file_branch = gr.Textbox(label="Gałąź")
|
340 |
+
update_file_path = gr.Textbox(label="Ścieżka do pliku")
|
341 |
+
update_file_message = gr.Textbox(label="Wiadomość commita")
|
342 |
+
update_file_content = gr.Textbox(label="Nowa zawartość pliku")
|
343 |
+
update_file_button = gr.Button("Zaktualizuj plik")
|
344 |
+
update_file_output = gr.Textbox(label="Wynik")
|
345 |
+
update_file_button.click(
|
346 |
+
update_file,
|
347 |
+
inputs=[update_file_repo_name, update_file_branch,
|
348 |
+
update_file_path, update_file_message, update_file_content],
|
349 |
+
outputs=update_file_output,
|
350 |
+
api_name="update_file"
|
351 |
+
)
|
352 |
+
|
353 |
+
with gr.Tab("Gałęzie"):
|
354 |
+
with gr.Row():
|
355 |
+
list_branches_repo_name = gr.Textbox(label="Nazwa repozytorium")
|
356 |
+
list_branches_button = gr.Button("Listuj gałęzie")
|
357 |
+
list_branches_output = gr.Textbox(label="Lista gałęzi")
|
358 |
+
list_branches_button.click(
|
359 |
+
list_branches,
|
360 |
+
inputs=list_branches_repo_name,
|
361 |
+
outputs=list_branches_output,
|
362 |
+
api_name="list_branches"
|
363 |
+
)
|
364 |
+
|
365 |
+
with gr.Row():
|
366 |
+
create_branch_repo_name = gr.Textbox(label="Nazwa repozytorium")
|
367 |
+
create_branch_source_branch = gr.Textbox(
|
368 |
+
label="Nazwa gałęzi źródłowej")
|
369 |
+
create_branch_new_branch = gr.Textbox(label="Nazwa nowej gałęzi")
|
370 |
+
create_branch_button = gr.Button("Utwórz gałąź")
|
371 |
+
create_branch_output = gr.Textbox(label="Wynik")
|
372 |
+
create_branch_button.click(
|
373 |
+
create_branch,
|
374 |
+
inputs=[create_branch_repo_name, create_branch_source_branch,
|
375 |
+
create_branch_new_branch],
|
376 |
+
outputs=create_branch_output,
|
377 |
+
api_name="create_branch"
|
378 |
+
)
|
379 |
+
|
380 |
+
with gr.Row():
|
381 |
+
delete_branch_repo_name = gr.Textbox(label="Nazwa repozytorium")
|
382 |
+
delete_branch_branch_name = gr.Textbox(label="Nazwa gałęzi")
|
383 |
+
delete_branch_button = gr.Button("Usuń gałąź")
|
384 |
+
delete_branch_output = gr.Textbox(label="Wynik")
|
385 |
+
delete_branch_button.click(
|
386 |
+
delete_branch,
|
387 |
+
inputs=[delete_branch_repo_name, delete_branch_branch_name],
|
388 |
+
outputs=delete_branch_output,
|
389 |
+
api_name="delete_branch"
|
390 |
+
)
|
391 |
+
|
392 |
+
with gr.Tab("Pull Requesty"):
|
393 |
+
with gr.Row():
|
394 |
+
create_pr_repo_name = gr.Textbox(label="Nazwa repozytorium")
|
395 |
+
create_pr_title = gr.Textbox(label="Tytuł")
|
396 |
+
create_pr_body = gr.Textbox(label="Treść")
|
397 |
+
create_pr_base = gr.Textbox(label="Gałąź bazowa")
|
398 |
+
create_pr_head = gr.Textbox(label="Gałąź docelowa")
|
399 |
+
create_pr_button = gr.Button("Utwórz Pull Request")
|
400 |
+
create_pr_output = gr.Textbox(label="Wynik")
|
401 |
+
create_pr_button.click(
|
402 |
+
create_pull_request,
|
403 |
+
inputs=[create_pr_repo_name, create_pr_title,
|
404 |
+
create_pr_body, create_pr_base, create_pr_head],
|
405 |
+
outputs=create_pr_output,
|
406 |
+
api_name="create_pull_request"
|
407 |
+
)
|
408 |
+
|
409 |
+
with gr.Row():
|
410 |
+
list_open_prs_repo_name = gr.Textbox(label="Nazwa repozytorium")
|
411 |
+
list_open_prs_button = gr.Button("Listuj otwarte Pull Requesty")
|
412 |
+
list_open_prs_output = gr.JSON(label="Lista otwartych Pull Requestów")
|
413 |
+
list_open_prs_button.click(
|
414 |
+
list_open_pull_requests,
|
415 |
+
inputs=list_open_prs_repo_name,
|
416 |
+
outputs=list_open_prs_output,
|
417 |
+
api_name="list_open_pull_requests"
|
418 |
+
)
|
419 |
+
|
420 |
+
with gr.Tab("Issue"):
|
421 |
+
with gr.Row():
|
422 |
+
create_issue_repo_name = gr.Textbox(label="Nazwa repozytorium")
|
423 |
+
create_issue_title = gr.Textbox(label="Tytuł")
|
424 |
+
create_issue_body = gr.Textbox(label="Treść")
|
425 |
+
create_issue_button = gr.Button("Utwórz Issue")
|
426 |
+
create_issue_output = gr.Textbox(label="Wynik")
|
427 |
+
create_issue_button.click(
|
428 |
+
create_issue,
|
429 |
+
inputs=[create_issue_repo_name, create_issue_title,
|
430 |
+
create_issue_body],
|
431 |
+
outputs=create_issue_output,
|
432 |
+
api_name="create_issue"
|
433 |
+
)
|
434 |
+
|
435 |
+
with gr.Row():
|
436 |
+
list_issues_repo_name = gr.Textbox(label="Nazwa repozytorium")
|
437 |
+
list_issues_button = gr.Button("Listuj Issue")
|
438 |
+
list_issues_output = gr.JSON(label="Lista Issue")
|
439 |
+
list_issues_button.click(
|
440 |
+
list_issues,
|
441 |
+
inputs=list_issues_repo_name,
|
442 |
+
outputs=list_issues_output,
|
443 |
+
api_name="list_issues"
|
444 |
+
)
|
445 |
+
|
446 |
+
with gr.Row():
|
447 |
+
add_label_repo_name = gr.Textbox(label="Nazwa repozytorium")
|
448 |
+
add_label_issue_number = gr.Number(
|
449 |
+
label="Numer Issue", precision=0)
|
450 |
+
add_label_labels = gr.Textbox(
|
451 |
+
label="Etykiety (oddzielone przecinkami)")
|
452 |
+
add_label_button = gr.Button("Dodaj etykiety")
|
453 |
+
add_label_output = gr.Textbox(label="Wynik")
|
454 |
+
add_label_button.click(
|
455 |
+
lambda repo_name, issue_number, labels: add_label_to_issue(
|
456 |
+
repo_name, issue_number, labels.split(",")),
|
457 |
+
inputs=[add_label_repo_name, add_label_issue_number,
|
458 |
+
add_label_labels],
|
459 |
+
outputs=add_label_output,
|
460 |
+
api_name="add_label_to_issue"
|
461 |
+
)
|
462 |
+
|
463 |
+
with gr.Row():
|
464 |
+
close_issue_repo_name = gr.Textbox(label="Nazwa repozytorium")
|
465 |
+
close_issue_issue_number = gr.Number(
|
466 |
+
label="Numer Issue", precision=0)
|
467 |
+
close_issue_button = gr.Button("Zamknij Issue")
|
468 |
+
close_issue_output = gr.Textbox(label="Wynik")
|
469 |
+
close_issue_button.click(
|
470 |
+
close_issue,
|
471 |
+
inputs=[close_issue_repo_name, close_issue_issue_number],
|
472 |
+
outputs=close_issue_output,
|
473 |
+
api_name="close_issue"
|
474 |
+
)
|
475 |
+
|
476 |
+
with gr.Row():
|
477 |
+
add_comment_repo_name = gr.Textbox(label="Nazwa repozytorium")
|
478 |
+
add_comment_issue_number = gr.Number(
|
479 |
+
label="Numer Issue", precision=0)
|
480 |
+
add_comment_comment = gr.Textbox(label="Komentarz")
|
481 |
+
add_comment_button = gr.Button("Dodaj komentarz")
|
482 |
+
add_comment_output = gr.Textbox(label="Wynik")
|
483 |
+
add_comment_button.click(
|
484 |
+
add_comment_to_issue,
|
485 |
+
inputs=[add_comment_repo_name, add_comment_issue_number,
|
486 |
+
add_comment_comment],
|
487 |
+
outputs=add_comment_output,
|
488 |
+
api_name="add_comment_to_issue"
|
489 |
+
)
|
490 |
+
|
491 |
+
with gr.Tab("Release"):
|
492 |
+
with gr.Row():
|
493 |
+
create_release_repo_name = gr.Textbox(label="Nazwa repozytorium")
|
494 |
+
create_release_tag = gr.Textbox(label="Tag")
|
495 |
+
create_release_name = gr.Textbox(label="Nazwa")
|
496 |
+
create_release_message = gr.Textbox(label="Wiadomość")
|
497 |
+
create_release_button = gr.Button("Utwórz Release")
|
498 |
+
create_release_output = gr.Textbox(label="Wynik")
|
499 |
+
create_release_button.click(
|
500 |
+
create_release,
|
501 |
+
inputs=[create_release_repo_name, create_release_tag,
|
502 |
+
create_release_name, create_release_message],
|
503 |
+
outputs=create_release_output,
|
504 |
+
api_name="create_release"
|
505 |
+
)
|
506 |
+
|
507 |
+
with gr.Row():
|
508 |
+
list_releases_repo_name = gr.Textbox(label="Nazwa repozytorium")
|
509 |
+
list_releases_button = gr.Button("Listuj Release")
|
510 |
+
list_releases_output = gr.JSON(label="Lista Release")
|
511 |
+
list_releases_button.click(
|
512 |
+
list_releases,
|
513 |
+
inputs=list_releases_repo_name,
|
514 |
+
outputs=list_releases_output,
|
515 |
+
api_name="list_releases"
|
516 |
+
)
|
517 |
+
|
518 |
+
with gr.Tab("Forki"):
|
519 |
+
with gr.Row():
|
520 |
+
fork_repo_name = gr.Textbox(label="Nazwa repozytorium")
|
521 |
+
fork_repo_button = gr.Button("Forkuj repozytorium")
|
522 |
+
fork_repo_output = gr.Textbox(label="Wynik")
|
523 |
+
fork_repo_button.click(
|
524 |
+
fork_repository,
|
525 |
+
inputs=fork_repo_name,
|
526 |
+
outputs=fork_repo_output,
|
527 |
+
api_name="fork_repository"
|
528 |
+
)
|
529 |
+
|
530 |
+
with gr.Row():
|
531 |
+
list_forks_repo_name = gr.Textbox(label="Nazwa repozytorium")
|
532 |
+
list_forks_button = gr.Button("Listuj forki")
|
533 |
+
list_forks_output = gr.JSON(label="Lista forków")
|
534 |
+
list_forks_button.click(
|
535 |
+
list_forks,
|
536 |
+
inputs=list_forks_repo_name,
|
537 |
+
outputs=list_forks_output,
|
538 |
+
api_name="list_forks"
|
539 |
+
)
|
540 |
+
|
541 |
+
with gr.Tab("Listowanie plików"):
|
542 |
+
with gr.Row():
|
543 |
+
list_files_owner = gr.Textbox(label="Właściciel")
|
544 |
+
list_files_repo_name = gr.Textbox(label="Nazwa repozytorium")
|
545 |
+
list_files_path = gr.Textbox(
|
546 |
+
label="Ścieżka (opcjonalnie)", value="")
|
547 |
+
list_files_button = gr.Button("Listuj pliki")
|
548 |
+
list_files_output = gr.JSON(label="Lista plików")
|
549 |
+
list_files_button.click(
|
550 |
+
list_files,
|
551 |
+
inputs=[list_files_owner, list_files_repo_name, list_files_path],
|
552 |
+
outputs=list_files_output,
|
553 |
+
api_name="list_files"
|
554 |
+
)
|
555 |
+
|
556 |
+
demo.launch()
|