From 81bdab25683086d39b50cd3ea98872bdadb82462 Mon Sep 17 00:00:00 2001 From: Eli Ma Date: Tue, 27 Aug 2024 17:10:10 +0800 Subject: [PATCH 1/3] Add comments for Git LFS router Signed-off-by: Eli Ma --- ceres/src/lfs/handler.rs | 7 +++++-- mono/src/server/https_server.rs | 18 ++++++++++++++---- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/ceres/src/lfs/handler.rs b/ceres/src/lfs/handler.rs index 4641a7438..6737b897f 100644 --- a/ceres/src/lfs/handler.rs +++ b/ceres/src/lfs/handler.rs @@ -177,7 +177,10 @@ pub async fn lfs_delete_lock( } } -/// Process batch request. +/// +/// +/// Reference: +/// 1. [Git LFS Batch API](https://github.com/git-lfs/git-lfs/blob/main/docs/api/batch.md) pub async fn lfs_process_batch( config: &LfsConfig, mut batch_vars: BatchRequest, @@ -197,7 +200,7 @@ pub async fn lfs_process_batch( let found = meta.is_ok(); let mut meta = meta.unwrap_or_default(); if found && lfs_file_exist(config, &meta).await { - // originla download method, split mode use `` + // original download method, split mode use `` response_objects.push(represent(object, &meta, batch_vars.operation == "download", false, false, &server_url).await); continue; } diff --git a/mono/src/server/https_server.rs b/mono/src/server/https_server.rs index 6465a0300..dd449f1e6 100644 --- a/mono/src/server/https_server.rs +++ b/mono/src/server/https_server.rs @@ -172,16 +172,26 @@ pub async fn app(config: Config, host: String, port: u16, common: CommonOptions) .with_state(state) } +/// [LFS Server Discovery](https://github.com/git-lfs/git-lfs/blob/main/docs/api/server-discovery.md) +/// + lazy_static! { - //GET + // Git LFS Protocol + // GET static ref OBJECTS_REGEX: Regex = Regex::new(r"/objects/[a-z0-9]+$").unwrap(); static ref LOCKS_REGEX: Regex = Regex::new(r"/locks$").unwrap(); - static ref INFO_REFS_REGEX: Regex = Regex::new(r"/info/refs$").unwrap(); - //POST + + // POST static ref REGEX_LOCKS_VERIFY: Regex = Regex::new(r"/locks/verify$").unwrap(); static ref REGEX_UNLOCK: Regex = Regex::new(r"/unlock$").unwrap(); static ref REGEX_OBJECTS_BATCH: Regex = Regex::new(r"/objects/batch$").unwrap(); - static ref REGEX_OBJECTS_CHUNKIDS: Regex = Regex::new(r"objects/chunkids$").unwrap(); + // + static ref REGEX_OBJECTS_CHUNKIDS: Regex = Regex::new(r"/objects/chunkids$").unwrap(); + + // Git Protocol + // Get + static ref INFO_REFS_REGEX: Regex = Regex::new(r"/info/refs$").unwrap(); + // POST static ref REGEX_GIT_UPLOAD_PACK: Regex = Regex::new(r"/git-upload-pack$").unwrap(); static ref REGEX_GIT_RECEIVE_PACK: Regex = Regex::new(r"/git-receive-pack$").unwrap(); } From 0f763351a366730bf59661d147ba6cc47540286a Mon Sep 17 00:00:00 2001 From: Quanyi Ma Date: Tue, 27 Aug 2024 23:07:33 +0800 Subject: [PATCH 2/3] Update the comments of https_server.rs Signed-off-by: Quanyi Ma --- mono/src/server/https_server.rs | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/mono/src/server/https_server.rs b/mono/src/server/https_server.rs index dd449f1e6..aaf68157c 100644 --- a/mono/src/server/https_server.rs +++ b/mono/src/server/https_server.rs @@ -172,26 +172,19 @@ pub async fn app(config: Config, host: String, port: u16, common: CommonOptions) .with_state(state) } -/// [LFS Server Discovery](https://github.com/git-lfs/git-lfs/blob/main/docs/api/server-discovery.md) -/// - lazy_static! { - // Git LFS Protocol - // GET + /// The [LFS Server Discovery](https://github.com/git-lfs/git-lfs/blob/main/docs/api/server-discovery.md) discribe the server LFS discovery protocol static ref OBJECTS_REGEX: Regex = Regex::new(r"/objects/[a-z0-9]+$").unwrap(); static ref LOCKS_REGEX: Regex = Regex::new(r"/locks$").unwrap(); - // POST static ref REGEX_LOCKS_VERIFY: Regex = Regex::new(r"/locks/verify$").unwrap(); static ref REGEX_UNLOCK: Regex = Regex::new(r"/unlock$").unwrap(); static ref REGEX_OBJECTS_BATCH: Regex = Regex::new(r"/objects/batch$").unwrap(); - // + static ref REGEX_OBJECTS_CHUNKIDS: Regex = Regex::new(r"/objects/chunkids$").unwrap(); - // Git Protocol - // Get + /// Git Protocol static ref INFO_REFS_REGEX: Regex = Regex::new(r"/info/refs$").unwrap(); - // POST static ref REGEX_GIT_UPLOAD_PACK: Regex = Regex::new(r"/git-upload-pack$").unwrap(); static ref REGEX_GIT_RECEIVE_PACK: Regex = Regex::new(r"/git-receive-pack$").unwrap(); } From e3856620c3c3510a896db5457ac3d21a34496b60 Mon Sep 17 00:00:00 2001 From: Eli Ma Date: Wed, 28 Aug 2024 16:59:42 +0800 Subject: [PATCH 3/3] Update git lfs comments Signed-off-by: Eli Ma --- mono/src/server/https_server.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mono/src/server/https_server.rs b/mono/src/server/https_server.rs index aaf68157c..602b75b10 100644 --- a/mono/src/server/https_server.rs +++ b/mono/src/server/https_server.rs @@ -173,7 +173,11 @@ pub async fn app(config: Config, host: String, port: u16, common: CommonOptions) } lazy_static! { - /// The [LFS Server Discovery](https://github.com/git-lfs/git-lfs/blob/main/docs/api/server-discovery.md) discribe the server LFS discovery protocol + /// The [LFS Server Discovery](https://github.com/git-lfs/git-lfs/blob/main/docs/api/server-discovery.md) + /// document describes the server LFS discovery protocol. + /// + /// The following regular expressions are used to match the LFS server discovery protocol. + /// static ref OBJECTS_REGEX: Regex = Regex::new(r"/objects/[a-z0-9]+$").unwrap(); static ref LOCKS_REGEX: Regex = Regex::new(r"/locks$").unwrap();