The Git Repository Manager is a powerful Python module designed to streamline the management of Git repositories and maintain clean working directories. With an array of features, it allows developers to efficiently clone, clean, and manage multiple repositories, all while providing robust error handling and logging capabilities.
- Remove files and folders that do not match specified patterns to maintain a clutter-free workspace.
- Clone multiple repositories specified in a CSV file, supporting both default and custom file patterns.
- Execute custom shell commands after cloning repositories, allowing for automated setup or configuration tasks.
- Utilize concurrent threads for cloning multiple repositories, significantly improving performance and reducing wait times.
- User-friendly command-line interface that guides users through cleanup and cloning operations.
- Comprehensive error logging with detailed context, ensuring a smoother user experience and easier debugging.
- Generate a summary report detailing operations performed, including total repositories cloned and any errors encountered.
- Load and customize settings from a JSON configuration file, enabling quick adjustments to module behavior.
- Safely simulate operations without making any actual changes, allowing users to preview the effects of their commands.
- Specify unique file patterns directly in the CSV file for granular control over what files to keep after cloning.
- Choose specific types of files to clean, such as logs and temporary files, ensuring that your working directory remains organized.
- Control the verbosity of logging output with adjustable logging levels, making it easier to focus on critical information.
- Automatically generate a comprehensive summary of operations, providing insight into what was cloned, deleted, and any issues that occurred.
- Python 3.6 or higher
- Git must be installed and available in your system's PATH
-
Clone this repository:
git clone https://github.com/yourusername/git-repo-manager.git cd git-repo-manager -
(Optional) Create a virtual environment:
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
-
Install required packages:
pip install -r requirements.txt
The module uses a JSON configuration file (config.json) to load default settings. Here’s a sample configuration:
{
"default_csv_file": "repositories.csv",
"clean_directory": ".",
"default_patterns": ["*.txt", "*.log", "*~"],
"log_level": "info",
"max_workers": 4
}You can customize the settings to suit your needs. If the configuration file is not found, the module will revert to default values.
To run the Git Repository Manager, execute the following command in your terminal:
python git_repo_manager.pyYou will be presented with an interactive menu to choose from the following options:
- Clean Files and Folders
- Clone Repositories from CSV
- Generate Summary Report
- Exit
The CSV file for cloning repositories should have the following format:
repo_url|target_directory|is_active|depth|custom_patterns
https://github.com/user/repo.git|./repo|true|1|*.py,*.txtrepo_url: The URL of the Git repository.target_directory: The directory where the repository will be cloned.is_active: Whether the repository should be cloned (true/false).depth: The depth of the clone operation.custom_patterns: Patterns for files to keep after cloning.
The module logs operations and errors to git_repo_manager.log. Adjust the log level in the configuration file as needed to control verbosity.
We welcome contributions! Please feel free to submit issues or pull requests to enhance this module.
This project is licensed under the MIT License. See the LICENSE file for details.
For questions or support, feel free to reach out via GitHub Issues.
Thank you for using the Git Repository Manager! Happy coding! 🎉
### Key Enhancements:
- **Visual Elements**: Added emojis to make sections more engaging.
- **Feature Details**: Each feature now has a concise description for clarity.
- **Sections**: Organized sections with headings for better readability.
- **Contact Information**: Provided a way for users to get support.
Feel free to customize it further to match your project’s branding or specific needs!