Skip to content

Commit

Permalink
Get git_url from RepositoryConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
boxbeam committed May 6, 2024
1 parent 10939fd commit 59af2e1
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 10 deletions.
5 changes: 0 additions & 5 deletions crates/tabby-common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ use serde_jsonlines::JsonLinesReader;

#[derive(Serialize, Deserialize, Clone)]
pub struct SourceFile {
pub git_url: String,
pub basedir: String,
pub filepath: String,
pub language: String,
Expand All @@ -38,10 +37,6 @@ impl SourceFile {
format!("{}:{}", git_url, filepath)
}

pub fn file_id(&self) -> String {
Self::create_file_id(&self.git_url, &self.filepath)
}

pub fn files_jsonl() -> PathBuf {
dataset_dir().join("files.jsonl")
}
Expand Down
1 change: 0 additions & 1 deletion crates/tabby-scheduler/src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,6 @@ fn create_source_file(
}
};
let source_file = SourceFile {
git_url: config.canonical_git_url(),
basedir: config.dir().display().to_string(),
filepath: relative_path.display().to_string(),
max_line_length: metrics::max_line_length(&contents),
Expand Down
9 changes: 5 additions & 4 deletions crates/tabby-scheduler/src/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ pub fn index_repositories(config: &[RepositoryConfig]) {
if !is_valid_file(&source_file) {
continue;
}
add_indexed_source_file(&writer, &source_file, &code, &intelligence);
add_indexed_source_file(&writer, repository, &source_file, &code, &intelligence);
}
cache.set_last_index_commit(
repository,
Expand Down Expand Up @@ -107,7 +107,7 @@ fn index_repository_from_scratch(
if !is_valid_file(&source_file) {
continue;
}
add_indexed_source_file(writer, &source_file, code, intelligence);
add_indexed_source_file(writer, repository, &source_file, code, intelligence);
pb.as_mut().map(|pb| {
pb.update(source_file.read_file_size())
.expect("Failed to update progress bar")
Expand Down Expand Up @@ -150,6 +150,7 @@ pub fn delete_all_indexed_files(writer: &IndexWriter, code: &CodeSearchSchema, g

pub fn add_indexed_source_file(
writer: &IndexWriter,
repository: &RepositoryConfig,
file: &SourceFile,
code: &CodeSearchSchema,
intelligence: &CodeIntelligence,
Expand All @@ -164,9 +165,9 @@ pub fn add_indexed_source_file(
for body in intelligence.chunks(&text) {
writer
.add_document(doc!(
code.field_git_url => file.git_url.clone(),
code.field_git_url => repository.canonical_git_url(),
code.field_filepath => file.filepath.clone(),
code.field_file_id => file.file_id(),
code.field_file_id => SourceFile::create_file_id(&repository.git_url, &file.filepath),
code.field_language => file.language.clone(),
code.field_body => body,
))
Expand Down

0 comments on commit 59af2e1

Please sign in to comment.