From 4c49953572b88cde7cd270c851cd10e9d0ec288c Mon Sep 17 00:00:00 2001 From: ZhenYi <434836402@qq.com> Date: Fri, 17 Apr 2026 15:16:18 +0800 Subject: [PATCH] fix(git): use default_branch in git_commit_log and update API docs - git_commit_log: default to repo.default_branch when rev is None - Update API documentation to reflect default_branch instead of HEAD --- libs/api/git/blob.rs | 2 +- libs/service/git/commit.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libs/api/git/blob.rs b/libs/api/git/blob.rs index b1e0882..83471f1 100644 --- a/libs/api/git/blob.rs +++ b/libs/api/git/blob.rs @@ -13,7 +13,7 @@ use session::Session; params( ("namespace" = String, Path, description = "Project namespace"), ("repo" = String, Path, description = "Repository name"), - ("ref" = Option, Query, description = "Git reference (branch, tag, commit). Defaults to HEAD."), + ("ref" = Option, Query, description = "Git reference (branch, tag, commit). Defaults to the repository's default branch."), ), responses( (status = 401, description = "Unauthorized", body = ApiResponse), diff --git a/libs/service/git/commit.rs b/libs/service/git/commit.rs index 8e52421..126fefd 100644 --- a/libs/service/git/commit.rs +++ b/libs/service/git/commit.rs @@ -786,8 +786,8 @@ impl AppService { let repo = self .utils_find_repo(namespace.clone(), repo_name.clone(), ctx) .await?; - let rev_clone = query.rev.clone(); - let rev_for_count = query.rev.clone(); + let rev_clone = query.rev.clone().or_else(|| Some(repo.default_branch.clone())); + let rev_for_count = rev_clone.clone(); let commits = git_spawn!(repo, domain -> { domain.commit_log(rev_clone.as_deref(), offset, per_page)