Append link to gitlab to create link between open project and gitlab #7
@@ -6,9 +6,12 @@ use crate::gitlab::issue::{Issue, IssueBundle, Project};
|
|||||||
use crate::openproject::client::Client;
|
use crate::openproject::client::Client;
|
||||||
use crate::openproject::user::{GetMe, User};
|
use crate::openproject::user::{GetMe, User};
|
||||||
use crate::openproject::work::WorkPackageWriterAssignee;
|
use crate::openproject::work::WorkPackageWriterAssignee;
|
||||||
|
use crate::planning::utils::{append_related_issues, IssueRelated};
|
||||||
use crate::planning::Issue2WorkActionTrait;
|
use crate::planning::Issue2WorkActionTrait;
|
||||||
use crate::planning::Issue2WorkResult;
|
use crate::planning::Issue2WorkResult;
|
||||||
use gitlab::api::{issues, projects, AsyncQuery};
|
use gitlab::api::projects::issues::EditIssue;
|
||||||
|
use gitlab::api::{issues, projects, ApiError, AsyncQuery};
|
||||||
|
use gitlab::RestError;
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@@ -71,6 +74,27 @@ impl Issue2WorkActionTrait for GitlabAction {
|
|||||||
.create_work_package(&(&dto).into(), &args.project_id)
|
.create_work_package(&(&dto).into(), &args.project_id)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
|
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_wp), &issue.description);
|
||||||
|
|
||||||
|
let endpoint_put_result = EditIssue::builder()
|
||||||
|
.project(issue.project_id)
|
||||||
|
.issue(issue.iid)
|
||||||
|
.description(content)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
if let Ok(endpoint_put) = endpoint_put_result {
|
||||||
|
let r: Result<Issue, ApiError<RestError>> = endpoint_put.query_async(&client).await;
|
||||||
|
if r.is_err() {
|
||||||
|
eprintln!("Error while updating the issue description: {:?}", r);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let result = Issue2WorkResult {
|
let result = Issue2WorkResult {
|
||||||
work_package_url: format!(
|
work_package_url: format!(
|
||||||
"{}/projects/{}/work_packages/{}",
|
"{}/projects/{}/work_packages/{}",
|
||||||
|
|||||||
Reference in New Issue
Block a user