Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions api-model/src/buck2/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ use utoipa::ToSchema;
use crate::buck2::{status::Status, types::ProjectRelativePath};

/// Parameters required to build a task.
#[allow(dead_code)]
#[derive(Debug, Deserialize, Serialize, ToSchema)]
pub struct TaskBuildRequest {
/// The repository base path
Expand Down Expand Up @@ -47,7 +46,6 @@ pub struct RetryBuildRequest {
}

/// Result of a task build operation containing status and metadata. Used by Orion-Server
#[allow(dead_code)]
#[derive(Debug, Deserialize, Serialize, ToSchema)]
pub struct OrionBuildResult {
/// Unique identifier for the build task
Expand Down
1 change: 0 additions & 1 deletion api-model/src/buck2/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use serde::{Deserialize, Serialize};
use utoipa::ToSchema;

/// Task phase when in buck2 build
#[allow(dead_code)]
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema, PartialEq, Eq)]
pub enum TaskPhase {
DownloadingSource,
Expand Down
1 change: 0 additions & 1 deletion api-model/src/buck2/ws.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use crate::buck2::{
};

/// Message protocol for WebSocket communication between worker and server.
#[allow(dead_code)]
#[derive(Debug, Serialize, Deserialize, Clone)]
#[serde(tag = "type")]
pub enum WSMessage {
Expand Down
8 changes: 1 addition & 7 deletions ceres/src/model/change_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ pub enum RequirementsState {
}

#[derive(Debug, Clone, serde::Deserialize, serde::Serialize, utoipa::ToSchema)]
#[allow(dead_code)]

pub struct VerifyClPayload {
pub assignees: Vec<String>,
}
Expand Down Expand Up @@ -386,12 +386,6 @@ impl ClDiffFile {
}
}
}
#[derive(Serialize)]
pub struct BuckFile {
pub buck: ObjectHash,
pub buck_config: ObjectHash,
pub path: PathBuf,
}

#[cfg(test)]
mod tests {
Expand Down
125 changes: 3 additions & 122 deletions ceres/src/pack/monorepo.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{
collections::{HashMap, HashSet},
path::{Component, Path, PathBuf},
path::{Component, PathBuf},
str::FromStr,
sync::{
Arc,
Expand Down Expand Up @@ -39,9 +39,9 @@ use tokio::sync::{RwLock, mpsc};
use tokio_stream::wrappers::ReceiverStream;

use crate::{
api_service::{ApiHandler, cache::GitObjectCache, mono_api_service::MonoApiService, tree_ops},
api_service::{ApiHandler, cache::GitObjectCache, mono_api_service::MonoApiService},
code_edit::{on_push::OnpushCodeEdit, utils::get_changed_files},
model::change_list::{BuckFile, ClDiffFile},
model::change_list::ClDiffFile,
pack::RepoHandler,
protocol::import_refs::{RefCommand, Refs},
};
Expand Down Expand Up @@ -589,93 +589,6 @@ impl MonoRepo {
Ok(cl_link)
}

#[allow(dead_code)]
async fn search_buck_under_cl(&self, cl_path: &Path) -> Result<Vec<BuckFile>, MegaError> {
let mut res = vec![];
let mono_stg = self.storage.mono_storage();
let mono_api_service: MonoApiService = self.into();

let mut path = Some(cl_path);
let mut path_q = Vec::new();
while let Some(p) = path {
path_q.push(p);
path = p.parent();
}
if path_q.len() > 2 {
path_q.pop();
path_q.pop();

let p = path_q[path_q.len() - 1];
if p.parent().is_some()
&& let Some(tree) = tree_ops::search_tree_by_path(&mono_api_service, p, None)
.await
.ok()
.flatten()
&& let Some(buck) = self.try_extract_buck(tree, cl_path)
{
return Ok(vec![buck]);
};
return Ok(vec![]);
}

let mut search_trees: Vec<(PathBuf, Tree)> = vec![];

let diff_trees = self.diff_trees_from_cl().await?;
for (path, new, old) in diff_trees {
match (new, old) {
(None, _) => {
continue;
}
(Some(sha1), _) => {
let tree = mono_stg.get_tree_by_hash(&sha1.to_string()).await?.unwrap();
search_trees.push((path, Tree::from_mega_model(tree)));
}
}
}

for (path, tree) in search_trees {
if let Some(buck) = self.try_extract_buck(tree, &cl_path.join(path)) {
res.push(buck);
}
}

Ok(res)
}

fn try_extract_buck(&self, tree: Tree, cl_path: &Path) -> Option<BuckFile> {
let mut buck = None;
let mut buck_config = None;
for item in tree.tree_items {
if item.is_blob() && item.name == "BUCK" {
buck = Some(item.id)
}
if item.is_blob() && item.name == ".buckconfig" {
buck_config = Some(item.id)
}
}
match (buck, buck_config) {
(Some(buck), Some(buck_config)) => Some(BuckFile {
buck,
buck_config,
path: cl_path.to_path_buf(),
}),
_ => None,
}
}

async fn diff_trees_from_cl(
&self,
) -> Result<Vec<(PathBuf, Option<ObjectHash>, Option<ObjectHash>)>, MegaError> {
let mono_stg = self.storage.mono_storage();
let from_c = mono_stg.get_commit_by_hash(&self.from_hash).await?.unwrap();
let from_tree: Tree =
Tree::from_mega_model(mono_stg.get_tree_by_hash(&from_c.tree).await?.unwrap());
let to_c = mono_stg.get_commit_by_hash(&self.to_hash).await?.unwrap();
let to_tree: Tree =
Tree::from_mega_model(mono_stg.get_tree_by_hash(&to_c.tree).await?.unwrap());
diff_trees(&to_tree, &from_tree)
}

pub fn username(&self) -> String {
self.username.clone().unwrap_or(String::from("Anonymous"))
}
Expand Down Expand Up @@ -841,35 +754,3 @@ impl MonoRepo {
Ok(())
}
}

#[allow(dead_code)]
type DiffResult = Vec<(PathBuf, Option<ObjectHash>, Option<ObjectHash>)>;

#[allow(dead_code)]
fn diff_trees(theirs: &Tree, base: &Tree) -> Result<DiffResult, MegaError> {
let their_items: HashMap<_, _> = get_plain_items(theirs).into_iter().collect();
let base_items: HashMap<_, _> = get_plain_items(base).into_iter().collect();
let all_paths: HashSet<_> = their_items.keys().chain(base_items.keys()).collect();

let mut diffs = Vec::new();

for path in all_paths {
let their_hash = their_items.get(path).cloned();
let base_hash = base_items.get(path).cloned();
if their_hash != base_hash {
diffs.push((path.clone(), their_hash, base_hash));
}
}
Ok(diffs)
}

#[allow(dead_code)]
fn get_plain_items(tree: &Tree) -> Vec<(PathBuf, ObjectHash)> {
let mut items = Vec::new();
for item in tree.tree_items.iter() {
if item.is_tree() {
items.push((PathBuf::from(item.name.clone()), item.id));
}
}
items
}
10 changes: 5 additions & 5 deletions io-orbit/src/bin/migrate_local_to_s3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,11 +290,11 @@ async fn migrate_all(
// Periodically await some tasks to keep the number of in-memory
// JoinHandles bounded. Semaphore still enforces the true I/O
// concurrency; this only caps bookkeeping overhead.
if tasks.len() >= concurrency.saturating_mul(4).max(64) {
if let Some(t) = tasks.pop() {
t.await
.map_err(|e| MegaError::Other(format!("migration task panicked: {e}")))??;
}
if tasks.len() >= concurrency.saturating_mul(4).max(64)
&& let Some(t) = tasks.pop()
{
t.await
.map_err(|e| MegaError::Other(format!("migration task panicked: {e}")))??;
}
}

Expand Down
23 changes: 1 addition & 22 deletions mono/src/api/guard/cedar_guard.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{collections::HashMap, path::Path, str::FromStr};
use std::{collections::HashMap, str::FromStr};

use axum::{
extract::{FromRef, FromRequestParts, Request, State},
Expand Down Expand Up @@ -216,27 +216,6 @@ async fn authorize(
Ok(())
}

#[allow(dead_code)]
async fn get_blob_string(state: &MonoApiServiceState, path: &Path) -> Result<String, ApiError> {
// Use main as default branch
let refs = None;
let data = state
.api_handler(path.as_ref())
.await?
.get_blob_as_string(path.into(), refs)
.await?;

match data {
Some(content) => Ok(content),
None => {
Err(MegaError::Other(format!(
"Blob not found at path: {}",
path.display()
)))
}?,
}
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down
2 changes: 1 addition & 1 deletion mono/src/git_protocol/ssh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use tokio::{io::AsyncReadExt, sync::Mutex};
use crate::git_protocol::http::search_subsequence;

type ClientMap = HashMap<(usize, ChannelId), Channel<Msg>>;
#[allow(dead_code)]

#[derive(Clone)]
pub struct SshServer {
pub clients: Arc<Mutex<ClientMap>>,
Expand Down
3 changes: 0 additions & 3 deletions orion-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,11 @@ path = "src/main.rs"
common = { workspace = true }
io-orbit = { workspace = true }
api-model = { workspace = true }
jupiter = { workspace = true }
callisto = { workspace = true }

http = { workspace = true }
axum = { workspace = true, features = ["macros", "ws"] }
tokio = { workspace = true, features = ["rt-multi-thread", "fs", "process"] }
tokio-retry = "0.3"
tokio-stream = { workspace = true, features = ["sync"] }
tokio-util = { workspace = true }
tracing = { workspace = true }
Expand All @@ -42,7 +40,6 @@ dashmap = { workspace = true }
utoipa.workspace = true
utoipa-swagger-ui = { workspace = true, features = ["axum"] }
chrono = { workspace = true, features = ["serde"] }
reqwest.workspace = true
anyhow = { workspace = true }
async-trait = { workspace = true }
once_cell = { workspace = true }
Expand Down
Loading
Loading