feat: gitlab feature
This commit is contained in:
parent
5fc65c7636
commit
d54ef5f265
3 changed files with 6 additions and 3 deletions
|
|
@ -9,7 +9,7 @@ license = "AGPL-3.0+"
|
|||
[dependencies]
|
||||
clap = { version = "4.5", features = [ "cargo" ] }
|
||||
forgejo-hooks = "*"
|
||||
gitlab = "0.1706"
|
||||
gitlab = { version = "0.1706", optional = true }
|
||||
hyper = { version = "1.6", default-features = false, features = [ "http1", "server" ] }
|
||||
hyper-util = { version = "0.1", features = [ "tokio" ] }
|
||||
http-body-util = "0.1"
|
||||
|
|
@ -34,4 +34,5 @@ git2 = "0.20"
|
|||
forgejo-hooks = { path = "forgejo-hooks" }
|
||||
|
||||
[features]
|
||||
gitlab = [ "dep:gitlab" ]
|
||||
syntax-highlighting = ["xmpp/syntax-highlighting"]
|
||||
|
|
|
|||
|
|
@ -14,11 +14,12 @@
|
|||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
mod forgejo;
|
||||
#[cfg(feature = "gitlab")]
|
||||
mod gitlab;
|
||||
mod types;
|
||||
|
||||
pub use crate::hooks::forgejo::ForgejoHook;
|
||||
#[allow(deprecated)]
|
||||
#[cfg(feature = "gitlab")]
|
||||
pub use crate::hooks::gitlab::GitlabHook;
|
||||
pub use crate::hooks::types::Hook;
|
||||
pub use crate::hooks::types::{IssueAction, MergeRequestAction, WikiAction};
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::error::Error;
|
||||
#[allow(deprecated)]
|
||||
#[cfg(feature = "gitlab")]
|
||||
use crate::hooks::GitlabHook;
|
||||
use crate::hooks::{ForgejoHook, Hook};
|
||||
|
||||
|
|
@ -62,6 +62,7 @@ async fn hooks_inner(req: Request<Incoming>, secret: &str) -> Result<Hook, Error
|
|||
let whole_body = req.collect().await?.aggregate();
|
||||
whole_body.reader().read_to_end(&mut payload)?;
|
||||
|
||||
#[cfg(feature = "gitlab")]
|
||||
if let Some(val) = headers.get("X-Gitlab-Token") {
|
||||
if secret != val {
|
||||
return Err(Error::InvalidSecret);
|
||||
|
|
|
|||
Loading…
Reference in a new issue