-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
187 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
use crate::{ | ||
providers::{PackageProvider, UserProvider}, | ||
Handler, | ||
}; | ||
use anyhow::{bail, Context}; | ||
use thrussh::server::Session; | ||
use thrussh::{ChannelId, CryptoVec}; | ||
use tracing::instrument; | ||
|
||
#[instrument(skip_all, err)] | ||
pub async fn handle<U: UserProvider + PackageProvider + Send + Sync + 'static>( | ||
handle: &mut Handler<U>, | ||
session: &mut Session, | ||
channel: ChannelId, | ||
mut params: impl Iterator<Item = String>, | ||
) -> Result<(), anyhow::Error> { | ||
let (Some(project), Some(crate_name), Some(version)) = | ||
(params.next(), params.next(), params.next()) | ||
else { | ||
bail!("usage: bust-cache [gitlab project] [crate name] [version]"); | ||
}; | ||
|
||
if !handle | ||
.gitlab | ||
.is_project_maintainer(handle.user()?, &project) | ||
.await | ||
.context("Failed to check project maintainer status")? | ||
{ | ||
bail!("This command can only be ran by project maintainers"); | ||
} | ||
|
||
handle | ||
.gitlab | ||
.bust_cache(&project, &crate_name, &version) | ||
.await?; | ||
|
||
session.data( | ||
channel, | ||
CryptoVec::from_slice("Successfully bust cache for release.".as_bytes()), | ||
); | ||
session.exit_status_request(channel, 0); | ||
session.close(channel); | ||
|
||
Ok(()) | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
pub mod bust_cache; | ||
pub mod git_upload_pack; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters