diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md index b135a93..9d24c9d 100644 --- a/ARCHITECTURE.md +++ b/ARCHITECTURE.md @@ -1,189 +1,189 @@ -# 🏗 Architecture du Migration Tool +# 🏗 Migration Tool Architecture -## Vue d'ensemble +## Overview -Le Migration Tool a Ă©tĂ© conçu selon les principes de dĂ©veloppement suivants : +The Migration Tool has been designed according to the following development principles: -- **Single Responsibility Principle (SRP)** : Chaque classe a une responsabilitĂ© unique -- **Open/Closed Principle** : Ouvert Ă  l'extension, fermĂ© Ă  la modification -- **Dependency Inversion** : DĂ©pendance sur des abstractions, pas des implĂ©mentations -- **ExtensibilitĂ©** : FacilitĂ© d'ajout de nouveaux providers +- **Single Responsibility Principle (SRP)**: Each class has a unique responsibility +- **Open/Closed Principle**: Open to extension, closed to modification +- **Dependency Inversion**: Dependency on abstractions, not implementations +- **Extensibility**: Ease of adding new providers -## Structure du projet +## Project Structure ``` -GiteaToGithubMigrator/ -├── providers/ # Providers pour diffĂ©rents services Git +GitMigrator/ +├── providers/ # Providers for different Git services │ ├── __init__.py -│ ├── base.py # Classes abstraites et modĂšles -│ ├── factory.py # Factory pour crĂ©er les providers -│ ├── source/ # Providers source (Gitea, GitLab, etc.) +│ ├── base.py # Abstract classes and models +│ ├── factory.py # Factory to create providers +│ ├── source/ # Source providers (Gitea, GitLab, etc.) │ │ ├── __init__.py │ │ ├── gitea.py │ │ └── gitlab.py -│ └── destination/ # Providers destination (GitHub, GitLab, etc.) +│ └── destination/ # Destination providers (GitHub, GitLab, etc.) │ ├── __init__.py │ ├── github.py │ └── gitlab.py -├── core/ # Logique mĂ©tier centrale +├── core/ # Core business logic │ ├── __init__.py -│ ├── config.py # Gestion de la configuration -│ └── migration_engine.py # Moteur de migration -├── ui/ # Interface utilisateur +│ ├── config.py # Configuration management +│ └── migration_engine.py # Migration engine +├── ui/ # User interface │ ├── __init__.py │ └── interactive_selector.py -├── main.py # Point d'entrĂ©e principal -└── run.sh # Script de lancement +├── main.py # Main entry point +└── run.sh # Launch script ``` -## ResponsabilitĂ©s des modules +## Module Responsibilities ### 🔧 Providers (providers/) #### Base (`providers/base.py`) -- **Repository** : ModĂšle de donnĂ©es unifiĂ© pour tous les providers -- **SourceProvider** : Interface abstraite pour les providers source -- **DestinationProvider** : Interface abstraite pour les providers destination -- **Exceptions** : Exceptions spĂ©cialisĂ©es pour la gestion d'erreurs +- **Repository**: Unified data model for all providers +- **SourceProvider**: Abstract interface for source providers +- **DestinationProvider**: Abstract interface for destination providers +- **Exceptions**: Specialized exceptions for error handling #### Factory (`providers/factory.py`) -- CrĂ©ation dynamique des instances de providers -- Enregistrement de nouveaux providers -- Validation des types de providers disponibles +- Dynamic creation of provider instances +- Registration of new providers +- Validation of available provider types #### Source Providers (`providers/source/`) -- **Gitea** : ImplĂ©mentation pour Gitea -- **GitLab** : ImplĂ©mentation pour GitLab (exemple d'extensibilitĂ©) +- **Gitea**: Implementation for Gitea +- **GitLab**: Implementation for GitLab (extensibility example) #### Destination Providers (`providers/destination/`) -- **GitHub** : ImplĂ©mentation pour GitHub -- **GitLab** : ImplĂ©mentation pour GitLab (exemple d'extensibilitĂ©) +- **GitHub**: Implementation for GitHub +- **GitLab**: Implementation for GitLab (extensibility example) ### ⚙ Core (`core/`) #### Configuration (`core/config.py`) -- Gestion centralisĂ©e de la configuration -- Support multi-providers via variables d'environnement -- Validation des paramĂštres de configuration +- Centralized configuration management +- Multi-provider support via environment variables +- Configuration parameter validation #### Migration Engine (`core/migration_engine.py`) -- Orchestration du processus de migration -- Gestion des repositories temporaires -- ExĂ©cution des commandes Git -- Logging et rapport de progression +- Migration process orchestration +- Temporary repository management +- Git command execution +- Logging and progress reporting ### 🎹 UI (`ui/`) #### Interactive Selector (`ui/interactive_selector.py`) -- Interface interactive pour la sĂ©lection de repositories -- Navigation au clavier -- SystĂšme de renommage -- Affichage paginated +- Interactive interface for repository selection +- Keyboard navigation +- Renaming system +- Paginated display -## ExtensibilitĂ© +## Extensibility -### Ajouter un nouveau provider source +### Adding a new source provider -1. **CrĂ©er le fichier** : `providers/source/mon_provider.py` +1. **Create the file**: `providers/source/my_provider.py` ```python from typing import List, Optional from ..base import SourceProvider, Repository, ProviderError, ConfigurationError -class MonProviderSourceProvider(SourceProvider): +class MyProviderSourceProvider(SourceProvider): def _validate_config(self) -> None: - # Valider la configuration spĂ©cifique + # Validate specific configuration pass def get_user_repositories(self) -> List[Repository]: - # RĂ©cupĂ©rer les repos de l'utilisateur + # Retrieve user repositories pass def get_accessible_repositories(self) -> List[Repository]: - # RĂ©cupĂ©rer tous les repos accessibles + # Retrieve all accessible repositories pass def get_repository_info(self, owner: str, name: str) -> Optional[Repository]: - # RĂ©cupĂ©rer les infos d'un repo spĂ©cifique + # Retrieve specific repository information pass def get_authenticated_clone_url(self, repository: Repository) -> str: - # GĂ©nĂ©rer l'URL de clone authentifiĂ©e + # Generate authenticated clone URL pass ``` -2. **Enregistrer le provider** dans `providers/factory.py` : +2. **Register the provider** in `providers/factory.py`: ```python -from .source.mon_provider import MonProviderSourceProvider +from .source.my_provider import MyProviderSourceProvider class ProviderFactory: _source_providers: Dict[str, Type[SourceProvider]] = { 'gitea': GiteaSourceProvider, 'gitlab': GitLabSourceProvider, - 'mon_provider': MonProviderSourceProvider, # Nouveau provider + 'my_provider': MyProviderSourceProvider, # New provider } ``` -3. **Ajouter la configuration** dans `core/config.py` : +3. **Add configuration** in `core/config.py`: ```python def _load_source_config(self) -> Dict[str, Any]: - if self.source_provider == 'mon_provider': + if self.source_provider == 'my_provider': return { - 'url': os.getenv('MON_PROVIDER_URL'), - 'token': os.getenv('MON_PROVIDER_TOKEN'), - 'username': os.getenv('MON_PROVIDER_USERNAME') + 'url': os.getenv('MY_PROVIDER_URL'), + 'token': os.getenv('MY_PROVIDER_TOKEN'), + 'username': os.getenv('MY_PROVIDER_USERNAME') } - # ... autres providers + # ... other providers ``` -### Ajouter un nouveau provider destination +### Adding a new destination provider -Le processus est identique, mais dans `providers/destination/`. +The process is identical, but in `providers/destination/`. -## Patterns utilisĂ©s +## Design Patterns Used ### 1. Abstract Factory Pattern -- `ProviderFactory` crĂ©e des instances de providers -- Permet d'ajouter de nouveaux providers sans modifier le code existant +- `ProviderFactory` creates provider instances +- Allows adding new providers without modifying existing code ### 2. Strategy Pattern -- Les providers implĂ©mentent des stratĂ©gies diffĂ©rentes pour accĂ©der aux APIs -- Le moteur de migration utilise ces stratĂ©gies de maniĂšre transparente +- Providers implement different strategies to access APIs +- Migration engine uses these strategies transparently ### 3. Template Method Pattern -- `SourceProvider` et `DestinationProvider` dĂ©finissent le squelette des opĂ©rations -- Les implĂ©mentations concrĂštes remplissent les dĂ©tails spĂ©cifiques +- `SourceProvider` and `DestinationProvider` define operation skeletons +- Concrete implementations fill in specific details ### 4. Dependency Injection -- Les providers sont injectĂ©s dans `MigrationEngine` -- Facilite les tests et la flexibilitĂ© +- Providers are injected into `MigrationEngine` +- Facilitates testing and flexibility ## Configuration -### Variables d'environnement +### Environment Variables ```bash -# Provider source +# Source provider SOURCE_PROVIDER=gitea|gitlab GITEA_URL=https://gitea.example.com GITEA_TOKEN=your_token GITEA_USERNAME=your_username -# Provider destination +# Destination provider DESTINATION_PROVIDER=github|gitlab GITHUB_TOKEN=your_token GITHUB_USERNAME=your_username ``` -### ExtensibilitĂ© de la configuration +### Configuration Extensibility -Pour ajouter un nouveau provider, il suffit d'ajouter les variables correspondantes et de modifier `MigrationConfig`. +To add a new provider, simply add corresponding variables and modify `MigrationConfig`. ## Tests -### Structure recommandĂ©e +### Recommended Structure ``` tests/ @@ -201,16 +201,16 @@ tests/ └── sample_repositories.json ``` -### Exemples de tests +### Test Examples ```python -# Test d'un provider +# Provider test def test_gitea_provider_validates_config(): config = {'url': 'https://gitea.com', 'token': 'token', 'username': 'user'} provider = GiteaSourceProvider(config) assert provider.base_url == 'https://gitea.com' -# Test du moteur de migration +# Migration engine test def test_migration_engine_handles_errors(): source = Mock(spec=SourceProvider) dest = Mock(spec=DestinationProvider) @@ -218,41 +218,41 @@ def test_migration_engine_handles_errors(): # Test error handling... ``` -## Bonnes pratiques +## Best Practices -### 1. Gestion d'erreurs -- Exceptions spĂ©cialisĂ©es pour chaque type d'erreur -- Logging appropriĂ© Ă  chaque niveau -- Gestion gracieuse des Ă©checs +### 1. Error Handling +- Specialized exceptions for each error type +- Appropriate logging at each level +- Graceful failure handling ### 2. Documentation -- Docstrings pour toutes les mĂ©thodes publiques -- Type hints pour la clartĂ© du code -- README et documentation d'architecture +- Docstrings for all public methods +- Type hints for code clarity +- README and architecture documentation -### 3. SĂ©curitĂ© -- Tokens jamais loggĂ©s -- Nettoyage des repositories temporaires -- Validation des entrĂ©es utilisateur +### 3. Security +- Tokens never logged +- Temporary repository cleanup +- User input validation ### 4. Performance -- Pagination pour les listes de repositories -- ParallĂ©lisation possible des migrations -- Gestion efficace de la mĂ©moire +- Pagination for repository lists +- Possible migration parallelization +- Efficient memory management -## Évolutions futures +## Future Evolutions -### FonctionnalitĂ©s potentielles -- Migration incrĂ©mentale (seulement les changements) -- Support des webhooks -- Interface web -- API REST -- Migration de mĂ©tadonnĂ©es (issues, pull requests) +### Potential Features +- Incremental migration (changes only) +- Webhook support +- Web interface +- REST API +- Metadata migration (issues, pull requests) -### Nouveaux providers +### New Providers - Bitbucket - Azure DevOps - Sourcehut - Codeberg -L'architecture actuelle permet d'ajouter facilement ces fonctionnalitĂ©s sans restructuration majeure. \ No newline at end of file +The current architecture allows easy addition of these features without major restructuring. \ No newline at end of file diff --git a/README.md b/README.md index 24d1465..7f9e9f3 100644 --- a/README.md +++ b/README.md @@ -1,341 +1,341 @@ -# 🚀 Outil de Migration Git Multi-Providers - -Cet projet fournit un outil pratique et modulable pour migrer automatiquement vos repositories entre diffĂ©rents providers Git. - -## ✹ FonctionnalitĂ©s - -- **Migration multi-providers** : Supporte plusieurs providers source et destination -- **Providers supportĂ©s** : - - **Sources** : Gitea, GitLab - - **Destinations** : GitHub, GitLab -- **Mode interactif par dĂ©faut** : Interface Ă©lĂ©gante pour sĂ©lectionner/dĂ©selectionner les repos Ă  migrer -- **Vision complĂšte** : Voit tous les repositories accessibles (vos repos + ceux d'organisations) -- **SĂ©lection intelligente** : Vos repositories sont prĂ©-sĂ©lectionnĂ©s, les autres sont dĂ©sĂ©lectionnĂ©s par dĂ©faut -- **Renommage intelligent** : PossibilitĂ© de renommer les repositories lors de la migration -- **Migration sĂ©lective** : Choisissez spĂ©cifiquement quels repositories migrer en ligne de commande -- **Interface en ligne de commande** : Interface colorĂ©e et intuitive avec navigation au clavier -- **Logging complet** : Suivi dĂ©taillĂ© des opĂ©rations avec fichier de log -- **Gestion des erreurs** : Robuste avec gestion gracieuse des erreurs -- **Architecture extensible** : Facilement extensible pour ajouter de nouveaux providers +# 🚀 Multi-Provider Git Migration Tool + +This project provides a practical and modular tool to automatically migrate your repositories between different Git providers. + +## ✹ Features + +- **Multi-provider migration**: Supports multiple source and destination providers +- **Supported providers**: + - **Sources**: Gitea, GitLab + - **Destinations**: GitHub, GitLab +- **Interactive mode by default**: Elegant interface to select/deselect repositories to migrate +- **Complete vision**: See all accessible repositories (your repos + those from organizations) +- **Smart selection**: Your repositories are pre-selected, others are deselected by default +- **Smart renaming**: Ability to rename repositories during migration +- **Selective migration**: Choose specifically which repositories to migrate via command line +- **Command line interface**: Colorful and intuitive interface with keyboard navigation +- **Complete logging**: Detailed operation tracking with log file +- **Error handling**: Robust with graceful error management +- **Extensible architecture**: Easily extensible to add new providers ## 🛠 Installation -1. **Clonez le repository** : +1. **Clone the repository**: ```bash -git clone https://github.com/votre-username/GitMigrator.git +git clone https://github.com/your-username/GitMigrator.git cd GitMigrator ``` -2. **Configuration automatique** : +2. **Automatic configuration**: ```bash ./run.sh --setup ``` -Le script va automatiquement : -- CrĂ©er un environnement virtuel Python -- Installer toutes les dĂ©pendances -- CrĂ©er le fichier de configuration `.env` +The script will automatically: +- Create a Python virtual environment +- Install all dependencies +- Create the `.env` configuration file -Cela crĂ©era un fichier `.env` que vous devrez remplir avec vos informations selon les providers choisis. +This will create a `.env` file that you will need to fill with your information according to the chosen providers. ## 🔧 Configuration -### Configuration avec support multi-instances +### Configuration with multi-instance support ```env # Gitea Source Configuration -GITEA_SOURCE_URL=https://votre-instance-gitea-source.com -GITEA_SOURCE_TOKEN=votre_token_gitea_source -GITEA_SOURCE_USERNAME=votre_nom_utilisateur_gitea_source +GITEA_SOURCE_URL=https://your-gitea-source-instance.com +GITEA_SOURCE_TOKEN=your_gitea_source_token +GITEA_SOURCE_USERNAME=your_gitea_source_username # Gitea Destination Configuration -GITEA_DEST_URL=https://votre-instance-gitea-dest.com -GITEA_DEST_TOKEN=votre_token_gitea_dest -GITEA_DEST_USERNAME=votre_nom_utilisateur_gitea_dest +GITEA_DEST_URL=https://your-gitea-dest-instance.com +GITEA_DEST_TOKEN=your_gitea_dest_token +GITEA_DEST_USERNAME=your_gitea_dest_username # GitLab Source Configuration GITLAB_SOURCE_URL=https://gitlab-source.com -GITLAB_SOURCE_TOKEN=votre_token_gitlab_source -GITLAB_SOURCE_USERNAME=votre_nom_utilisateur_gitlab_source +GITLAB_SOURCE_TOKEN=your_gitlab_source_token +GITLAB_SOURCE_USERNAME=your_gitlab_source_username # GitLab Destination Configuration GITLAB_DEST_URL=https://gitlab-dest.com -GITLAB_DEST_TOKEN=votre_token_gitlab_dest -GITLAB_DEST_USERNAME=votre_nom_utilisateur_gitlab_dest +GITLAB_DEST_TOKEN=your_gitlab_dest_token +GITLAB_DEST_USERNAME=your_gitlab_dest_username # GitHub Configuration (same for source and destination - only one instance) -GITHUB_TOKEN=votre_token_github -GITHUB_USERNAME=votre_nom_utilisateur_github +GITHUB_TOKEN=your_github_token +GITHUB_USERNAME=your_github_username ``` -**📝 Instructions :** -1. **Multi-instances** : Vous pouvez configurer diffĂ©rentes instances du mĂȘme provider -2. **MĂȘme instance** : Utilisez les mĂȘmes credentials pour source et destination si c'est la mĂȘme instance -3. **Migration flexible** : Supports GitLab → GitLab, Gitea → Gitea, etc. entre diffĂ©rentes instances -4. **Configuration minimale** : Configurez seulement les providers source/destination que vous utilisez -5. L'outil vous demandera interactivement quel provider utiliser comme source et destination +**📝 Instructions:** +1. **Multi-instances**: You can configure different instances of the same provider +2. **Same instance**: Use the same credentials for source and destination if it's the same instance +3. **Flexible migration**: Supports GitLab → GitLab, Gitea → Gitea, etc. between different instances +4. **Minimal configuration**: Configure only the source/destination providers that you use +5. The tool will interactively ask which provider to use as source and destination -## 🔑 Configuration des tokens +## 🔑 Token Configuration -### Token Gitea -1. Allez dans **Settings** → **Applications** → **Generate New Token** -2. Donnez un nom au token et sĂ©lectionnez les permissions : - - `repo` (accĂšs complet aux repositories) - - `user` (accĂšs aux informations utilisateur) +### Gitea Token +1. Go to **Settings** → **Applications** → **Generate New Token** +2. Give the token a name and select permissions: + - `repo` (full access to repositories) + - `user` (access to user information) -### Token GitLab -1. Allez dans **Settings** → **Access Tokens** ou **User Settings** → **Access Tokens** -2. CrĂ©ez un **Personal Access Token** avec les permissions : - - `read_api` (lecture des informations API) - - `read_repository` (lecture des repositories) - - `write_repository` (Ă©criture des repositories - pour destination) +### GitLab Token +1. Go to **Settings** → **Access Tokens** or **User Settings** → **Access Tokens** +2. Create a **Personal Access Token** with permissions: + - `read_api` (read API information) + - `read_repository` (read repositories) + - `write_repository` (write repositories - for destination) -### Token GitHub -1. Allez dans **Settings** → **Developer settings** → **Personal access tokens** → **Tokens (classic)** -2. Cliquez sur **Generate new token (classic)** -3. SĂ©lectionnez les permissions : - - `repo` (accĂšs complet aux repositories privĂ©s) - - `public_repo` (accĂšs aux repositories publics) +### GitHub Token +1. Go to **Settings** → **Developer settings** → **Personal access tokens** → **Tokens (classic)** +2. Click on **Generate new token (classic)** +3. Select permissions: + - `repo` (full access to private repositories) + - `public_repo` (access to public repositories) -## 🚀 Utilisation +## 🚀 Usage -AprĂšs avoir configurĂ© vos tokens dans le fichier `.env`, utilisez le script de lancement : +After configuring your tokens in the `.env` file, use the launch script: -### Migration interactive (par dĂ©faut) +### Interactive migration (default) ```bash ./run.sh ``` -### Migration automatique de tous vos repos +### Automatic migration of all your repos ```bash ./run.sh --no-interactive ``` -### Migration de repositories spĂ©cifiques +### Migration of specific repositories ```bash -./run.sh --repos mon-repo autre-repo +./run.sh --repos my-repo another-repo ``` -### Lister les repositories disponibles +### List available repositories ```bash ./run.sh --list ``` -### Mode verbose (plus de dĂ©tails) +### Verbose mode (more details) ```bash ./run.sh --verbose ``` -> **💡 Alternative** : Vous pouvez aussi utiliser directement `python main.py` si vous avez activĂ© l'environnement virtuel (`source venv/bin/activate`) +> **💡 Alternative**: You can also use `python main.py` directly if you have activated the virtual environment (`source venv/bin/activate`) -## 🎯 Mode Interactif +## 🎯 Interactive Mode -Le mode interactif (activĂ© par dĂ©faut) offre une **interface utilisateur Ă©lĂ©gante** pour sĂ©lectionner prĂ©cisĂ©ment quels repositories migrer : +Interactive mode (enabled by default) offers an **elegant user interface** to precisely select which repositories to migrate: ```bash -./run.sh # Mode interactif par dĂ©faut +./run.sh # Interactive mode by default ``` -### ContrĂŽles dans l'interface interactive : -- **↑↓** : Naviguer entre les repositories -- **←→** : Changer de page (si beaucoup de repos) -- **ESPACE** : Cocher/dĂ©cocher un repository -- **A** : SĂ©lectionner tous les repositories -- **N** : DĂ©sĂ©lectionner tous les repositories -- **ENTRÉE** : Confirmer la sĂ©lection et passer au renommage (optionnel) -- **Q** : Quitter sans migrer - -### Interface de renommage : -AprĂšs la sĂ©lection, l'outil propose de renommer les repositories : -- **Y** : Ouvrir l'interface de renommage -- **N/ENTRÉE** : Conserver les noms actuels -- **Validation automatique** des noms de repositories pour le provider de destination - -### FonctionnalitĂ©s : -- ✅ **Checkboxes visuelles** avec Ă©mojis -- đŸ‘€ **Distinction propriĂ©taire** : Vos repos vs repos d'autres utilisateurs -- 🎯 **SĂ©lection intelligente** : Vos repos prĂ©-sĂ©lectionnĂ©s par dĂ©faut -- 📋 **Tri intelligent** : Vos repos en premier, puis les autres, tous par ordre alphabĂ©tique -- ✏ **Renommage optionnel** : PossibilitĂ© de renommer les repos sur le provider de destination -- 📄 **Pagination automatique** (15 repos par page) -- 🎹 **Interface colorĂ©e** avec mise en surbrillance et sĂ©parateurs visuels -- 📊 **Compteur en temps rĂ©el** des repos sĂ©lectionnĂ©s -- 🔒 **Indicateurs visuels** (privĂ©/public) -- 📝 **Descriptions tronquĂ©es** pour un affichage propre - -## 📋 Exemples d'utilisation - -### Exemple 1 : Migration interactive (dĂ©faut) +### Controls in the interactive interface: +- **↑↓**: Navigate between repositories +- **←→**: Change page (if many repos) +- **SPACE**: Check/uncheck a repository +- **A**: Select all repositories +- **N**: Deselect all repositories +- **ENTER**: Confirm selection and proceed to renaming (optional) +- **Q**: Quit without migrating + +### Renaming interface: +After selection, the tool offers to rename repositories: +- **Y**: Open renaming interface +- **N/ENTER**: Keep current names +- **Automatic validation** of repository names for the destination provider + +### Features: +- ✅ **Visual checkboxes** with emojis +- đŸ‘€ **Owner distinction**: Your repos vs other users' repos +- 🎯 **Smart selection**: Your repos pre-selected by default +- 📋 **Smart sorting**: Your repos first, then others, all alphabetically ordered +- ✏ **Optional renaming**: Ability to rename repos on the destination provider +- 📄 **Automatic pagination** (15 repos per page) +- 🎹 **Colorful interface** with highlighting and visual separators +- 📊 **Real-time counter** of selected repos +- 🔒 **Visual indicators** (private/public) +- 📝 **Truncated descriptions** for clean display + +## 📋 Usage Examples + +### Example 1: Interactive migration (default) ```bash -# 1. Configurez vos providers dans .env -# 2. Lancez l'outil +# 1. Configure your providers in .env +# 2. Launch the tool ./run.sh -# L'outil vous demandera : -# - Quel provider utiliser comme source -# - Quel provider utiliser comme destination -# - Puis vous pourrez sĂ©lectionner les repos Ă  migrer +# The tool will ask you: +# - Which provider to use as source +# - Which provider to use as destination +# - Then you can select repos to migrate ``` -### Exemple 2 : Migration automatique +### Example 2: Automatic migration ```bash -# Migre tous vos repositories automatiquement -# (aprĂšs sĂ©lection interactive des providers) +# Migrate all your repositories automatically +# (after interactive provider selection) ./run.sh --no-interactive ``` -### Exemple 3 : Migration sĂ©lective +### Example 3: Selective migration ```bash -# Migre seulement les repositories spĂ©cifiĂ©s -# (aprĂšs sĂ©lection interactive des providers) -./run.sh --repos projet-web api-backend +# Migrate only specified repositories +# (after interactive provider selection) +./run.sh --repos web-project api-backend ``` -### Exemple 4 : Migration depuis une organisation +### Example 4: Migration from an organization ```bash -# Migre un repository d'une organisation (fonctionne avec tous les providers) -./run.sh --repos mon-org/projet-important +# Migrate a repository from an organization (works with all providers) +./run.sh --repos my-org/important-project ``` -### Exemple 5 : Premier lancement (configuration) +### Example 5: First launch (configuration) ```bash -# 1. Setup initial - crĂ©e le fichier .env template +# 1. Initial setup - creates .env template file ./run.sh --setup -# 2. Éditez le fichier .env avec vos credentials (au moins 2 providers) +# 2. Edit the .env file with your credentials (at least 2 providers) nano .env -# 3. Lancez l'outil - il vous demandera quels providers utiliser +# 3. Launch the tool - it will ask which providers to use ./run.sh -# 4. Pour lister les repos disponibles (aprĂšs sĂ©lection du provider source) +# 4. To list available repos (after source provider selection) ./run.sh --list ``` -### Exemple 6 : Migration avec renommage +### Example 6: Migration with renaming ```bash -# 1. Lancer le mode interactif +# 1. Launch interactive mode ./run.sh -# 2. SĂ©lectionner les providers source et destination -# 3. SĂ©lectionner les repos Ă  migrer -# 4. Choisir "Y" pour le renommage -# 5. Renommer les repos un par un -# - Appuyer sur ENTRÉE pour garder le nom original -# - Taper un nouveau nom pour renommer -# 6. Confirmer et lancer la migration +# 2. Select source and destination providers +# 3. Select repos to migrate +# 4. Choose "Y" for renaming +# 5. Rename repos one by one +# - Press ENTER to keep original name +# - Type new name to rename +# 6. Confirm and start migration ``` -## 📊 RĂ©sultats +## 📊 Results -L'outil affiche un rĂ©sumĂ© dĂ©taillĂ© Ă  la fin : -- ✅ Nombre de migrations rĂ©ussies -- ❌ Nombre de migrations Ă©chouĂ©es -- 📝 DĂ©tail par repository +The tool displays a detailed summary at the end: +- ✅ Number of successful migrations +- ❌ Number of failed migrations +- 📝 Detail per repository -Tous les logs sont Ă©galement sauvegardĂ©s dans `migration.log`. +All logs are also saved in `migration.log`. -## 🔧 Structure du projet +## 🔧 Project Structure ``` GitMigrator/ -├── main.py # Script principal -├── core/ # Logique mĂ©tier centrale -│ ├── config.py # Gestion de la configuration multi-providers -│ └── migration_engine.py # Moteur de migration -├── providers/ # Providers pour diffĂ©rents services Git -│ ├── base.py # Classes abstraites et modĂšles -│ ├── factory.py # Factory pour crĂ©er les providers -│ ├── source/ # Providers source -│ │ ├── gitea.py # Support Gitea -│ │ └── gitlab.py # Support GitLab -│ └── destination/ # Providers destination -│ ├── github.py # Support GitHub -│ └── gitlab.py # Support GitLab -├── ui/ # Interface utilisateur +├── main.py # Main script +├── core/ # Core business logic +│ ├── config.py # Multi-provider configuration management +│ └── migration_engine.py # Migration engine +├── providers/ # Providers for different Git services +│ ├── base.py # Abstract classes and models +│ ├── factory.py # Factory to create providers +│ ├── source/ # Source providers +│ │ ├── gitea.py # Gitea support +│ │ └── gitlab.py # GitLab support +│ └── destination/ # Destination providers +│ ├── github.py # GitHub support +│ └── gitlab.py # GitLab support +├── ui/ # User interface │ └── interactive_selector.py -├── requirements.txt # DĂ©pendances Python -├── .env # Configuration (Ă  crĂ©er) +├── requirements.txt # Python dependencies +├── .env # Configuration (to create) └── README.md # Documentation ``` -## 🌟 Providers supportĂ©s +## 🌟 Supported Providers -### Providers Source -- **Gitea** : Instances Gitea (self-hosted ou cloud) -- **GitLab** : GitLab.com ou instances GitLab self-hosted +### Source Providers +- **Gitea**: Gitea instances (self-hosted or cloud) +- **GitLab**: GitLab.com or self-hosted GitLab instances -### Providers Destination -- **GitHub** : GitHub.com -- **GitLab** : GitLab.com ou instances GitLab self-hosted +### Destination Providers +- **GitHub**: GitHub.com +- **GitLab**: GitLab.com or self-hosted GitLab instances -### Combinaisons possibles +### Possible Combinations - Gitea → GitHub - Gitea → GitLab - GitLab → GitHub -- GitLab → GitLab (migration entre instances) +- GitLab → GitLab (migration between instances) -## ⚠ PrĂ©requis +## ⚠ Prerequisites - Python 3.7+ -- Git installĂ© sur votre systĂšme -- AccĂšs aux APIs des providers source et destination -- Tokens d'authentification valides pour les providers +- Git installed on your system +- Access to source and destination provider APIs +- Valid authentication tokens for providers -## 🛡 SĂ©curitĂ© +## 🛡 Security -- Les tokens sont stockĂ©s dans un fichier `.env` (ajoutez-le Ă  `.gitignore`) -- Les URLs d'authentification ne sont jamais loggĂ©es -- Nettoyage automatique des repositories temporaires +- Tokens are stored in a `.env` file (add it to `.gitignore`) +- Authentication URLs are never logged +- Automatic cleanup of temporary repositories -## 🐛 RĂ©solution de problĂšmes +## 🐛 Troubleshooting -### Erreur d'authentification -- VĂ©rifiez que vos tokens sont valides et ont les bonnes permissions -- Assurez-vous que les noms d'utilisateur correspondent -- VĂ©rifiez que les URLs des providers sont correctes +### Authentication error +- Check that your tokens are valid and have the right permissions +- Make sure usernames match +- Verify that provider URLs are correct -### Erreur de clonage -- VĂ©rifiez votre connexion internet -- Assurez-vous que Git est installĂ© et accessible +### Clone error +- Check your internet connection +- Make sure Git is installed and accessible -### Repository dĂ©jĂ  existant -- L'outil vĂ©rifie automatiquement l'existence sur le provider de destination -- Les repositories existants sont ignorĂ©s avec un avertissement +### Repository already exists +- The tool automatically checks existence on the destination provider +- Existing repositories are ignored with a warning -### Provider non supportĂ© ou non configurĂ© -- VĂ©rifiez que vos providers sont bien configurĂ©s dans le fichier .env -- Assurez-vous d'avoir au moins 2 providers configurĂ©s -- Providers disponibles : gitea, gitlab, github -- L'outil vous indiquera quels providers sont configurĂ©s au dĂ©marrage +### Unsupported or unconfigured provider +- Check that your providers are properly configured in the .env file +- Make sure you have at least 2 providers configured +- Available providers: gitea, gitlab, github +- The tool will indicate which providers are configured at startup ## 📝 Logs -Tous les dĂ©tails d'exĂ©cution sont sauvegardĂ©s dans `migration.log` : -- Timestamps des opĂ©rations -- SĂ©lection des providers source et destination -- DĂ©tails des erreurs -- Statistiques de migration -- Informations complĂštes sur le processus de migration +All execution details are saved in `migration.log`: +- Operation timestamps +- Source and destination provider selection +- Error details +- Migration statistics +- Complete information about the migration process -## 🚀 ExtensibilitĂ© +## 🚀 Extensibility -L'architecture modulaire permet d'ajouter facilement de nouveaux providers : +The modular architecture allows easy addition of new providers: -1. **CrĂ©er un nouveau provider source** dans `providers/source/` -2. **CrĂ©er un nouveau provider destination** dans `providers/destination/` -3. **Enregistrer le provider** dans `providers/factory.py` -4. **Ajouter la configuration** dans `core/config.py` +1. **Create a new source provider** in `providers/source/` +2. **Create a new destination provider** in `providers/destination/` +3. **Register the provider** in `providers/factory.py` +4. **Add configuration** in `core/config.py` -Voir `ARCHITECTURE.md` pour plus de dĂ©tails sur l'ajout de nouveaux providers. +See `ARCHITECTURE.md` for more details on adding new providers. ## đŸ€ Contribution -Les contributions sont les bienvenues ! N'hĂ©sitez pas Ă  : -- Signaler des bugs -- Proposer des amĂ©liorations -- Soumettre des pull requests -- Ajouter de nouveaux providers +Contributions are welcome! Feel free to: +- Report bugs +- Suggest improvements +- Submit pull requests +- Add new providers -## 📄 Licence +## 📄 License -Ce projet est sous licence MIT. Voir le fichier LICENSE pour plus de dĂ©tails. \ No newline at end of file +This project is under MIT license. See the LICENSE file for more details. \ No newline at end of file diff --git a/core/config.py b/core/config.py index ee31031..e775e23 100644 --- a/core/config.py +++ b/core/config.py @@ -136,7 +136,7 @@ class MigrationConfig: dest_configured = any(self.get_available_destination_providers().values()) return source_configured and dest_configured - # MĂ©thodes dĂ©prĂ©ciĂ©es pour compatibilitĂ© (si jamais utilisĂ©es ailleurs) + # Deprecated methods for compatibility (if ever used elsewhere) def get_provider_config(self, provider_type: str) -> Dict[str, Any]: """DEPRECATED: Use get_source_provider_config or get_destination_provider_config""" return self.get_source_provider_config(provider_type) diff --git a/ui/interactive_selector.py b/ui/interactive_selector.py index 405c99d..3ab52e8 100644 --- a/ui/interactive_selector.py +++ b/ui/interactive_selector.py @@ -80,7 +80,7 @@ class InteractiveSelector: # Add separator when transitioning from own repos to others if last_owner_type == "own" and current_owner_type == "others": - print(f" {Fore.LIGHTBLACK_EX}{'─' * 50} Autres repositories {'─' * 10}{Style.RESET_ALL}") + print(f" {Fore.LIGHTBLACK_EX}{'─' * 50} Other repositories {'─' * 10}{Style.RESET_ALL}") last_owner_type = current_owner_type @@ -189,7 +189,7 @@ class InteractiveSelector: print(f"║ ✏ RENAME REPOSITORIES ║") print(f"║ ║") print(f"║ Press ENTER to keep current name, or type new name ║") - print(f"║ Repository names should be valid GitHub repo names ║") + print(f"║ Repository names should be valid for destination provider ║") print(f"╚═══════════════════════════════════════════════════════════════╝{Style.RESET_ALL}") print() @@ -204,7 +204,7 @@ class InteractiveSelector: print(f" Source: {Fore.BLUE}{owner}/{original_name}{Style.RESET_ALL} {private}") # Get new name from user - new_name = input(f" GitHub name [{Fore.GREEN}{original_name}{Style.RESET_ALL}]: ").strip() + new_name = input(f" Destination name [{Fore.GREEN}{original_name}{Style.RESET_ALL}]: ").strip() # Validate and use new name if new_name: @@ -218,7 +218,7 @@ class InteractiveSelector: new_name = original_name print(f" {Fore.CYAN}â„č Keeping original name: {original_name}{Style.RESET_ALL}") - # Update repository with new GitHub name + # Update repository with new destination name repo.github_name = new_name renamed_repos.append(repo) print() @@ -242,11 +242,11 @@ class InteractiveSelector: return renamed_repos def _is_valid_repo_name(self, name: str) -> bool: - """Validate GitHub repository name""" + """Validate repository name for destination provider""" if not name: return False - # GitHub repo name rules (simplified) + # Common repository name rules (simplified) if len(name) > 100: return False @@ -307,13 +307,13 @@ class InteractiveSelector: print(f" ‱ {Fore.BLUE}{owner}/{name}{Style.RESET_ALL} {private}") # Ask if user wants to rename repositories - print(f"\n{Fore.YELLOW}📝 Voulez-vous changer le nom de certains repos sur GitHub ?{Style.RESET_ALL}") - print(f"{Fore.CYAN}[Y/y] Oui - Interface de renommage{Style.RESET_ALL}") - print(f"{Fore.CYAN}[N/n ou ENTER] Non - Conserver les noms actuels{Style.RESET_ALL}") + print(f"\n{Fore.YELLOW}📝 Do you want to change the name of some repos on the destination?{Style.RESET_ALL}") + print(f"{Fore.CYAN}[Y/y] Yes - Renaming interface{Style.RESET_ALL}") + print(f"{Fore.CYAN}[N/n or ENTER] No - Keep current names{Style.RESET_ALL}") - choice = input(f"\n{Fore.YELLOW}Votre choix: {Style.RESET_ALL}").strip().lower() + choice = input(f"\n{Fore.YELLOW}Your choice: {Style.RESET_ALL}").strip().lower() - if choice == 'y' or choice == 'yes' or choice == 'oui': + if choice == 'y' or choice == 'yes': selected_repos = self._rename_repositories_interface(selected_repos) print(f"\n{Fore.CYAN}🚀 Starting migration...{Style.RESET_ALL}\n")