fix: github: restarting server creates duplicate webhook for repo
The Github routine for registering a new webhook, wasn't removing any existing matching webhooks. There is a test for this, but it doesn't assert that the delete requests are made. (This is a limitation of kxio). Closes kemitix/git-next#102
This commit is contained in:
parent
975c9e315c
commit
db90280641
1 changed files with 7 additions and 2 deletions
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
use crate as github;
|
||||
use crate::{self as github, webhook};
|
||||
use git_next_config as config;
|
||||
use git_next_git as git;
|
||||
|
||||
|
@ -15,8 +15,13 @@ pub async fn register(
|
|||
return Err(git::forge::webhook::Error::NoRepoConfig);
|
||||
};
|
||||
|
||||
let net = &github.net;
|
||||
// remove any lingering webhooks for the same URL
|
||||
let existing_webhook_ids = webhook::list(github, webhook_url).await?;
|
||||
for webhook_id in existing_webhook_ids {
|
||||
webhook::unregister(github, &webhook_id).await?;
|
||||
}
|
||||
|
||||
let net = &github.net;
|
||||
let hostname = repo_details.forge.hostname();
|
||||
let authorisation = config::WebhookAuth::generate();
|
||||
let request = network::NetRequest::new(
|
||||
|
|
Loading…
Reference in a new issue