Added README and requirements.txt
This commit is contained in:
parent
b5a2843a86
commit
160e3b9f88
111
gitlab2gitea/README.md
Normal file
111
gitlab2gitea/README.md
Normal file
@ -0,0 +1,111 @@
|
||||
# GitLab to Gitea Migration Script
|
||||
|
||||
**Note: This script is still work in progess!**
|
||||
|
||||
## Description
|
||||
This script is designed to migrate repositories from GitLab to Gitea.
|
||||
|
||||
## Author(s)
|
||||
- [Enrico Ludwig](https://git.zion-networks.de/eludwig) <[enrico.ludwig@zion-networks.de](mailto:enrico.ludwig@zion-networks.de?subject=Gitlab%20to%20Gitea%20migration%20script)>
|
||||
|
||||
## License
|
||||
MIT License. For more details, refer to the [LICENSE](https://git.zion-networks.de/ZionNetworks/linux-bash-scripts/src/branch/main/LICENSE) file.
|
||||
|
||||
## Precedence of Settings
|
||||
Settings will be applied in the following order:
|
||||
1. Command-line arguments
|
||||
2. `.env` file
|
||||
3. Environment variables
|
||||
4. Default values
|
||||
|
||||
## Usage
|
||||
```sh
|
||||
python3 gitlab2gitea.py [options]
|
||||
```
|
||||
|
||||
## Options
|
||||
| Option | Description |
|
||||
| ------------------------------------------- | -------------------------------------------------------------------------------------- |
|
||||
| `--help` | Show help message and exit. |
|
||||
| `--gitlab-token <GITLAB_TOKEN>` | GitLab access token. |
|
||||
| `--gitlab-url <GITLAB_URL>` | GitLab URL. |
|
||||
| `--gitlab-api-version <GITLAB_API_VERSION>` | GitLab API version (default: v4). |
|
||||
| `--gitea-token <GITEA_TOKEN>` | Gitea access token. |
|
||||
| `--gitea-url <GITEA_URL>` | Gitea URL. |
|
||||
| `--gitea-api-version <GITEA_API_VERSION>` | Gitea API version (default: v1). |
|
||||
| `--no-create-missing-groups` | Do not create missing groups on Gitea (default: False). |
|
||||
| `--no-create-missing-users` | Do not create missing users on Gitea (default: False). |
|
||||
| `--no-create-missing-projects` | Do not create missing projects on Gitea (default: False). |
|
||||
| `--no-update-existing-groups` | Do not update existing groups on Gitea (default: False). |
|
||||
| `--no-update-existing-users` | Do not update existing users on Gitea (default: False). |
|
||||
| `--no-update-existing-projects` | Do not update existing projects on Gitea (default: False). |
|
||||
| `--only-groups` | Migrate only groups (default: False). |
|
||||
| `--only-users` | Migrate only users (default: False). |
|
||||
| `--only-projects` | Migrate only projects (default: False). |
|
||||
| `--quiet` | Enable quiet mode (default: False). |
|
||||
| `--debug` | Enable debug mode (default: False). |
|
||||
| `--trace` | Enable trace mode (default: False). |
|
||||
| `--dry-run` | Enable dry-run mode (default: False). |
|
||||
| `--log-file <LOG_FILE>` | Log file (default: gitlab2gitea.log). If not set, logs will be only printed to stdout. |
|
||||
| `--append-log` | Append to log file instead of overwriting (default: False). |
|
||||
|
||||
## Example
|
||||
```sh
|
||||
python3 gitlab2gitea.py \
|
||||
--gitlab-url <GITLAB_URL> \
|
||||
--gitlab-token <GITLAB_TOKEN> \
|
||||
--gitea-url <GITEA_URL> \
|
||||
--gitea-token <GITEA_TOKEN>
|
||||
```
|
||||
|
||||
## Environment Variables
|
||||
|
||||
| Option | Description |
|
||||
| ----------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `GITLAB_URL` | The full URL to your Gitlab instance (e.g. https://gitlab.myhost.com) |
|
||||
| `GITLAB_TOKEN` | The access token from your Gitlab instance ([see here](https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html#create-a-personal-access-token)) |
|
||||
| `GITLAB_API_VERSION` | The API version to be used (default: v4) - do not change unless you know, what you do. |
|
||||
| `GITEA_URL` | The full URL to your Gitea instance (e.g. https://gitea.myhost.com) |
|
||||
| `GITEA_TOKEN` | The access token from your Gitea instance (example URL to find the settings: https://gitea.myhost.com/user/settings/applications) |
|
||||
| `GITEA_API_VERSION` | The API version to be used (default: v1) - do not change unless you know, what you do. |
|
||||
| `NO_CREATE_MISSING_GROUPS` | Set to prevent creation of groups in Gitea (default: `0`, allowed: `0` or `1`) |
|
||||
| `NO_CREATE_MISSING_USERS` | Set to prevent creation of users in Gitea (default: `0`, allowed: `0` or `1`) |
|
||||
| `NO_CREATE_MISSING_PROJECTS` | Set to prevent creation of projects in Gitea (default: `0`, allowed: `0` or `1`) |
|
||||
| `NO_UPDATE_EXISTING_GROUPS` | Set to prevent updating of existing groups in Gitea (default: `0`, allowed: `0` or `1`) |
|
||||
| `NO_UPDATE_EXISTING_USERS` | Set to prevent updating of existing users in Gitea (default: `0`, allowed: `0` or `1`) |
|
||||
| `NO_UPDATE_EXISTING_PROJECTS` | Set to prevent updating of existing projects in Gitea (default: `0`, allowed: `0` or `1`) |
|
||||
| `ONLY_GROUPS` | Set to only migrate groups to Gitea (default: `0`, allowed: `0` or `1`) |
|
||||
| `ONLY_USERS` | Set to only migrate users to Gitea (default: `0`, allowed: `0` or `1`) |
|
||||
| `ONLY_PROJECTS` | Set to only migrate projects to Gitea (default: `0`, allowed: `0` or `1`) |
|
||||
| `DEBUG` | Enable or disable debug output (default: `0`, allowed: `0` or `1`) |
|
||||
| `TRACE` | Enable or disable trace (or verbose) output (default: `0`, allowed: `0` or `1`) |
|
||||
| `DRY_RUN` | Only do a dry run, no actual migration will be performed and no data will be changed (default: `0`, allowed: `0` or `1`) |
|
||||
| `LOG_FILE` | Path to the log file (default: `gitlab2gitea.log`, allowed: a valid file path or `""` to disable file logging) |
|
||||
| `APPEND_LOG` | Enable or disable appending log output to the specified log file (default: `0`, allowed: `0` or `1`) |
|
||||
| `QUIET` | Enable or disable quiet mode (default: `0`, allowed: `0` or `1`) |
|
||||
|
||||
## Notes & Caveats
|
||||
- **Mutually Exclusive Options**: Some options cannot be used together, such as:
|
||||
- `--only-groups` and `--only-users`
|
||||
- `--only-groups` and `--only-projects`
|
||||
- `--only-users` and `--only-projects`
|
||||
|
||||
- **Reserved Usernames**: Gitea has reserved usernames like "ghost" and "notifications"; these should be avoided.
|
||||
|
||||
## Script Overview
|
||||
The script performs the following actions:
|
||||
1. **Reading Configuration**: Fetch configuration from environment variables, `.env` file, and command-line arguments.
|
||||
2. **Check Endpoints**: Validates access to GitLab and Gitea endpoints.
|
||||
3. **Migration**:
|
||||
- **Groups**: Compares, creates, and updates groups between GitLab and Gitea.
|
||||
- **Users**: Compares, creates, and updates users between GitLab and Gitea.
|
||||
- **Projects**: (Implementation pending for creating and updating projects).
|
||||
|
||||
---
|
||||
|
||||
**Note**: For complete usage, ensure you have the required Python packages by running:
|
||||
```sh
|
||||
pip install -r requirements.txt
|
||||
```
|
||||
|
||||
For any issues, please refer to the contact details provided in the author's contact information section.
|
@ -1,7 +1,7 @@
|
||||
# Description: Script to migrate repositories from GitLab to Gitea
|
||||
# Author: Enrico Ludwig <enrico.ludwig@zion-networks.de>
|
||||
# Version: 1.0
|
||||
# Date: 2024-07-14
|
||||
# Date: 2024-07-18
|
||||
# License: MIT (see https://git.zion-networks.de/ZionNetworks/linux-bash-scripts/src/branch/main/LICENSE)
|
||||
#
|
||||
# Precedence of settings: arguments > .env file > environment variables > default values
|
||||
@ -29,6 +29,9 @@
|
||||
# --override-users Override existing users on Gitea (default: False) - not implemented yet
|
||||
# --override-projects Override existing projects on Gitea (default: False) - not implemented yet
|
||||
#
|
||||
# --skip-empty-groups Skip empty groups (default: False) - not implemented yet
|
||||
# --skip-empty-projects Skip empty projects (default: False) - not implemented yet
|
||||
#
|
||||
# --only-groups Migrate only groups (default: False)
|
||||
# --only-users Migrate only users (default: False)
|
||||
# --only-projects Migrate only projects (default: False)
|
||||
|
1
gitlab2gitea/requirements.txt
Normal file
1
gitlab2gitea/requirements.txt
Normal file
@ -0,0 +1 @@
|
||||
requests
|
Reference in New Issue
Block a user