Skip to content

Conversation

@231220075
Copy link
Contributor

rm user table;
fix tag pointing to wrong tree hash;
adjust get latest commit on single file;
fix get latest commit API bug with specific file paths.

Signed-off-by: Ruizhi Huang <[email protected]>

cargo fmt

Signed-off-by: Ruizhi Huang <[email protected]>
@genedna genedna requested review from benjamin-747 and Copilot and removed request for Copilot October 28, 2025 14:19
Copy link
Contributor

Copilot AI left a comment

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 refactors the user management architecture by removing the local user table and simplifying commit binding to use only usernames. The key changes include removing email-based user lookups, eliminating the UserAuthExtractor trait, and fixing tag creation to point to the correct tree hash instead of ZERO_ID. Additionally, it improves the get-latest-commit logic for single files by implementing a proper commit history traversal algorithm.

Reviewed Changes

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

Show a summary per file
File Description
mono/src/api/router/preview_router.rs Simplified commit binding to use username-only model with anonymous fallback
mono/src/api/router/commit_router.rs Removed user validation and simplified binding update to username-only
mono/src/api/oauth/model.rs Removed dependency on user::Model and updated conversions to use LoginUser
mono/src/api/oauth/mod.rs Removed user persistence, directly converting GitHub user to session
jupiter/src/storage/user_storage.rs Removed user lookup methods (find by email/name, save user)
jupiter/src/storage/mono_storage.rs Simplified commit binding to accept authenticated username directly
jupiter/src/storage/commit_binding_storage.rs Removed author_email parameter from upsert_binding
jupiter/src/service/blame_service.rs Updated to username-only model, removed email extraction logic
jupiter/src/model/blame_dto.rs Removed user verification fields from CommitBindingInfo
jupiter/src/migration/mod.rs Added migration to drop user table
jupiter/src/migration/m20251026_065433_drop_user_table.rs New migration that drops user table and author_email column
jupiter/callisto/src/*.rs Updated SeaORM codegen version to 1.1.17
jupiter/callisto/src/user.rs Removed entire user entity model
jupiter/callisto/src/commit_auths.rs Removed author_email field from model
ceres/src/protocol/smart.rs Simplified commit binding to username-only, removed email extraction
ceres/src/protocol/mod.rs Moved PushUserInfo to local definition with username only
ceres/src/model/git.rs Removed user verification fields from CommitBindingInfo
ceres/src/model/commit.rs Simplified response to contain only username
ceres/src/lib.rs Removed auth module
ceres/src/auth/mod.rs Deleted entire auth module
ceres/src/api_service/mono_api_service.rs Fixed tag creation to resolve tree hash from commit; improved get-latest-commit filtering
ceres/src/api_service/mod.rs Implemented precise commit history traversal for file paths

Comment on lines +303 to +304
let mut steps: u32 = 0;
const MAX_STEPS: u32 = 10_000;
Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

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

The constant MAX_STEPS is defined inside the loop function. Consider moving it to a module-level constant or as an associated constant to improve maintainability and avoid re-defining it on each call.

Copilot uses AI. Check for mistakes.
Comment on lines +82 to +89
let final_username = json.author_username.as_deref().and_then(|u| {
let t = u.trim();
if t.is_empty() || t.eq_ignore_ascii_case("anonymous") {
None
} else {
Some(t.to_string())
}
});
Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

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

This username normalization logic is duplicated in both create_entry and save_edit functions. Consider extracting it into a helper function to reduce code duplication and improve maintainability.

Copilot uses AI. Check for mistakes.
Signed-off-by: Ruizhi Huang <[email protected]>
@genedna genedna requested a review from Copilot October 28, 2025 14:42
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

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

Comment on lines +109 to +111
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
// No-op: we don't recreate the legacy users table
let _ = manager; // silence unused warning in some compilers
Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

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

Rather than silencing the unused parameter warning with let _ = manager;, mark the parameter as unused with an underscore prefix _manager in the function signature. This is more idiomatic Rust.

Suggested change
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
// No-op: we don't recreate the legacy users table
let _ = manager; // silence unused warning in some compilers
async fn down(&self, _manager: &SchemaManager) -> Result<(), DbErr> {
// No-op: we don't recreate the legacy users table

Copilot uses AI. Check for mistakes.

let mut curr_commit = head_commit.clone();
// Safety guard to avoid pathological loops on very deep histories
let mut steps: u32 = 0;
Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

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

The magic number 10,000 for MAX_STEPS should be documented. Consider adding a comment explaining why this limit was chosen and what scenarios it protects against (e.g., repository size, expected history depth).

Suggested change
let mut steps: u32 = 0;
let mut steps: u32 = 0;
// Limit the number of commit history traversal steps to prevent excessive resource usage
// in pathological cases (e.g., extremely deep or cyclic histories in very large monorepos).
// The value 10,000 was chosen as a conservative upper bound, which should be far greater
// than the expected depth of commit history for any normal repository, even at Mega scale.
// If this limit is reached, the function falls back to returning the HEAD commit to avoid
// timeouts or runaway resource consumption. Adjust this value if repository characteristics change.

Copilot uses AI. Check for mistakes.
Comment on lines +297 to +301
let Some(mut curr_blob) = current_blob else {
return Ok(None);
};

let mut curr_commit = head_commit.clone();
Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

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

[nitpick] Using let-else with mut for curr_blob is correct, but consider whether mutability is needed from the start. The variable is reassigned in the loop body (line 344), so the mut is justified, but worth reviewing if the algorithm could be restructured to reduce mutability.

Suggested change
let Some(mut curr_blob) = current_blob else {
return Ok(None);
};
let mut curr_commit = head_commit.clone();
let Some(curr_blob) = current_blob else {
return Ok(None);
};
let mut curr_commit = head_commit.clone();
let mut curr_blob = curr_blob;

Copilot uses AI. Check for mistakes.
@genedna genedna requested a review from Copilot October 28, 2025 15:17
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 66 out of 66 changed files in this pull request and generated 1 comment.

Comment on lines +115 to +119
if let Ok(Some(binding)) = self.build_commit_binding_info(&commit.id.to_string()).await
&& !binding.is_anonymous
&& binding.matched_username.is_some()
{
let username = binding.matched_username.unwrap();
Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

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

The pattern of checking binding.matched_username.is_some() followed by unwrap() appears twice (lines 115-120 and 146-153). Consider using if let Some(username) = binding.matched_username pattern instead to make the code more idiomatic and avoid the redundant check.

Copilot uses AI. Check for mistakes.
@benjamin-747 benjamin-747 added this pull request to the merge queue Oct 29, 2025
Merged via the queue into web3infra-foundation:main with commit 7827e69 Oct 29, 2025
7 checks passed
@231220075
Copy link
Contributor Author

link(#1562 )

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.

2 participants