Compare commits
No commits in common. "24a99ee2d407571c5d96efc45a84de901359107b" and "0af686e64c55d0a581066ebff60b73533f1f6631" have entirely different histories.
24a99ee2d4
...
0af686e64c
2 changed files with 1 additions and 58 deletions
|
@ -19,7 +19,7 @@ Currently this is the only script:
|
|||
Use it by passing in the source owner, the source repository, the issue number, the destination owner, and the destination repository, like so:
|
||||
|
||||
```bash
|
||||
python move_issue.py old-example-org old-example-repo 123 new-example-org new-example-repo
|
||||
python move_issue old-example-org old-example-repo 123 new-example-org new-example-repo
|
||||
```
|
||||
|
||||
All five parameters are needed, even if it is within the same organization.
|
||||
|
|
|
@ -1,57 +0,0 @@
|
|||
import csv
|
||||
import os
|
||||
import sys
|
||||
from dotenv import load_dotenv
|
||||
import requests
|
||||
|
||||
load_dotenv()
|
||||
|
||||
FORGEJO_INSTANCE = os.getenv("FORGEJO_INSTANCE", "https://codeberg.org")
|
||||
FORGEJO_API_TOKEN = os.getenv("FORGEJO_API_TOKEN")
|
||||
|
||||
API_GET_ISSUE = "{instance}/api/v1/repos/{owner}/{repo}/issues/{index}"
|
||||
API_GET_ISSUE = "{instance}/api/v1/repos/{owner}/{repo}/issues/{index}"
|
||||
API_PATCH_ISSUE = "{instance}/api/v1/repos/{owner}/{repo}/issues/{index}"
|
||||
API_CREATE_ISSUE = "{instance}/api/v1/repos/{owner}/{repo}/issues"
|
||||
API_GET_COMMENTS = "{instance}/api/v1/repos/{owner}/{repo}/issues/{index}/comments"
|
||||
API_CREATE_COMMENT = "{instance}/api/v1/repos/{owner}/{repo}/issues/{index}/comments"
|
||||
|
||||
def import_issues(owner, repo, csv_filename):
|
||||
|
||||
issues = []
|
||||
with open(csv_filename) as csvfile:
|
||||
rows = csv.reader(csvfile)
|
||||
rows.pop(0)
|
||||
for row in rows:
|
||||
issues.append(row[0])
|
||||
|
||||
|
||||
print(f"Creating issue {json_response['title']} now…")
|
||||
|
||||
for issue in issues:
|
||||
new_issue = {
|
||||
"title": issue
|
||||
}
|
||||
|
||||
create_issue_url = API_CREATE_ISSUE.format(instance=FORGEJO_INSTANCE, owner=owner, repo=repo)
|
||||
# print(create_issue_url)
|
||||
headers = {"Authorization": f"token {FORGEJO_API_TOKEN}"}
|
||||
created_response = requests.post(create_issue_url, headers=headers, json=new_issue)
|
||||
|
||||
json_response = created_response.json()
|
||||
message = json_response.pop('message', False)
|
||||
if message:
|
||||
print(message)
|
||||
sys.exit("Error creating issue.")
|
||||
else:
|
||||
new_issue_url = json_response['html_url']
|
||||
print(f"Issue created: {new_issue_url}")
|
||||
|
||||
|
||||
if __name__=="__main__":
|
||||
# '0' comes in as move_issue.py when this is called as `python move_issue.py`
|
||||
owner = sys.argv[1]
|
||||
repo = sys.argv[2]
|
||||
csv_filename = sys.argv[2]
|
||||
|
||||
import_issues(owner, repo, csvfile)
|
Loading…
Reference in a new issue