Add PATCH support in Gitea client and update issue handling
Extend Gitea client with a `patch` method for executing PATCH requests. Introduce `IssueWriteSetBody` struct for serializing issue update payloads. Update Gitea action to append related issues and send PATCH requests to update issue descriptions.
This commit is contained in:
+15
-7
@@ -2,12 +2,12 @@ use crate::cli::Issue2Work;
|
||||
use crate::config::Config;
|
||||
use crate::error::GeneralError;
|
||||
use crate::gitea::client::has_client_for_url;
|
||||
use crate::gitea::issue::{issue_html_url_to_api, Issue};
|
||||
use crate::gitea::issue::{issue_html_url_to_api, Issue, IssueWriteSetBody};
|
||||
use crate::openproject::user::{GetMe, User};
|
||||
use crate::openproject::work::WorkPackageWriter;
|
||||
use crate::planning::utils::{append_related_issues, IssueRelated};
|
||||
use crate::planning::Issue2WorkActionTrait;
|
||||
use url::Url;
|
||||
use crate::planning::utils::{append_related_issues, IssueRelated};
|
||||
|
||||
pub(crate) struct GiteaAction {}
|
||||
|
||||
@@ -33,20 +33,28 @@ impl Issue2WorkActionTrait for GiteaAction {
|
||||
.create_work_package(&work_package, &args.project_id)
|
||||
.await?;
|
||||
|
||||
let url = format!(
|
||||
let url_wp = format!(
|
||||
"{}/projects/{}/work_packages/{}",
|
||||
config.openproject.base_url, args.project_id, work_package.id
|
||||
);
|
||||
|
||||
let content = append_related_issues(&IssueRelated::OpenProjectIssue(url.to_string()), &issue.body);
|
||||
|
||||
let content = append_related_issues(
|
||||
&IssueRelated::OpenProjectIssue(url_wp.to_string()),
|
||||
&issue.body,
|
||||
);
|
||||
let _u: Issue = gitea_client
|
||||
.patch(
|
||||
issue_html_url_to_api(url)?,
|
||||
&IssueWriteSetBody { body: content },
|
||||
)
|
||||
.await?;
|
||||
|
||||
println!(
|
||||
"new work package created: {:?}, edit at {}",
|
||||
work_package.subject, url
|
||||
work_package.subject, url_wp
|
||||
);
|
||||
|
||||
if let Err(e) = open::that(url) {
|
||||
if let Err(e) = open::that(url_wp) {
|
||||
println!("failed to open work package in browser: {}", e);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user