Skip to main content

git_workflow/github/
mod.rs

1//! GitHub CLI (gh) integration
2//!
3//! Uses `gh` CLI to query PR information and perform GitHub operations.
4//!
5//! # Architecture
6//!
7//! This module uses a trait-based design for testability:
8//!
9//! - [`CommandExecutor`] - Trait for executing shell commands
10//! - [`GitHubClient`] - Main client that uses a CommandExecutor
11//! - [`MockCommandExecutor`] - Mock implementation for testing
12//!
13//! # Example: Using in tests
14//!
15//! ```ignore
16//! use gw::github::{GitHubClient, MockScenarioBuilder, fixtures};
17//!
18//! let executor = MockScenarioBuilder::new()
19//!     .gh_available()
20//!     .with_pr("feature/test", &fixtures::open_pr(42, "feature/test"))
21//!     .build();
22//!
23//! let client = GitHubClient::with_executor(executor);
24//! let pr = client.get_pr_for_branch("feature/test").unwrap().unwrap();
25//! assert!(pr.state.is_open());
26//! ```
27
28mod client;
29mod mock;
30mod parser;
31#[cfg(test)]
32mod tests;
33mod types;
34
35// Re-export types
36pub use types::{MergeMethod, PrInfo, PrState, RawPrData};
37
38// Re-export client
39pub use client::{
40    CommandExecutor, CommandOutput, GitHubClient, RealCommandExecutor, add_pr_comment,
41    delete_remote_branch, get_pr_for_branch, is_gh_authenticated, is_gh_available, update_pr_base,
42};
43
44// Re-export mock (for testing in other modules)
45pub use mock::{CommandCall, MockCommandExecutor, MockScenarioBuilder, fixtures};