1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// src/types.rs
use structopt::StructOpt;
#[derive(Debug, StructOpt, Clone)]
pub enum Operation {
/// Clone repositories from source to target directory
Clone,
/// Pull latest changes for all repositories in source directory
Pull,
/// Push local changes for all repositories in source directory
Push,
/// List all repositories and their status
Status,
/// Run arbitrary git command on all repositories
Run {
/// Git command to run
#[structopt(required = true)]
command: Vec<String>,
},
/// Manage Git hooks across repositories
Hook {
/// Hook subcommand to execute
#[structopt(subcommand)]
subcommand: HookSubCommand,
},
}
#[derive(Debug, StructOpt, Clone)]
pub enum HookSubCommand {
/// List available hooks for repositories
List,
/// Create a new hook or update an existing one
Create {
/// Type of hook to create (pre-commit, post-commit, etc.)
#[structopt(required = true)]
hook_type: String,
/// Path to the script file to use for the hook
#[structopt(required = true)]
script_path: std::path::PathBuf,
},
/// Install hooks to repositories
Install {
/// Type of hook to install (pre-commit, post-commit, etc.)
#[structopt(required = true)]
hook_type: String,
},
/// Remove hooks from repositories
Remove {
/// Type of hook to remove (pre-commit, post-commit, etc.)
#[structopt(required = true)]
hook_type: String,
},
}
/// Represents the result of an operation on a repository
#[derive(Debug)]
pub enum OperationResult {
Success(String),
Failure(String),
Skipped(String),
}
/// Trait for repository operations
pub trait RepositoryOperation: Send + Sync {
fn name(&self) -> &'static str;
fn description(&self) -> &'static str;
// Use Box<dyn Future> instead of async fn for dynamic dispatch
fn execute<'a>(&'a self, repo_path: &'a std::path::Path) ->
std::pin::Pin<Box<dyn std::future::Future<Output = anyhow::Result<OperationResult>> + Send + 'a>>;
}