Expand description
GitHub CLI (gh) integration
Uses gh CLI to query PR information and perform GitHub operations.
§Architecture
This module uses a trait-based design for testability:
CommandExecutor- Trait for executing shell commandsGitHubClient- Main client that uses a CommandExecutorMockCommandExecutor- Mock implementation for testing
§Example: Using in tests
ⓘ
use gw::github::{GitHubClient, MockScenarioBuilder, fixtures};
let executor = MockScenarioBuilder::new()
.gh_available()
.with_pr("feature/test", &fixtures::open_pr(42, "feature/test"))
.build();
let client = GitHubClient::with_executor(executor);
let pr = client.get_pr_for_branch("feature/test").unwrap().unwrap();
assert!(pr.state.is_open());Modules§
- fixtures
- Pre-built JSON responses for common PR scenarios
Structs§
- Command
Call - A recorded command call for verification
- Command
Output - Output from a command execution
- GitHub
Client - GitHub client for interacting with GitHub via gh CLI
- Mock
Command Executor - Mock command executor for testing
- Mock
Scenario Builder - Builder for creating mock GitHub scenarios
- PrInfo
- Information about a PR associated with a branch
- RawPr
Data - Raw PR data from JSON (before merge method detection)
- Real
Command Executor - Real command executor that runs actual shell commands
Enums§
- Merge
Method - How a PR was merged
- PrState
- PR state from GitHub
Traits§
- Command
Executor - Trait for executing shell commands
Functions§
- add_
pr_ comment - Add a comment to a PR
- delete_
remote_ branch - Delete a remote branch
- get_
pr_ for_ branch - Get PR information for a branch
- is_
gh_ authenticated - Check if
ghis authenticated - is_
gh_ available - Check if
ghCLI is available - update_
pr_ base - Update PR base branch