diff --git a/crates/tabby-common/src/lib.rs b/crates/tabby-common/src/lib.rs index 9006b20af444..513965d4a0c3 100644 --- a/crates/tabby-common/src/lib.rs +++ b/crates/tabby-common/src/lib.rs @@ -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, @@ -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") } diff --git a/crates/tabby-scheduler/src/cache.rs b/crates/tabby-scheduler/src/cache.rs index ce502132a34a..e6268bacd60e 100644 --- a/crates/tabby-scheduler/src/cache.rs +++ b/crates/tabby-scheduler/src/cache.rs @@ -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), diff --git a/crates/tabby-scheduler/src/index.rs b/crates/tabby-scheduler/src/index.rs index 9d07e53d118a..e9d4750e4e37 100644 --- a/crates/tabby-scheduler/src/index.rs +++ b/crates/tabby-scheduler/src/index.rs @@ -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, @@ -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") @@ -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, @@ -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, ))