Skip to main content

guts_migrate/
lib.rs

1//! # Guts Migration Tools
2//!
3//! This crate provides migration tools for importing repositories from GitHub, GitLab,
4//! and Bitbucket to the Guts decentralized code collaboration platform.
5//!
6//! ## Features
7//!
8//! - **GitHub Migration**: Full repository migration including issues, PRs, releases
9//! - **GitLab Migration**: Project migration with merge requests and issues
10//! - **Bitbucket Migration**: Repository migration with pull requests
11//! - **Verification**: Post-migration verification to ensure data integrity
12//! - **Progress Tracking**: Real-time progress reporting with ETA
13//!
14//! ## Example
15//!
16//! ```rust,ignore
17//! use guts_migrate::{GitHubMigrator, MigrationConfig, MigrationOptions};
18//!
19//! #[tokio::main]
20//! async fn main() -> anyhow::Result<()> {
21//!     let config = MigrationConfig {
22//!         source_repo: "owner/repo".to_string(),
23//!         guts_url: "https://api.guts.network".to_string(),
24//!         guts_token: Some("guts_xxx".to_string()),
25//!     };
26//!
27//!     let options = MigrationOptions::default()
28//!         .with_issues(true)
29//!         .with_pull_requests(true)
30//!         .with_releases(true);
31//!
32//!     let migrator = GitHubMigrator::new("github_token", config)?;
33//!     let report = migrator.migrate(options).await?;
34//!
35//!     report.print_summary();
36//!     Ok(())
37//! }
38//! ```
39
40pub mod bitbucket;
41pub mod client;
42pub mod error;
43pub mod github;
44pub mod gitlab;
45pub mod progress;
46pub mod types;
47pub mod verify;
48
49// Re-export main types
50pub use bitbucket::BitbucketMigrator;
51pub use client::GutsClient;
52pub use error::{MigrationError, Result};
53pub use github::GitHubMigrator;
54pub use gitlab::GitLabMigrator;
55pub use progress::{MigrationProgress, ProgressCallback};
56pub use types::*;
57pub use verify::MigrationVerifier;
58
59/// Version of the migration tools.
60pub const VERSION: &str = env!("CARGO_PKG_VERSION");
61
62#[cfg(test)]
63mod tests {
64    use super::*;
65
66    #[test]
67    fn test_migration_options_builder() {
68        let options = MigrationOptions::default()
69            .with_issues(true)
70            .with_pull_requests(true)
71            .with_releases(false)
72            .with_wiki(false);
73
74        assert!(options.migrate_issues);
75        assert!(options.migrate_pull_requests);
76        assert!(!options.migrate_releases);
77        assert!(!options.migrate_wiki);
78    }
79
80    #[test]
81    fn test_migration_report_summary() {
82        let mut report = MigrationReport::new();
83        report.repo_created = true;
84        report.git_mirrored = true;
85        report.issues_migrated = 10;
86        report.prs_migrated = 5;
87
88        assert!(report.is_successful());
89        assert_eq!(report.total_items_migrated(), 15);
90    }
91}