Skip to content
This repository has been archived by the owner on Jan 2, 2025. It is now read-only.

Fix autocomplete repo match #1218

Merged
merged 2 commits into from
Jan 30, 2024
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
3 changes: 2 additions & 1 deletion server/bleep/src/agent/prompts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ pub fn system<'a>(paths: impl IntoIterator<Item = &'a RepoPath>) -> String {
if iter.peek().is_some() {
s.push_str("\n## PATHS ##\nindex, repo, path\n");
for (i, path) in iter.enumerate() {
let repo = path.repo.display_name();
let repo = &path.repo;
let repo = &format!("{repo}");
let path = &path.path;
s.push_str(&format!("{}, {}, {}\n", i, repo, path));
}
Expand Down
2 changes: 1 addition & 1 deletion server/bleep/src/agent/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ impl Agent {
.to_string(),
token_info_request: TokenInfoRequest {
relative_path: chunk.repo_path.path.clone(),
repo_ref: chunk.repo_path.repo.display_name(),
repo_ref: chunk.repo_path.repo.indexed_name(),
branch: None,
start: range.start.byte,
end: range.end.byte,
Expand Down
2 changes: 1 addition & 1 deletion server/bleep/src/indexes/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ impl File {

let repo_disk_path = builder.add_text_field("repo_disk_path", STRING);
let repo_ref = builder.add_text_field("repo_ref", STRING | STORED);
let repo_name = builder.add_text_field("repo_name", trigram.clone());
let repo_name = builder.add_text_field("repo_name", STRING | STORED);
let relative_path = builder.add_text_field("relative_path", trigram.clone());

let content = builder.add_text_field("content", trigram.clone());
Expand Down
2 changes: 1 addition & 1 deletion server/bleep/src/query/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ pub fn case_permutations(s: &str) -> impl Iterator<Item = CompactString> {

// Make sure not to overflow. The end condition is a mask with the highest bit set, and we use
// `u32` masks.
debug_assert!(chars.len() <= 31);
debug_assert!(chars.len() <= 5);

let num_chars = chars.len();

Expand Down
11 changes: 1 addition & 10 deletions server/bleep/src/repo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,23 +97,14 @@ impl RepoRef {

pub fn indexed_name(&self) -> String {
// Local repos indexed as: dirname
// Github repos indexed as: github.com/org/repo
// Github repos indexed as: org/repo
match self.backend {
Backend::Local => Path::new(&self.name)
.file_name()
.expect("last component is `..`")
.to_string_lossy()
.into(),
Backend::Github => format!("{}", self),
}
}

pub fn display_name(&self) -> String {
match self.backend {
// org_name/repo_name
Backend::Github => self.name.to_owned(),
// repo_name
Backend::Local => self.indexed_name(),
}
}

Expand Down
4 changes: 4 additions & 0 deletions server/bleep/src/webserver/autocomplete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ pub(super) async fn handle(
let queries = parser::parse(&api_params.q)
.map_err(Error::user)?
.into_iter()
.map(|q| parser::Query {
case_sensitive: Some(true),
..q
})
.map(|mut q| {
let keywords = &["lang:", "path:", "repo:"];

Expand Down
1 change: 1 addition & 0 deletions server/bleep/src/webserver/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ pub(super) async fn folder(
repo: Some(parser::Literal::from(&params.repo_ref.indexed_name())),
path: Some(parser::Literal::from(params.path.to_string_lossy())),
branch: params.branch.map(|b| parser::Literal::from(&b)),
case_sensitive: Some(true),
..Default::default()
};

Expand Down
2 changes: 1 addition & 1 deletion server/bleep/src/webserver/repos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ impl From<(&RepoRef, &Repository)> for Repo {

Repo {
provider: key.backend(),
name: key.display_name(),
name: key.indexed_name(),
repo_ref: key.clone(),
sync_status: repo.pub_sync_status.clone(),
local_duplicates: vec![],
Expand Down