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]
|
[dependencies]
|
||||||
clap = { version = "4.5", features = [ "cargo" ] }
|
clap = { version = "4.5", features = [ "cargo" ] }
|
||||||
forgejo-hooks = "*"
|
forgejo-hooks = "*"
|
||||||
gitlab = "0.1706"
|
gitlab = { version = "0.1706", optional = true }
|
||||||
hyper = { version = "1.6", default-features = false, features = [ "http1", "server" ] }
|
hyper = { version = "1.6", default-features = false, features = [ "http1", "server" ] }
|
||||||
hyper-util = { version = "0.1", features = [ "tokio" ] }
|
hyper-util = { version = "0.1", features = [ "tokio" ] }
|
||||||
http-body-util = "0.1"
|
http-body-util = "0.1"
|
||||||
|
|
@ -34,4 +34,5 @@ git2 = "0.20"
|
||||||
forgejo-hooks = { path = "forgejo-hooks" }
|
forgejo-hooks = { path = "forgejo-hooks" }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
|
gitlab = [ "dep:gitlab" ]
|
||||||
syntax-highlighting = ["xmpp/syntax-highlighting"]
|
syntax-highlighting = ["xmpp/syntax-highlighting"]
|
||||||
|
|
|
||||||
|
|
@ -14,11 +14,12 @@
|
||||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
mod forgejo;
|
mod forgejo;
|
||||||
|
#[cfg(feature = "gitlab")]
|
||||||
mod gitlab;
|
mod gitlab;
|
||||||
mod types;
|
mod types;
|
||||||
|
|
||||||
pub use crate::hooks::forgejo::ForgejoHook;
|
pub use crate::hooks::forgejo::ForgejoHook;
|
||||||
#[allow(deprecated)]
|
#[cfg(feature = "gitlab")]
|
||||||
pub use crate::hooks::gitlab::GitlabHook;
|
pub use crate::hooks::gitlab::GitlabHook;
|
||||||
pub use crate::hooks::types::Hook;
|
pub use crate::hooks::types::Hook;
|
||||||
pub use crate::hooks::types::{IssueAction, MergeRequestAction, WikiAction};
|
pub use crate::hooks::types::{IssueAction, MergeRequestAction, WikiAction};
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
use crate::error::Error;
|
use crate::error::Error;
|
||||||
#[allow(deprecated)]
|
#[cfg(feature = "gitlab")]
|
||||||
use crate::hooks::GitlabHook;
|
use crate::hooks::GitlabHook;
|
||||||
use crate::hooks::{ForgejoHook, Hook};
|
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();
|
let whole_body = req.collect().await?.aggregate();
|
||||||
whole_body.reader().read_to_end(&mut payload)?;
|
whole_body.reader().read_to_end(&mut payload)?;
|
||||||
|
|
||||||
|
#[cfg(feature = "gitlab")]
|
||||||
if let Some(val) = headers.get("X-Gitlab-Token") {
|
if let Some(val) = headers.get("X-Gitlab-Token") {
|
||||||
if secret != val {
|
if secret != val {
|
||||||
return Err(Error::InvalidSecret);
|
return Err(Error::InvalidSecret);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue