Skip to content

Commit

Permalink
remove unused libs
Browse files Browse the repository at this point in the history
  • Loading branch information
ggordonhall committed Apr 3, 2024
1 parent 82bd1d1 commit 3ff240c
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 358 deletions.
294 changes: 4 additions & 290 deletions Cargo.lock

Large diffs are not rendered by default.

6 changes: 0 additions & 6 deletions server/bleep/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ petgraph = { version = "0.6.4", default-features = false, features = ["serde-1"]
# webserver
serde_json = "1.0.107"
axum = { version = "0.6.20", features = ["http2", "headers", "macros"] }
axum-extra = { version = "0.8.0", features = ["cookie", "cookie-private"] }
tower-http = { version = "0.4.4", features = ["auth", "cors", "catch-panic", "fs"] }

# api integrations
Expand Down Expand Up @@ -113,9 +112,6 @@ comrak = { default-features = false, git = "https://github.com/rsdy/comrak" }
lazy-regex = "3.0.2"
quick-xml = { version = "0.29.0", features = ["serialize"] }

# auth
jsonwebtoken = { version = "8.3.0", features = ["use_pem"] }

# doc scraper
select = "0.6"
tree-sitter-md = "0.1.5"
Expand All @@ -139,11 +135,9 @@ thread-priority = "0.13.1"
diffy = "0.3.0"

[dev-dependencies]
criterion = { version = "0.5.1", features = ["async_tokio"] }
pretty_assertions = "1.4.0"
tempdir = "0.3.7"
expect-test = "1.4.1"
reqwest = { version = "0.11.20", default-features = false, features = ["blocking"] }

[build-dependencies]
phf_codegen = "0.11.2"
Expand Down
2 changes: 1 addition & 1 deletion server/bleep/src/indexes/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1005,7 +1005,7 @@ impl scraper::Document {
schema.doc_description => self.meta.description.as_deref().unwrap_or_default(),
schema.absolute_url => self.url.as_str(),
schema.relative_url => relative_url.as_str(),
schema.raw_relative_url => relative_url.as_str().as_bytes(),
schema.raw_relative_url => relative_url.as_bytes(),
schema.header => section.header.unwrap_or_default(),
schema.ancestry => section.ancestry_str().as_str(),
schema.text => section.data,
Expand Down
2 changes: 1 addition & 1 deletion server/bleep/src/indexes/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ impl DocumentRead for OpenReader {
// by users of this reader.
Some(parser::Literal::Plain(s)) => {
Some(parser::Literal::Plain(match base_name(s) {
s if s.is_empty() => return None,
"" => return None,
s => s.into(),
}))
}
Expand Down
2 changes: 2 additions & 0 deletions server/bleep/src/llm/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,9 @@ impl From<&api::Message> for tiktoken_rs::ChatCompletionRequestMessage {

enum ChatError {
BadRequest(String),
#[allow(dead_code)]
TooManyRequests(String),
#[allow(dead_code)]
InvalidToken,
Other(anyhow::Error),
}
Expand Down
3 changes: 0 additions & 3 deletions server/bleep/src/remotes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ pub(crate) enum RemoteError {
#[error("IO error: {0}")]
IO(#[from] std::io::Error),

#[error("JWT error: {0}")]
Jwt(#[from] jsonwebtoken::errors::Error),

#[error("github access error: {0}")]
GitHub(#[from] octocrab::Error),

Expand Down
14 changes: 7 additions & 7 deletions server/bleep/src/webserver/studio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1160,15 +1160,15 @@ async fn rectify_hunks(
debug!("fixing up patch:\n\n{hunk:?}\n\n{diff}");

singular_chunk.hunks[0].lines.retain(|line| match line {
diff::Line::AddLine(..) | diff::Line::DelLine(..) => true,
diff::Line::Add(..) | diff::Line::Del(..) => true,
diff::Line::Context(..) => false,
});
singular_chunk.fixup_hunks();

let diff = if singular_chunk.hunks[0]
.lines
.iter()
.all(|l| matches!(l, diff::Line::AddLine(..)))
.all(|l| matches!(l, diff::Line::Add(..)))
{
let system_prompt = prompts::studio_diff_regen_hunk_prompt(llm_context);
let messages = vec![
Expand Down Expand Up @@ -1232,11 +1232,11 @@ async fn validate_add_file(
return Ok(false);
};

if chunk.hunks.iter().any(|h| {
h.lines
.iter()
.any(|l| !matches!(l, diff::Line::AddLine(..)))
}) {
if chunk
.hunks
.iter()
.any(|h| h.lines.iter().any(|l| !matches!(l, diff::Line::Add(..))))
{
error!("diff to create a new file had non-addition lines");
Ok(false)
} else {
Expand Down
100 changes: 50 additions & 50 deletions server/bleep/src/webserver/studio/diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ fn split_hunks(hunks: &str) -> impl Iterator<Item = DiffHunk> + '_ {
})
.map(|(type_, line)| match type_ {
" " => Line::Context(line.into()),
"+" => Line::AddLine(line.into()),
"-" => Line::DelLine(line.into()),
"+" => Line::Add(line.into()),
"-" => Line::Del(line.into()),
_ => unreachable!("unknown character slipped through regex"),
})
.collect()
Expand All @@ -145,8 +145,8 @@ impl DiffHunk {
.iter()
.filter_map(|line| match line {
Line::Context(l) => Some(format!("{l}\n")),
Line::AddLine(_) => None,
Line::DelLine(l) => Some(format!("{l}\n")),
Line::Add(_) => None,
Line::Del(l) => Some(format!("{l}\n")),
})
.collect::<String>();

Expand All @@ -155,8 +155,8 @@ impl DiffHunk {
.iter()
.filter_map(|line| match line {
Line::Context(l) => Some(format!("{l}\n")),
Line::AddLine(l) => Some(format!("{l}\n")),
Line::DelLine(_) => None,
Line::Add(l) => Some(format!("{l}\n")),
Line::Del(_) => None,
})
.collect::<String>();

Expand All @@ -182,17 +182,17 @@ impl DiffHunk {
.lines
.iter()
.map(|l| match l {
Line::Context(_) | Line::DelLine(_) => 1,
Line::AddLine(_) => 0,
Line::Context(_) | Line::Del(_) => 1,
Line::Add(_) => 0,
})
.sum();

self.dst_count = self
.lines
.iter()
.map(|l| match l {
Line::Context(_) | Line::AddLine(_) => 1,
Line::DelLine(_) => 0,
Line::Context(_) | Line::Add(_) => 1,
Line::Del(_) => 0,
})
.sum();

Expand All @@ -219,16 +219,16 @@ impl fmt::Display for DiffHunk {
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum Line {
Context(String),
AddLine(String),
DelLine(String),
Add(String),
Del(String),
}

impl fmt::Display for Line {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Line::Context(line) => writeln!(f, " {line}"),
Line::AddLine(line) => writeln!(f, "+{line}"),
Line::DelLine(line) => writeln!(f, "-{line}"),
Line::Add(line) => writeln!(f, "+{line}"),
Line::Del(line) => writeln!(f, "-{line}"),
}
}
}
Expand Down Expand Up @@ -345,8 +345,8 @@ foo bar
"the line right below this one is intentionally empty".to_owned(),
),
Line::Context("".to_owned()),
Line::DelLine("foo".to_owned()),
Line::AddLine("bar".to_owned()),
Line::Del("foo".to_owned()),
Line::Add("bar".to_owned()),
],
},
DiffHunk {
Expand All @@ -355,9 +355,9 @@ foo bar
dst_line: 10,
dst_count: 2,
lines: vec![
Line::DelLine("bar".to_owned()),
Line::AddLine("quux".to_owned()),
Line::AddLine("quux2".to_owned()),
Line::Del("bar".to_owned()),
Line::Add("quux".to_owned()),
Line::Add("quux2".to_owned()),
],
},
];
Expand Down Expand Up @@ -401,8 +401,8 @@ foo bar
"the line right below this one is intentionally empty".to_owned(),
),
Line::Context("".to_owned()),
Line::DelLine("foo".to_owned()),
Line::AddLine("bar".to_owned()),
Line::Del("foo".to_owned()),
Line::Add("bar".to_owned()),
],
}],
},
Expand All @@ -415,9 +415,9 @@ foo bar
dst_line: 10,
dst_count: 2,
lines: vec![
Line::DelLine("bar".to_owned()),
Line::AddLine("quux".to_owned()),
Line::AddLine("quux2".to_owned()),
Line::Del("bar".to_owned()),
Line::Add("quux".to_owned()),
Line::Add("quux2".to_owned()),
],
}],
},
Expand Down Expand Up @@ -493,21 +493,21 @@ foo bar
Line::Context(" }));".to_owned()),
Line::Context(" }".to_owned()),
Line::Context(" }".to_owned()),
Line::AddLine(" ".to_owned()),
Line::AddLine(" pub fn track_index_repo(&self, user: &crate::webserver::middleware::User, repo_ref: RepoRef) {".to_owned()),
Line::AddLine(r#" if let Some(options) = &self.options {"#.to_owned()),
Line::AddLine(r#" self.send(Message::Track(Track {"#.to_owned()),
Line::AddLine(r#" user_id: Some(self.tracking_id(user.username())),"#.to_owned()),
Line::AddLine(r#" event: "index repo".to_owned(),"#.to_owned()),
Line::AddLine(r#" properties: Some(json!({"#.to_owned()),
Line::AddLine(r#" "device_id": self.device_id(),"#.to_owned()),
Line::AddLine(r#" "repo_ref": repo_ref.to_string(),"#.to_owned()),
Line::AddLine(r#" "package_metadata": options.package_metadata,"#.to_owned()),
Line::AddLine(r#" })),"#.to_owned()),
Line::AddLine(r#" ..Default::default()"#.to_owned()),
Line::AddLine(r#" }));"#.to_owned()),
Line::AddLine(r#" }"#.to_owned()),
Line::AddLine(r#" }"#.to_owned()),
Line::Add(" ".to_owned()),
Line::Add(" pub fn track_index_repo(&self, user: &crate::webserver::middleware::User, repo_ref: RepoRef) {".to_owned()),
Line::Add(r#" if let Some(options) = &self.options {"#.to_owned()),
Line::Add(r#" self.send(Message::Track(Track {"#.to_owned()),
Line::Add(r#" user_id: Some(self.tracking_id(user.username())),"#.to_owned()),
Line::Add(r#" event: "index repo".to_owned(),"#.to_owned()),
Line::Add(r#" properties: Some(json!({"#.to_owned()),
Line::Add(r#" "device_id": self.device_id(),"#.to_owned()),
Line::Add(r#" "repo_ref": repo_ref.to_string(),"#.to_owned()),
Line::Add(r#" "package_metadata": options.package_metadata,"#.to_owned()),
Line::Add(r#" })),"#.to_owned()),
Line::Add(r#" ..Default::default()"#.to_owned()),
Line::Add(r#" }));"#.to_owned()),
Line::Add(r#" }"#.to_owned()),
Line::Add(r#" }"#.to_owned()),
Line::Context("}".to_owned()),
Line::Context("".to_owned()),
Line::Context("impl From<Option<String>> for DeviceId {".to_owned()),
Expand All @@ -529,8 +529,8 @@ foo bar
Line::Context(r#""#.to_owned()),
Line::Context(r#" pub(crate) async fn index("#.to_owned()),
Line::Context(r#" &self,"#.to_owned()),
Line::AddLine(r#" analytics: &RudderHub, // Pass in the RudderHub instance"#.to_owned()),
Line::AddLine(r#" user: &crate::webserver::middleware::User, // Pass in the current user"#.to_owned()),
Line::Add(r#" analytics: &RudderHub, // Pass in the RudderHub instance"#.to_owned()),
Line::Add(r#" user: &crate::webserver::middleware::User, // Pass in the current user"#.to_owned()),
Line::Context(r#" sync_handle: &SyncHandle,"#.to_owned()),
Line::Context(r#" repo: &Repository,"#.to_owned()),
Line::Context(r#" ) -> Result<Arc<RepoMetadata>, RepoError> {"#.to_owned()),
Expand All @@ -545,9 +545,9 @@ foo bar
Line::Context(r#""#.to_owned()),
Line::Context(r#" for h in &self.handles {"#.to_owned()),
Line::Context(r#" h.index(sync_handle, repo, &metadata).await?;"#.to_owned()),
Line::AddLine(r#" "#.to_owned()),
Line::AddLine(r#" // Track the repo indexing event"#.to_owned()),
Line::AddLine(r#" analytics.track_index_repo(user, repo.repo_ref.clone());"#.to_owned()),
Line::Add(r#" "#.to_owned()),
Line::Add(r#" // Track the repo indexing event"#.to_owned()),
Line::Add(r#" analytics.track_index_repo(user, repo.repo_ref.clone());"#.to_owned()),
Line::Context(r#" }"#.to_owned()),
Line::Context(r#""#.to_owned()),
Line::Context(r#" Ok(metadata)"#.to_owned()),
Expand All @@ -573,11 +573,11 @@ foo bar
dst_line: 10,
dst_count: 5,
lines: vec![
Line::DelLine("fn main() {".to_owned()),
Line::AddLine("fn main() {".to_owned()),
Line::Del("fn main() {".to_owned()),
Line::Add("fn main() {".to_owned()),
Line::Context(" let a = 123;".to_owned()),
Line::DelLine(" println!(\"the value of `a` is {a:?}\");".to_owned()),
Line::AddLine(" dbg!(&a);".to_owned()),
Line::Del(" println!(\"the value of `a` is {a:?}\");".to_owned()),
Line::Add(" dbg!(&a);".to_owned()),
Line::Context(" drop(a);".to_owned()),
Line::Context("}".to_owned()),
],
Expand All @@ -593,8 +593,8 @@ foo bar
lines: vec![
Line::Context("fn main() {".to_owned()),
Line::Context(" let a = 123;".to_owned()),
Line::DelLine(" println!(\"the value of `a` is {a:?}\");".to_owned()),
Line::AddLine(" dbg!(&a);".to_owned()),
Line::Del(" println!(\"the value of `a` is {a:?}\");".to_owned()),
Line::Add(" dbg!(&a);".to_owned()),
Line::Context(" drop(a);".to_owned()),
Line::Context("}".to_owned()),
],
Expand Down

0 comments on commit 3ff240c

Please sign in to comment.