Compare commits

..

2 commits

Author SHA1 Message Date
7b64e300b6 feat!: reduce the max commit dev can be ahead of main
All checks were successful
Rust / build (push) Successful in 1m14s
ci/woodpecker/push/cron-docker-builder Pipeline was successful
ci/woodpecker/push/push-next Pipeline was successful
ci/woodpecker/push/tag-created Pipeline was successful
ci/woodpecker/cron/cron-docker-builder Pipeline was successful
ci/woodpecker/cron/push-next Pipeline was successful
ci/woodpecker/cron/tag-created Pipeline was successful
From 50 to 25.

Aim to make this a configuration option from git-next-server.toml
2024-07-30 16:40:39 +01:00
f6bc2e1283 feat: terminate process if config file is invalid
All checks were successful
Rust / build (push) Successful in 1m20s
ci/woodpecker/push/cron-docker-builder Pipeline was successful
ci/woodpecker/push/push-next Pipeline was successful
ci/woodpecker/push/tag-created Pipeline was successful
2024-07-30 16:27:24 +01:00
6 changed files with 13 additions and 24 deletions

View file

@ -13,12 +13,8 @@ impl Handler<FileUpdated> for ServerActor {
fn handle(&mut self, _msg: FileUpdated, ctx: &mut Self::Context) -> Self::Result {
match ServerConfig::load(&self.fs) {
Ok(server_config) => {
self.do_send(ReceiveServerConfig::new(server_config), ctx);
}
Err(err) => {
self.abort(ctx, format!("Failed to load config file. Error: {}", err));
}
Ok(server_config) => self.do_send(ReceiveServerConfig::new(server_config), ctx),
Err(err) => self.abort(ctx, format!("Failed to load config file. Error: {}", err)),
};
}
}

View file

@ -12,15 +12,15 @@ impl Handler<ReceiveServerConfig> for ServerActor {
fn handle(&mut self, msg: ReceiveServerConfig, ctx: &mut Self::Context) -> Self::Result {
tracing::info!("recieved server config");
let Ok(socket_addr) = msg.http() else {
self.abort(ctx, "Unable to parse http.addr");
return self.abort(ctx, "Unable to parse http.addr");
};
let Some(server_storage) = self.server_storage(&msg) else {
self.abort(ctx, "Server storage not available");
return self.abort(ctx, "Server storage not available");
};
if msg.inbound_webhook().base_url().ends_with('/') {
self.abort(ctx, "webhook.url must not end with a '/'");
return self.abort(ctx, "webhook.url must not end with a '/'");
}
self.do_send(

View file

@ -229,17 +229,11 @@ impl ServerActor {
Some(server_storage)
}
/// Attempts to gracefully shutdown the server before terminating the process.
fn abort(
&mut self,
ctx: &mut <Self as actix::Actor>::Context,
message: impl Into<String>,
) -> ! {
/// Attempts to gracefully shutdown the server before stopping the system.
fn abort(&mut self, ctx: &mut <Self as actix::Actor>::Context, message: impl Into<String>) {
tracing::error!("Aborting: {}", message.into());
self.do_send(crate::server::actor::messages::Shutdown, ctx);
std::thread::sleep(std::time::Duration::from_millis(200));
System::current().stop();
std::process::exit(-1);
System::current().stop_with_code(1);
}
fn do_send<M>(&mut self, msg: M, _ctx: &mut <Self as actix::Actor>::Context)

View file

@ -52,5 +52,5 @@ async fn when_webhook_url_has_trailing_slash_should_not_send() {
tracing::debug!(?message_log, "");
assert!(message_log.read().iter().any(|log| !log
.iter()
.any(|line| line != "send: ReceiveValidServerConfig")));
.any(|line| line == "send: ReceiveValidServerConfig")));
}

View file

@ -133,7 +133,7 @@ impl super::OpenRepositoryLike for RealOpenRepository {
) -> Result<Vec<git::Commit>, git::commit::log::Error> {
let limit = match find_commits.is_empty() {
true => 1,
false => 50,
false => 25,
};
self.0
.read()

View file

@ -19,18 +19,17 @@ fn should_return_single_item_in_commit_log_when_not_searching() -> TestResult {
#[test]
// assumes running in the git-next repo which should have main, next and dev as remote branches
fn should_return_capacity_50_in_commit_log_when_searching_for_garbage() -> TestResult {
fn should_return_capacity_25_in_commit_log_when_searching_for_garbage() -> TestResult {
let_assert!(Ok(fs) = kxio::fs::temp());
let branch_name = given::a_branch_name();
let gitdir = GitDir::new(fs.base().to_path_buf(), StoragePathType::Internal);
let test_repository = git::repository::test(fs.clone());
let_assert!(Ok(open_repository) = test_repository.open(&gitdir));
for _ in [0; 60] {
// create 60 commits
for _ in [0; 25] {
then::create_a_commit_on_branch(&fs, &gitdir, &branch_name)?;
}
let_assert!(Ok(result) = open_repository.commit_log(&branch_name, &[given::a_commit()]));
assert_eq!(result.len(), 50);
assert_eq!(result.len(), 25);
Ok(())
}