Skip to content

feat: implement commit-user binding#1420

Merged
genedna merged 6 commits into
gitmono-dev:mainfrom
231220075:feat/commit-user-binding
Sep 10, 2025
Merged

feat: implement commit-user binding#1420
genedna merged 6 commits into
gitmono-dev:mainfrom
231220075:feat/commit-user-binding

Conversation

@231220075

Copy link
Copy Markdown
Contributor

Backend Implementation

  • Database Schema: Added commit_auths table to store commit-user associations
  • Storage Layer: Implemented CommitBindingStorage trait with upsert and query capabilities
  • Authentication: Added UserAuthExtractor for identity extraction from AccessToken
  • API Endpoints:
    • GET /api/v1/commits/{sha}/binding - Query commit binding information
    • PUT /api/v1/commits/{sha}/binding - Create/update commit bindings

Frontend Integration

  • React Hook: useGetCommitBinding with React Query for efficient data fetching
  • UI Components: Enhanced CommitHistory and CommitMessageWithAuthor to display user info
  • User Experience: Added avatars, verification badges, and anonymous commit indicators

…st version)

Signed-off-by: Ruizhi Huang <231220075@smail.nju.edu.cn>

feat(commit-message-binding):finish binding commit-message to user (2st version)

Signed-off-by: Ruizhi Huang <231220075@smail.nju.edu.cn>

feat: implement commit-user binding

Signed-off-by: Ruizhi Huang <231220075@smail.nju.edu.cn>
@vercel

vercel Bot commented Sep 8, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
mega Ready Ready Preview Comment Sep 10, 2025 0:15am

This comment was marked as outdated.

queryKey: ['commit-binding', sha],
queryFn: async (): Promise<CommitBindingData> => {
const baseUrl = process.env.NEXT_PUBLIC_MONO_API_URL || process.env.NEXT_PUBLIC_API_URL || 'http://localhost:8000'
const url = `${baseUrl}/api/v1/mega/commits/${sha}`

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@231220075

这里的 URL 和在描述里面写的不一致:

API Endpoints:
GET /api/v1/commits/{sha}/binding - Query commit binding information
PUT /api/v1/commits/{sha}/binding - Create/update commit bindings

Comment thread moon/apps/web/components/CodeView/CommitHistory.tsx Outdated
Comment thread mono/src/api/commit/commit_router.rs Outdated
Comment thread jupiter/callisto/src/commit_auths.rs
Comment thread jupiter/src/storage/user_storage.rs

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

API 请求由swagger 文档直接生成,不建议自己实现

Comment thread gateway/Cargo.toml
…ev#1409)

Signed-off-by: Ruizhi Huang <231220075@smail.nju.edu.cn>
Signed-off-by: Ruizhi Huang <166112492+231220075@users.noreply.github.com>
Signed-off-by: Ruizhi Huang <166112492+231220075@users.noreply.github.com>

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 implements commit-user binding functionality to associate Git commits with authenticated users, enabling better user tracking and attribution in the system.

  • Added database schema for storing commit-user associations with authentication status
  • Implemented storage layer with upsert and query capabilities for commit bindings
  • Created API endpoints for retrieving and updating commit binding information

Reviewed Changes

Copilot reviewed 24 out of 25 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
mono/src/api/commit/ New API module with models and router for commit binding endpoints
mono/src/api/api_router.rs Integration of commit router into main API
jupiter/src/storage/ Database storage implementation and migration for commit_auths table
ceres/src/protocol/smart.rs Git protocol integration for automatic binding during push operations
ceres/src/auth/mod.rs User authentication extraction framework for Git operations
docs/ Updated documentation for database schema and API endpoints

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

Comment thread jupiter/src/tests.rs
commit_binding_storage::CommitBindingStorage, conversation_storage::ConversationStorage,
git_db_storage::GitDbStorage, issue_storage::IssueStorage, lfs_db_storage::LfsDbStorage,
mr_reviewer_storage::MrReviewerStorage, mono_storage::MonoStorage, mr_storage::MrStorage,
raw_db_storage::RawDbStorage,relay_storage::RelayStorage, user_storage::UserStorage,

Copilot AI Sep 10, 2025

Copy link

Choose a reason for hiding this comment

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

Missing space after comma between raw_db_storage::RawDbStorage and relay_storage::RelayStorage.

Suggested change
raw_db_storage::RawDbStorage,relay_storage::RelayStorage, user_storage::UserStorage,
raw_db_storage::RawDbStorage, relay_storage::RelayStorage, user_storage::UserStorage,

Copilot uses AI. Check for mistakes.
Comment thread mono/src/api/commit/commit_router.rs Outdated
Some(UserInfo {
id: user.id.to_string(),
username: user.name.clone(),
display_name: Some(user.name.clone()), // Use name as display_name since display_name field doesn't exist

Copilot AI Sep 10, 2025

Copy link

Choose a reason for hiding this comment

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

The comment indicates that display_name field doesn't exist, but the code is setting it to Some(user.name.clone()). This comment should be updated to clarify the actual behavior or the field should be properly implemented.

Suggested change
display_name: Some(user.name.clone()), // Use name as display_name since display_name field doesn't exist
display_name: Some(user.name.clone()), // Use name as display_name (fallback if no separate display name is available)

Copilot uses AI. Check for mistakes.
)
} else {
// Fallback for cases where user is matched but user info is not available
(binding_model.author_email.split('@').next().unwrap_or(&binding_model.author_email).to_string(), None, false)

Copilot AI Sep 10, 2025

Copy link

Choose a reason for hiding this comment

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

This line is overly complex and hard to read. Consider extracting the email parsing logic into a separate function for better maintainability.

Copilot uses AI. Check for mistakes.
Comment thread ceres/src/protocol/smart.rs Outdated
let matched_user = user_storage.find_user_by_email(&author_email).await?;

if let Some(user) = matched_user {
(Some(user.id.to_string()), false)

Copilot AI Sep 10, 2025

Copy link

Choose a reason for hiding this comment

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

The code is using user.id.to_string() but should be using user.name.clone() to match the matched_username field which expects a username string, not a user ID.

Copilot uses AI. Check for mistakes.
Comment thread ceres/src/protocol/smart.rs Outdated
let matched_user = user_storage.find_user_by_email(&author_email).await?;

if let Some(user) = matched_user {
(Some(user.id.to_string()), false)

Copilot AI Sep 10, 2025

Copy link

Choose a reason for hiding this comment

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

Similar to the previous comment, these lines are using user.id.to_string() but should be using user.name.clone() to match the expected username format for the matched_username field.

Copilot uses AI. Check for mistakes.
Comment thread ceres/src/protocol/smart.rs Outdated
let matched_user = user_storage.find_user_by_email(&author_email).await?;

if let Some(user) = matched_user {
(Some(user.id.to_string()), false)

Copilot AI Sep 10, 2025

Copy link

Choose a reason for hiding this comment

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

Similar to the previous comment, these lines are using user.id.to_string() but should be using user.name.clone() to match the expected username format for the matched_username field.

Copilot uses AI. Check for mistakes.
Comment on lines +178 to +181
if let Ok(commit_obj) = mercury::internal::object::commit::Commit::from_bytes(&entry.data, entry.hash) {
let mut commits = commits_to_process.lock().unwrap();
commits.push((commit_obj.id.to_string(), commit_obj.author.email.clone()));
}

Copilot AI Sep 10, 2025

Copy link

Choose a reason for hiding this comment

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

Parsing commit objects twice (once here and potentially again in the storage layer) is inefficient. Consider reusing the parsed commit object or restructuring to avoid duplicate parsing.

Suggested change
if let Ok(commit_obj) = mercury::internal::object::commit::Commit::from_bytes(&entry.data, entry.hash) {
let mut commits = commits_to_process.lock().unwrap();
commits.push((commit_obj.id.to_string(), commit_obj.author.email.clone()));
}
let mut commits = commits_to_process.lock().unwrap();
commits.push((commit.id.to_string(), commit.author.email.clone()));

Copilot uses AI. Check for mistakes.
Comment thread gateway/src/https_server.rs Outdated
…ev#1409)

Signed-off-by: Ruizhi Huang <231220075@smail.nju.edu.cn>

fix bugs in ceres/src/protocol/smart.rs

Signed-off-by: Ruizhi Huang <231220075@smail.nju.edu.cn>
@genedna
genedna added this pull request to the merge queue Sep 10, 2025
Merged via the queue into gitmono-dev:main with commit 53585b6 Sep 10, 2025
13 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.

4 participants