diff --git a/README.md b/README.md index f19d968..4ff1b4c 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Gitea GitHub Sync -Enrich all GitHub pull mirrors owned by a Gitea account with repository metadata, +Enrich all GitHub pull mirrors on your own Gitea instance with repository metadata, topics, issues and comments that native Git mirroring does not synchronize. The script discovers repositories automatically and derives each GitHub source @@ -34,7 +34,19 @@ Use `gitea-github-sync.conf.example` as the template for overwriting its tokens. Set your Gitea URL and token, the account owner, and a GitHub token where needed. An empty `GITEA_OWNER` selects the token's account. -The example contains deployment-specific defaults; replace them for your server. +Set `GITEA_URL` to **your own Gitea instance** in the configuration: + +```bash +GITEA_URL='https://gitea.example.com' +GITEA_OWNER='' +``` + +Replace the example address with your server's URL. For an installation under +a subdirectory, use e.g. `GITEA_URL='https://example.com/gitea'`. +Do not append `/api/v1`. There is no built-in Gitea server address; an absent or +empty `GITEA_URL` stops the script before any API request. `GITEA_OWNER` may be +left empty to detect the authenticated account, or set to an owner to scan. + Restrict the configuration to its owner: ```bash @@ -100,4 +112,4 @@ mock API tests, including multiple mirrors, idempotency, throttling and quiet mo Download the script or the complete bundle from [GitHub Releases](https://github.com/adamzend/gitea-github-sync/releases). -The first release is **v1.0.0**. +The latest release is **v1.0.1**, which requires an explicitly configured Gitea URL. diff --git a/README.txt b/README.txt index f9eaf6d..b09add0 100644 --- a/README.txt +++ b/README.txt @@ -28,6 +28,15 @@ selects the account identified by GITEA_TOKEN. GITHUB_TOKEN is optional for public sources and required for private sources. It is recommended for large scans because of GitHub API rate limits. +GITEA_URL must be the address of YOUR Gitea instance, for example: + GITEA_URL='https://gitea.example.com' +For a server mounted below a path: + GITEA_URL='https://example.com/gitea' +Replace these examples with your actual server address. Do not append /api/v1. +There is no default Gitea server. A missing or empty GITEA_URL stops the script +before API requests. Existing configurations with GITEA_URL already set remain +valid. The example leaves GITEA_OWNER empty to detect the token's account. + The Gitea token must allow account/repository reads and repository settings, issues and comment writes. Its account must be able to edit imported comments. The configuration is trusted Bash code. Restrict its permissions: @@ -106,7 +115,7 @@ with output managed by the scheduler instead of detaching with --apply-quiet. Configuration reference ----------------------- -GITEA_URL: Base web URL, default https://git.an0n.eu. Include any path prefix, +GITEA_URL: Required base web URL of your own Gitea instance; no default. Include any path prefix, for example https://example.org/gitea. Do not append /api/v1. GITEA_OWNER: Owner to scan; empty means the authenticated token account. GITEA_TOKEN: Required Gitea API token; distinct from the GitHub token. diff --git a/gitea-github-sync.conf.example b/gitea-github-sync.conf.example index e38a6ae..f21373b 100644 --- a/gitea-github-sync.conf.example +++ b/gitea-github-sync.conf.example @@ -2,11 +2,14 @@ GITEA_TOKEN='REPLACE_WITH_GITEA_TOKEN' # Optional for public GitHub repositories; recommended to increase rate limits. GITHUB_TOKEN='' -GITEA_URL='https://git.an0n.eu' +# Required: replace this example with your own Gitea instance URL. +# Include a web path prefix if used, e.g. https://example.com/gitea. +# Do not append /api/v1. There is no built-in server address. +GITEA_URL='https://gitea.example.com' # Leave empty to discover the account from GITEA_TOKEN, or specify an owner. # All repositories owned by this account are scanned, including private ones # visible to the token. Collaborator repositories owned by others are excluded. -GITEA_OWNER='adam' +GITEA_OWNER='' # Source owners and repository names are derived from each mirror's original_url. GITHUB_API='https://api.github.com' GITHUB_API_VERSION='2026-03-10' diff --git a/gitea-github-sync.sh b/gitea-github-sync.sh index c2a17de..a7408e1 100755 --- a/gitea-github-sync.sh +++ b/gitea-github-sync.sh @@ -72,7 +72,7 @@ if [[ "${GITEA_SYNC_QUIET_WORKER:-}" == 1 ]]; then trap 'rc=$?; log "Background worker finished: PID=$$, exit_status=$rc"' EXIT log "Background worker started: PID=$$" fi -: "${GITEA_URL:=https://git.an0n.eu}" +[[ -n "${GITEA_URL:-}" ]] || die "GITEA_URL is required in $CONFIG_FILE (for example https://gitea.example.com)" : "${GITEA_OWNER:=}" : "${GITHUB_API:=https://api.github.com}" : "${GITHUB_API_VERSION:=2026-03-10}" @@ -91,7 +91,8 @@ for cmd in curl jq flock mktemp rm cmp cat date mkdir awk sleep; do done GITEA_URL=${GITEA_URL%/} GITHUB_API=${GITHUB_API%/} -[[ "$GITEA_URL" == http://* || "$GITEA_URL" == https://* ]] || die "Invalid GITEA_URL" +[[ "$GITEA_URL" =~ ^https?://[^/?#[:space:]@]+(/[^?#[:space:]]*)?$ ]] || + die "Invalid GITEA_URL: use your instance base URL, including any path prefix, without credentials, query or fragment" [[ "$GITHUB_API" == http://* || "$GITHUB_API" == https://* ]] || die "Invalid GITHUB_API" exec 9>"$LOCK_FILE" || die "Cannot open lock: $LOCK_FILE" flock -n 9 || die "Another synchronization is running"