feat(core): implement Git repository operations with gRPC services

- Add advertise_refs functionality for Git protocol communication
- Implement archive service with TAR/ZIP format support and streaming
- Create blame service for Git file annotation with line tracking
- Add branch management including create, delete, rename and compare operations
- Implement merge checking with conflict detection and fast-forward handling
- Add cherry-pick functionality for applying commits between branches
- Integrate gix library for Git repository operations and object handling
- Add comprehensive test suite covering all Git operations
- Implement proper error handling and repository validation
- Add pagination support for large result sets
- Create protobuf definitions for all Git operations and data structures
- Add build system for gRPC code generation and dependency management
This commit is contained in:
zhenyi
2026-06-04 13:05:38 +08:00
commit dcb0fb74c5
98 changed files with 20569 additions and 0 deletions
+51
View File
@@ -0,0 +1,51 @@
use std::fs;
use std::path::{Path, PathBuf};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let manifest_dir = PathBuf::from(std::env::var("CARGO_MANIFEST_DIR")?);
let proto_dir = manifest_dir.join("proto");
let out_dir = PathBuf::from(std::env::var("OUT_DIR")?);
fs::create_dir_all(&out_dir)?;
clean_generated_files(&out_dir)?;
let protos = proto_files(&proto_dir)?;
for proto in &protos {
println!("cargo:rerun-if-changed={}", proto.display());
}
println!("cargo:rerun-if-changed={}", proto_dir.display());
println!("cargo:rerun-if-changed=build.rs");
tonic_build::configure()
.build_client(true)
.build_server(true)
.emit_rerun_if_changed(false)
.out_dir(&out_dir)
.compile_protos(&protos, &[proto_dir])?;
Ok(())
}
fn proto_files(proto_dir: &Path) -> Result<Vec<PathBuf>, Box<dyn std::error::Error>> {
let mut files = fs::read_dir(proto_dir)?
.map(|entry| entry.map(|entry| entry.path()))
.collect::<Result<Vec<_>, _>>()?;
files.retain(|path| path.extension().is_some_and(|ext| ext == "proto"));
files.sort();
Ok(files)
}
fn clean_generated_files(out_dir: &Path) -> Result<(), Box<dyn std::error::Error>> {
for entry in fs::read_dir(out_dir)? {
let path = entry?.path();
let is_generated_rs = path.extension().is_some_and(|ext| ext == "rs")
&& path.file_name().is_some_and(|name| name != "mod.rs");
if is_generated_rs {
fs::remove_file(path)?;
}
}
Ok(())
}