Open Benjamin-Loison opened 9 months ago
#!/usr/bin/python3
# https://github.com/Benjamin-Loison/gitea/issues/9
import requests
import json
from tqdm import tqdm
import math
GITEA_INSTANCE_URL = 'https://codeberg.org'
# With `read:{issue,repository}` scopes.
TOKEN = 'CENSORED'
REPOSITORY_FULL_NAME = 'Benjamin_Loison/Improve_websites_thanks_to_open_source'
headers = {
'Authorization': f'token {TOKEN}'
}
def getApi(url, params = {}):
response = requests.get(f'{GITEA_INSTANCE_URL}/api/v1/{url}', params, headers = headers)
return response.json()
LIMIT = 50
repositoryIssueParams = {
'limit': LIMIT,
}
repositoryIssues = []
repository = getApi(f'repos/{REPOSITORY_FULL_NAME}')
if repository.get('message') == 'The target couldn\'t be found.':
print(f'Repository {GITEA_INSTANCE_URL}/{REPOSITORY_FULL_NAME} not found!')
exit(1)
# See [Benjamin-Loison/gitea/issues/60](https://github.com/Benjamin-Loison/gitea/issues/60).
openIssuesCount = repository['open_issues_count']
for state, total in [('closed', None), ('open', math.ceil(openIssuesCount / LIMIT))]:
repositoryIssueParams['state'] = state
with tqdm(total = total, desc = f'{state.title()} issues page') as progressBar:
while True:
repositoryIssueParams['page'] = progressBar.n + 1
repositoryIssuePage = getApi(f'repos/{REPOSITORY_FULL_NAME}/issues', repositoryIssueParams)
if repositoryIssuePage == []:
break
repositoryIssues += repositoryIssuePage
progressBar.update(1)
repositoryIssuesStr = json.dumps(repositoryIssues, indent = 4)
#print(repositoryIssuesStr)
import pyperclip
pyperclip.copy(repositoryIssuesStr)
Using .url
is too long to fit the whole line on the screen.
Above script does not seem to copy to clipboard on Debian 12 GNOME (this is probably due to Wayland) at least in Pyzo but seems to work fine when run in a gnome-terminal
. In fact it does not work in a terminal too, current workaround consists in uncommenting print
and executing in terminal and piping to xclip -selection clipboard
(clip
alias in my case).
Would help Community_detection_in_graphs/issues/10.
Note the new enum Exact and Fuzzy:
What about attachments not mentioned in the body? Can we deduce to what issue comment they were uploaded to?
For instance:
prodezarts.com
Benjamin_Loison/Improve_websites_thanks_to_open_source#18.Same issue with https://codeberg.org/api/swagger#/issue/issueListIssues.
Establishing a workaround based on download everything seems to make sense.
As I do not find, even with DuckDuckGo and Google search engines, a solution to export repository issues. Let us try to import on my own Gitea instance. Maybe it is a Codeberg intended limitation.
Maybe incorrect scopes, as there are two interesting ones:
issue
andrepository
.Is there a dedicated option in Gitea for importing from Forgejo instance? As it seems to be such one on Codeberg.
With above both scopes (they are both required), I am able to import from Codeberg to Codeberg and then there is no issue anymore searching
prodezarts.com
for instance.Are issue ids kept? I do not have this feeling at least with Improve_websites_thanks_to_open_source_issues/issues/300.
Description
For instance: https://codeberg.org/Benjamin_Loison/Improve_websites_thanks_to_open_source/issues?type=all&state=open&labels=&milestone=0&project=0&assignee=0&poster=0&q=github.com
+69
Gitea Version
Not read.
Can you reproduce the bug on the Gitea demo site?
Yes
Log Gist
No response
Screenshots
No response
Git Version
No response
Operating System
No response
How are you running Gitea?
Not read.
Database
None