From 4ca47ade2b7719e56a172aae371b518acedda074 Mon Sep 17 00:00:00 2001 From: 7000pctAUTO Date: Thu, 29 Jan 2026 19:59:21 +0000 Subject: [PATCH] Initial commit: git-issue-commit CLI tool --- src/fetcher/mod.rs | 56 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 src/fetcher/mod.rs diff --git a/src/fetcher/mod.rs b/src/fetcher/mod.rs new file mode 100644 index 0000000..cfd56bf --- /dev/null +++ b/src/fetcher/mod.rs @@ -0,0 +1,56 @@ +use anyhow::Result; + +pub mod github; +pub mod gitlab; + +pub use github::fetch_github_issue; +pub use gitlab::fetch_gitlab_issue; + +pub struct IssueContent { + pub title: String, + pub body: String, + pub number: u64, + pub url: String, + pub labels: Vec, + pub author: String, + pub state: String, +} + +impl IssueContent { + pub fn new(title: String, body: String) -> Self { + IssueContent { + title, + body, + number: 0, + url: String::new(), + labels: Vec::new(), + author: String::new(), + state: String::new(), + } + } + + pub fn with_labels(mut self, labels: Vec) -> Self { + self.labels = labels; + self + } + + pub fn with_author(mut self, author: String) -> Self { + self.author = author; + self + } + + pub fn with_state(mut self, state: String) -> Self { + self.state = state; + self + } +} + +pub async fn fetch_issue_content(url: &str) -> Result { + if url.contains("github.com") { + fetch_github_issue(url).await + } else if url.contains("gitlab.com") { + fetch_gitlab_issue(url).await + } else { + anyhow::bail!("Unsupported Git provider. Only GitHub and GitLab are supported.") + } +}