Refactor Gitea client and improve issue handling

Update the authorization header format in the Gitea client. Enhance issue details in work package creation and make `number` field public in the `Issue` struct.
This commit is contained in:
Julien Fastré 2024-11-14 14:22:39 +01:00
parent 696fd15cfa
commit 7b6cc33ecb
Signed by: julienfastre
GPG Key ID: BDE2190974723FCB
3 changed files with 3 additions and 3 deletions

View File

@ -47,7 +47,7 @@ impl Issue2WorkActionTrait for GiteaAction {
fn create_work_package_from_issue(issue: &Issue, assignee: Option<User>) -> WorkPackageWriter { fn create_work_package_from_issue(issue: &Issue, assignee: Option<User>) -> WorkPackageWriter {
WorkPackageWriter { WorkPackageWriter {
subject: format!("{} ({})", issue.title, issue.repository.full_name), subject: format!("{} ({}/{})", issue.title, issue.repository.full_name, issue.number),
work_type: "TASK".into(), work_type: "TASK".into(),
description: crate::openproject::work::DescriptionWriter { description: crate::openproject::work::DescriptionWriter {
format: "markdown".into(), format: "markdown".into(),

View File

@ -54,7 +54,7 @@ impl Client {
pub async fn get<T: DeserializeOwned>(&self, url: Url) -> Result<T, GeneralError> { pub async fn get<T: DeserializeOwned>(&self, url: Url) -> Result<T, GeneralError> {
let mut headers = HeaderMap::new(); let mut headers = HeaderMap::new();
headers.append(AUTHORIZATION, self.token.parse()?); headers.append(AUTHORIZATION, format!("token {}", self.token).parse()?);
headers.append(ACCEPT, "application/json".parse()?); headers.append(ACCEPT, "application/json".parse()?);
let client = ClientBuilder::new() let client = ClientBuilder::new()

View File

@ -7,7 +7,7 @@ use url::Url;
#[derive(Debug, Deserialize)] #[derive(Debug, Deserialize)]
pub struct Issue { pub struct Issue {
pub id: u64, pub id: u64,
number: u64, pub number: u64,
pub title: String, pub title: String,
pub body: String, pub body: String,
pub repository: Repository, pub repository: Repository,