| .env.example | Emerges fully-formed and working thanks to lots of help from Louis and Chris | |
| .gitignore | Ignore .env | |
| .python-version | Use uv | |
| import_issues.py | Working simple import script - unless issue title is too long | |
| move_issue.py | Fix regression: reintroduce erroneously-removed variable | |
| pyproject.toml | Use uv | |
| README.md | Improve heading | |
| uv.lock | Use uv | |
Forgejo Helpers
Fork info
Forked from: https://git.agaric.com/agaric/forgejo_helpers
Changes
-
FIXED: Regression in move_issue.py introduced in ab23c86 where the required
new_issue_numbervariable was deleted, resulting in the comment copying code failing. -
CHANGED: Added uv lock for required dependencies.
(I was unable to issue pull requests for these are Agaric’s Forgejo instance does not accept sign ups.)
Setup
git clone https://codeberg.org/aral/forgego-helpers.git
cd forgejo_helpers
cp .env.example .env
Edit the .env file to add your Forgejo instance’s domain (e.g., codeberg.org) and your access token (with read/write permissions for issues).
To run with uv
uv is a Python version/virtual environment/dependency management tool written in Rust (similar to the combination of nvm and npm for Node.js). You can install it using Brew with
brew install uv. It’s basically makes Python usable ;)
Run uv sync to ensure all dependencies are installed, etc.
Then, e.g., to Move an issue from kitten/app to kitten/site on codeberg.org:
uv run move_issue.py kitten app 299 kitten site
(i.e, substitute uv run for python).
Note: I’ve only tested/used the move_issue.py script.
For help with the changes, please contact mail@ar.al.
Original readme
Setup:
git clone https://git.agaric.com/agaric/forgejo_helpers.git
cd forgejo_helpers
cp .env.example .env
Set your instance URL there and your API token (with permission to read and write issues at least).
Import issues
Put your issues in a CSV with the title as the first column. Include a column label (such as "Issue") as the first row will be skipped. No other columns from the CSV will be imported, although it should not be hard to extend this script to import a description (as first comment). Do not include issue titles greater than 255 characters; this will result in a KeyError: 'html_url' that really means the server gave a 500 error.
python import_issues.py example-org example-repo stories.csv
Move issues
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:
python move_issue.py 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.
It would be easy to change it so these could be environment variables so that only the issue number needs to be passed in, and it would be pretty easy to allow passing in a list of issues, but this has not been done yet.
It would not be too hard to allow separate source and destination instances and auth tokens, either, which could give this script a reason for being even after #1280 - [FEAT] transfer issues to another repo - forgejo lands!
Although it is probably best to prioritize bulk export and import of issues even over moving single issues, as that tests the API the best and covers the broadest use cases.
Troubleshooting
"The target couldn't be found."
404 errors like that probably mean the user whose API token you are using (for Agaric, we typically use tobor) does not have permission to see your repository/organization; the organization needs to be public or the user needs to be added to it.