cargo fixes
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
use crate::error::GeneralError;
|
||||
use crate::gitea::client::Client;
|
||||
use crate::gitea::repository::Repository;
|
||||
use serde::Deserialize;
|
||||
use url::Url;
|
||||
use crate::error::GeneralError;
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct Issue {
|
||||
@@ -31,13 +31,24 @@ pub fn issue_html_url_to_api(url: &Url) -> Result<Url, GeneralError> {
|
||||
let issue = parts.next().unwrap();
|
||||
let iid = parts.next().unwrap();
|
||||
|
||||
if (!issue.eq("issues")) {
|
||||
if !issue.eq("issues") {
|
||||
return Err(GeneralError {
|
||||
description: format!("Issue url is not valid: {}", url),
|
||||
});
|
||||
}
|
||||
|
||||
let url = Url::parse(format!("{}://{}/api/v1/repos/{}/{}/issues/{}", url.scheme(), url.host().unwrap(), domain, repo, iid).as_str()).unwrap();
|
||||
let url = Url::parse(
|
||||
format!(
|
||||
"{}://{}/api/v1/repos/{}/{}/issues/{}",
|
||||
url.scheme(),
|
||||
url.host().unwrap(),
|
||||
domain,
|
||||
repo,
|
||||
iid
|
||||
)
|
||||
.as_str(),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
Ok(url)
|
||||
}
|
||||
@@ -51,6 +62,9 @@ mod tests {
|
||||
let url = Url::parse("https://gitea.champs-libres.be/champs-libres/test/issues/1").unwrap();
|
||||
let result = issue_html_url_to_api(&url).unwrap();
|
||||
|
||||
assert_eq!(result.as_str(), "https://gitea.champs-libres.be/api/v1/repos/champs-libres/test/issues/1");
|
||||
assert_eq!(
|
||||
result.as_str(),
|
||||
"https://gitea.champs-libres.be/api/v1/repos/champs-libres/test/issues/1"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user