Skip to content

fix: adjust get_latest_commit && get_blob API#1576

Merged
benjamin-747 merged 6 commits into
gitmono-dev:mainfrom
231220075:pr-branch
Oct 23, 2025
Merged

fix: adjust get_latest_commit && get_blob API#1576
benjamin-747 merged 6 commits into
gitmono-dev:mainfrom
231220075:pr-branch

Conversation

@231220075

Copy link
Copy Markdown
Contributor

Provide committer data to the get_latest_commit API;
Provide the refs parameter for the get blob API.

231220075 and others added 4 commits October 23, 2025 10:39
Signed-off-by: Ruizhi Huang <231220075@smail.nju.edu.cn>
Signed-off-by: Ruizhi Huang <231220075@smail.nju.edu.cn>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adjusts two API endpoints related to Git operations: get_latest_commit and get_blob. The changes provide committer binding data directly in the commit response and add a refs parameter to the blob retrieval API for branch/tag-specific queries.

  • Adds refs parameter to get_blob_as_string API for retrieving blobs from specific references
  • Modifies get_latest_commit to populate author/committer data from commit bindings instead of returning separate binding info
  • Adds author email and username fields to EditFilePayload to support commit-to-user binding

Reviewed Changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 3 comments.

File Description
mono/src/api/router/preview_router.rs Passes refs parameter to blob retrieval; adds commit binding logic after file edits
mono/src/api/mod.rs Updates blob retrieval call to include new refs parameter (None value)
ceres/src/model/git.rs Adds refs field to BlobContentQuery; removes binding_info from LatestCommitInfo; adds author fields to EditFilePayload
ceres/src/api_service/mod.rs Updates get_blob_as_string signature with refs parameter; modifies commit info population to inline binding data into author/committer fields

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread mono/src/api/router/preview_router.rs Outdated
.api_handler(query.path.as_ref())
.await?
.get_blob_as_string(query.path.into())
.get_blob_as_string(query.path.clone().into(), Some(query.refs.as_str()))

Copilot AI Oct 23, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The query.path is cloned here but was previously consumed by into(). Since query.path is used only once, consider using query.path.into() without cloning to avoid unnecessary allocation.

Suggested change
.get_blob_as_string(query.path.clone().into(), Some(query.refs.as_str()))
.get_blob_as_string(query.path.into(), Some(query.refs.as_str()))

Copilot uses AI. Check for mistakes.
Comment thread ceres/src/api_service/mod.rs Outdated
Comment on lines +122 to +126
// Fill both author and committer for UI consumption
commit_info.author.display_name = display.clone();
commit_info.author.avatar_url = avatar.clone();
commit_info.committer.display_name = display;
commit_info.committer.avatar_url = avatar;

Copilot AI Oct 23, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The binding information unconditionally overwrites both author and committer data. This loses the original Git commit author/committer information. Consider preserving the original data or making this behavior explicit, as it may confuse users expecting to see actual Git metadata.

Suggested change
// Fill both author and committer for UI consumption
commit_info.author.display_name = display.clone();
commit_info.author.avatar_url = avatar.clone();
commit_info.committer.display_name = display;
commit_info.committer.avatar_url = avatar;
// Fill author fields with binding info, preserve original committer info
commit_info.author.display_name = display.clone();
commit_info.author.avatar_url = avatar.clone();
// Do not overwrite committer fields to preserve original Git metadata
// commit_info.committer.display_name = display;
// commit_info.committer.avatar_url = avatar;

Copilot uses AI. Check for mistakes.
Comment thread mono/src/api/router/preview_router.rs Outdated
false,
)
.await
.map_err(|e| ApiError::from(anyhow::anyhow!("Failed to update commit binding: {}", e)))?;

Copilot AI Oct 23, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message 'Failed to update commit binding' is misleading since upsert_binding performs both insert and update operations. Consider using 'Failed to save commit binding' for clarity.

Suggested change
.map_err(|e| ApiError::from(anyhow::anyhow!("Failed to update commit binding: {}", e)))?;
.map_err(|e| ApiError::from(anyhow::anyhow!("Failed to save commit binding: {}", e)))?;

Copilot uses AI. Check for mistakes.
@benjamin-747

Copy link
Copy Markdown
Collaborator

link #1555

@benjamin-747 benjamin-747 added this pull request to the merge queue Oct 23, 2025
Merged via the queue into gitmono-dev:main with commit 8a37f60 Oct 23, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants