Initial commit: git-issue-commit CLI tool
Some checks failed
CI / release (push) Has been cancelled
CI / test (push) Has been cancelled

This commit is contained in:
2026-01-29 19:59:21 +00:00
parent 4214848922
commit 4ca47ade2b

56
src/fetcher/mod.rs Normal file
View File

@@ -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<String>,
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<String>) -> 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<IssueContent> {
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.")
}
}