allow multiple instances of gitlab to be configured
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
use crate::cli::Issue2Work;
|
||||
use crate::config::Config;
|
||||
use crate::error::GeneralError;
|
||||
use crate::gitlab::client::{ClientProvider, ClientProviderTrait};
|
||||
use crate::gitlab::issue::IssueBundle;
|
||||
use crate::openproject::client::Client;
|
||||
use crate::openproject::user::{GetMe, User};
|
||||
use crate::openproject::work::WorkPackageWriterAssignee;
|
||||
use gitlab::api::{issues, projects, AsyncQuery};
|
||||
use gitlab::{GitlabBuilder, Issue, Project};
|
||||
use gitlab::{Issue, Project};
|
||||
use url::Url;
|
||||
|
||||
#[derive(Debug)]
|
||||
@@ -22,17 +23,6 @@ struct Issue2WorkPackageDTO {
|
||||
pub assign_to: Option<User>,
|
||||
}
|
||||
|
||||
impl From<&Issue2WorkPackageDTO> for Option<WorkPackageWriterAssignee> {
|
||||
fn from(value: &Issue2WorkPackageDTO) -> Self {
|
||||
match &value.assign_to {
|
||||
None => None,
|
||||
Some(w) => Some(WorkPackageWriterAssignee {
|
||||
href: w.clone().d_links.d_self.href,
|
||||
}),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&Issue2WorkPackageDTO> for crate::openproject::work::WorkPackageWriter {
|
||||
fn from(value: &Issue2WorkPackageDTO) -> Self {
|
||||
crate::openproject::work::WorkPackageWriter {
|
||||
@@ -47,7 +37,12 @@ impl From<&Issue2WorkPackageDTO> for crate::openproject::work::WorkPackageWriter
|
||||
format: "markdown".into(),
|
||||
raw: format!("From gitlab: {}", value.issue.issue.web_url),
|
||||
},
|
||||
assignee: value.into(),
|
||||
assignee: WorkPackageWriterAssignee {
|
||||
href: match &value.assign_to {
|
||||
None => None,
|
||||
Some(w) => Some(w.clone().d_links.d_self.href),
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -56,9 +51,7 @@ pub(crate) async fn issue2work(config: Config, args: &Issue2Work) -> Result<(),
|
||||
let url = Url::parse(&*args.issue_url).expect("issue_url is not valid");
|
||||
let data = extract_issue_info(&url).unwrap();
|
||||
|
||||
let client = GitlabBuilder::new("gitlab.com", config.gitlab.token)
|
||||
.build_async()
|
||||
.await?;
|
||||
let client = ClientProvider::client_for_url(&url, &config).await?;
|
||||
|
||||
let endpoint = issues::ProjectIssues::builder()
|
||||
.iid(data.iid)
|
||||
|
||||
Reference in New Issue
Block a user