This application processes a JSON file containing commit URLs, extracts unique repository URLs, and executes a bash script (mirroring.sh) for each URL. It uses Python for data processing and logging.
- Loads JSON data containing commit URLs.
- Extracts unique repository URLs from the JSON.
- Executes a bash script (mirroring.sh) for each URL.
- Logs all actions and errors to both a log file and the console.
-
Python 3.7 or higher
Ensure Python is installed on your system.
Download PythonTested on Python 3.12.2
-
Bash The application executes a bash script (
mirroring.sh). Ensure bash is installed and accessible. -
JSON Data File
JSON file with the following structure:[ { "commit_URL": "https://github.com/user/repo/commit/abc123", "other_field": "content" }, { "commit_URL": "https://github.com/user/repo/commit/abc123", "other_field": "content" }, ]
-
Clone the repository:
git clone https://github.com/manhtdd/mirroring.git cd mirroring -
Run the Application:
python -m main
DATA_PATH: Path to the JSON file containing commit URLs.LOGS_DIR: Directory where logs will be stored (default:./logs).BASH_SCRIPT_PATH: Path to the bash script to execute (default:./mirroring.sh).
- Logs are stored in the
logs/mirroring.logfile. - Logs include timestamp, log level, function name, line number, and messages.
Ensure the mirroring.sh script is executable:
chmod +x mirroring.shReplace <github-token> with your PAT & <username> with your username:
#!/bin/bash
NEW_REPO_URL="https://<username>:<github-token>@gitlab.com/<username>/$OLD_REPO_NAME.git" # Replace with your new repo URLSave the following JSON in a file (e.g., data.json):
[
{"commit_URL": "https://github.com/user/repo/commit/abc123"},
{"commit_URL": "https://github.com/user/repo/commit/def456"},
{"commit_URL": "https://github.com/another/repo/commit/ghi789"}
]