feat(pack): add raw advertise refs and stateless protocol support
- Add raw flag to AdvertiseRefsRequest to enable raw pkt-line output - Implement advertise_refs_raw function that calls git upload-pack/receive-pack with --advertise-refs - Add stateless flag to GitProtocolFeatures for HTTP smart protocol support - Modify upload_pack and receive_pack to accept stateless parameter - Update command construction to include --stateless-rpc flag when enabled - Add raw_data field to AdvertiseRefsResponse for raw output - Update pack cache key computation to include raw service differentiation - Initialize raw field to false in all request creation calls
This commit is contained in:
+12
-5
@@ -14,8 +14,12 @@ impl GitBare {
|
||||
/// Client-streaming input → server-streaming output.
|
||||
/// Stdin packets are forwarded to the child process as they arrive from the client,
|
||||
/// while stdout is concurrently read and streamed back via a channel.
|
||||
///
|
||||
/// `stateless` enables `--stateless-rpc` for HTTP smart protocol.
|
||||
/// Leave `false` for SSH (persistent connection).
|
||||
pub async fn upload_pack(
|
||||
&self,
|
||||
stateless: bool,
|
||||
input: impl tokio_stream::Stream<Item = Result<crate::pb::UploadPackRequest, tonic::Status>>
|
||||
+ Send
|
||||
+ 'static,
|
||||
@@ -23,6 +27,7 @@ impl GitBare {
|
||||
let bare_dir = self.bare_dir.to_string_lossy().into_owned();
|
||||
tracing::info!(
|
||||
repo = %bare_dir,
|
||||
stateless = stateless,
|
||||
"spawning git upload-pack subprocess"
|
||||
);
|
||||
|
||||
@@ -32,11 +37,13 @@ impl GitBare {
|
||||
let stream = Box::pin(input);
|
||||
tokio::spawn(async move {
|
||||
let stream = stream;
|
||||
let mut child = match Command::new("git")
|
||||
.arg("--git-dir")
|
||||
.arg(&bare_dir)
|
||||
.arg("upload-pack")
|
||||
.arg(&bare_dir)
|
||||
let mut cmd = Command::new("git");
|
||||
cmd.arg("--git-dir").arg(&bare_dir);
|
||||
if stateless {
|
||||
cmd.arg("--stateless-rpc");
|
||||
}
|
||||
cmd.arg("upload-pack").arg(&bare_dir);
|
||||
let mut child = match cmd
|
||||
.stdin(Stdio::piped())
|
||||
.stdout(Stdio::piped())
|
||||
.stderr(Stdio::piped())
|
||||
|
||||
Reference in New Issue
Block a user