All source listed below is under MIT license if no LICENSE file stating different is available.

Gitea Repository Antispam

Solution for repositories created by spammers.

This script deletes Gitea repositories that are likely created by spammers based on the following criteria:

  • Repository has no commits

This project is a professional, ready-to-use script for managing Gitea repositories. It allows you to list, check, and delete repositories based on customizable criteria. Designed for efficiency and security, it supports environment variable configuration, command-line parameters, and token-based authentication.


Features

  • List all accessible repositories
  • Check for existing commits
  • Delete repositories that meet specific criteria
  • Safe dry-run mode for testing
  • Easy token management via Gitea's application settings

Requirements

  • Python 3.x
  • requests library (install via pip install requests)

Environment Variables (Optional)

You can create a .env file in the project directory to set default values for the script. This file is optional but recommended for convenience.

.env file format

GITEA_USERNAME=your_username
GITEA_PASSWORD=your_password
GITEA_API_URL=https://gitea.example.com/api/v1
GITEA_API_TOKEN=your_token

Notes:

  • The .env file is purely for default values; command-line arguments override these settings.
  • You should generate a personal access token in Gitea under /user/settings/applications. Use this token for authentication to avoid exposing your password.

Usage

Example Gitea URL

https://gitea.example.com/api/v1

Creating a Token in Gitea

  1. Log in to your Gitea account.
  2. Navigate to /user/settings/applications.
  3. Create a new application token.
  4. Use this token as the GITEA_API_TOKEN in your environment or command-line.

Command-line Parameters

python main.py \
  --gitea-username your_username \
  --gitea-password your_password \
  --gitea-api-url https://gitea.example.com \
  --gitea-api-token your_token \
  --dry-run
  • --dry-run: Perform a simulation without making any changes (default mode).
  • --no-dry-run: Execute actual deletions and modifications.

Default Behavior

If environment variables are set or .env exists, you can run the script without parameters:

python main.py

The script will run with a configuration time of approximately 10 minutes, suitable for large repositories or extensive operations.


Contact

For support or questions, contact:
retoor retoor@molodetz.nl


License

This project is licensed under the MIT License. Feel free to use, modify, and distribute as you see fit.


Summary

This is a complete, professional solution for managing your Gitea repositories efficiently and securely. No contributions are needed—it's ready to deploy and use in your environment.

.gitignore
gitea_api.py
main.py
read_env.py
README.md
requirements.txt