How inditextech/gh-sherpa works
Main Components
• CLI Interface: Represent the extension’s entry points under the “cmd” directory (e.g., create_branch, create_pull_request, root.go). These handle user commands and trigger the extension’s behavior.
• Configuration Management: Highlight the configuration components found under “internal/config” (configuration parsing, default-config.yml, templates, and custom configuration support from $HOME/.config/sherpa/config.yml). This part is crucial since it maps issue types to branch naming conventions.
• Use Cases/Business Logic: Emphasize the “internal/use_cases” where core functions (like create_branch and create_pull_request) are implemented. These files define how user commands drive the creation of branches and PRs.
• Domain Entities: Show the “internal/domain” layer where domain models (issue, branch, pull request, repository, issue type) are defined. These represent the business objects that the system manipulates.
• External Dependencies/Integrations:
• Git and GitHub: The “internal/git” and “internal/gh” packages encapsulate interactions with Git repositories and GitHub CLI respectively.
• Issue Trackers: The packages under “internal/issue_trackers” (with separate modules for GitHub and Jira) represent connectors to external issue tracking systems.
• Auxiliary Components:
• Fakes and Mocks (found in “internal/fakes” and “internal/mocks”) that facilitate testing.
• Validation and Metadata (in the “pkg” directory) to enforce rules and capture repository metadata.
Inter-component Relationships
• The CLI commands (in the cmd directory) act as the entry point. They interact with the Use Cases – for instance, the “create_branch” and “create_pull_request” use cases – which in turn coordinate domain logic.
• The Use Cases leverage the Configuration Management to determine the issue-to-branch mapping logic.
• Domain entities pass data between the use cases and integration modules (Git, GitHub CLI, or issue trackers).
• There is a clear separation between the logic that handles business rules (internal/use_cases and internal/domain) and the actual integrations (internal/git, internal/gh, internal/issue_trackers/*).
Architectural Patterns and Design Principles
• Layered Architecture: The project cleanly separates concerns into a command layer (CLI), application layer (use cases and domain logic), and infrastructure layer (Git and issue tracker integrations).
• Dependency Inversion: The use of interfaces and “fakes” in internal/fakes/mocks helps in abstracting external dependencies, which facilitates testing and potentially plug-and-play integrations.
• Extensibility: The configuration management, templated configuration files, and structured domain objects suggest that the tool is built to be easily extended (for instance, to support other issue trackers or customized branching schemes).