Add a web extension and debian package compilation (#5)
Check go code / build-and-release (push) Successful in 1m9s

Reviewed-on: #5
Co-authored-by: Julien Fastré <julien.fastre@champs-libres.coop>
Co-committed-by: Julien Fastré <julien.fastre@champs-libres.coop>
This commit was merged in pull request #5.
This commit is contained in:
2025-11-12 19:10:41 +00:00
committed by Julien Fastré
parent d830f33eec
commit 0a64db6925
31 changed files with 7005 additions and 346 deletions
+30 -6
View File
@@ -3,7 +3,7 @@ use crate::config::Config;
use crate::error::GeneralError;
use crate::gitea::action::GiteaAction;
use crate::gitlab::action::GitlabAction;
use crate::planning::Issue2WorkActionTrait;
use crate::planning::{Issue2WorkActionTrait, Issue2WorkResult};
use url::Url;
struct App {
@@ -11,20 +11,44 @@ struct App {
gitea_issue2work_action: GiteaAction,
}
pub(crate) async fn issue2work(config: Config, args: &Issue2Work) -> Result<(), GeneralError> {
pub async fn handle_issue2work(
config: Config,
args: &Issue2Work,
) -> Result<Issue2WorkResult, GeneralError> {
let url = Url::parse(&*args.issue_url).expect("issue_url is not valid");
let app = App {
gitlab_issue2work_action: GitlabAction {},
gitea_issue2work_action: GiteaAction {},
};
let result: Issue2WorkResult;
if app.gitlab_issue2work_action.supports(&url, &config, args) {
app.gitlab_issue2work_action.run(&url, &config, args).await
result = app
.gitlab_issue2work_action
.run(&url, &config, args)
.await?;
} else if app.gitea_issue2work_action.supports(&url, &config, args) {
app.gitea_issue2work_action.run(&url, &config, args).await
result = app.gitea_issue2work_action.run(&url, &config, args).await?
} else {
Err(GeneralError {
return Err(GeneralError {
description: format!("This action is not supported for this url: {}", url),
})
});
}
Ok(result)
}
pub async fn issue2work_cli(config: Config, args: &Issue2Work) -> Result<(), GeneralError> {
let result = handle_issue2work(config, args).await?;
println!(
"new work package created: {:?}, edit at {}",
result.subject, result.work_package_url
);
if let Err(e) = open::that(result.work_package_url.as_str()) {
println!("failed to open work package in browser: {}", e);
};
Ok(())
}
+12 -2
View File
@@ -3,11 +3,21 @@ use crate::config::Config;
use crate::error::GeneralError;
use url::Url;
pub(crate) mod issue2work;
pub mod issue2work;
pub mod utils;
pub trait Issue2WorkActionTrait {
async fn run(&self, url: &Url, config: &Config, args: &Issue2Work) -> Result<(), GeneralError>;
fn run(
&self,
url: &Url,
config: &Config,
args: &Issue2Work,
) -> impl std::future::Future<Output = Result<Issue2WorkResult, GeneralError>> + Send;
fn supports(&self, url: &Url, config: &Config, args: &Issue2Work) -> bool;
}
pub struct Issue2WorkResult {
pub work_package_url: String,
pub subject: String,
}