feat(api): add comprehensive repository management API endpoints

- Introduce new repo module with complete repository functionality
- Add endpoints for repository CRUD operations (create, get, update, archive, delete)
- Implement branch management with create, list, delete and protection features
- Add tag management with create, list and delete operations
- Include release management with create, update and delete capabilities
- Support repository forking with sync functionality
- Implement starring and watching mechanisms for repositories
- Add member management with roles and invitations
- Provide deploy key management for CI/CD integration
- Create webhook management for external integrations
- Implement branch protection rules with approval requirements
- Add commit status and comment functionality for code reviews
- Include merge checking logic for pull requests
- Register all new endpoints in OpenAPI documentation
- Configure routes to handle new repository-specific paths
This commit is contained in:
zhenyi
2026-06-07 19:19:53 +08:00
parent dca717be10
commit 7368ba676c
78 changed files with 4305 additions and 16 deletions
+207
View File
@@ -0,0 +1,207 @@
use actix_web::web;
pub mod list;
pub mod get;
pub mod create;
pub mod update;
pub mod archive;
pub mod unarchive;
pub mod delete;
pub mod transfer_owner;
pub mod list_branches;
pub mod create_branch;
pub mod set_default_branch;
pub mod set_branch_protection;
pub mod delete_branch;
pub mod list_tags;
pub mod create_tag;
pub mod delete_tag;
pub mod list_releases;
pub mod create_release;
pub mod update_release;
pub mod delete_release;
pub mod list_forks;
pub mod fork_repo;
pub mod sync_fork;
pub mod star_repo;
pub mod unstar_repo;
pub mod list_stargazers;
pub mod watch_repo;
pub mod unwatch_repo;
pub mod list_watchers;
pub mod list_members;
pub mod add_member;
pub mod update_member_role;
pub mod remove_member;
pub mod leave_repo;
pub mod list_invitations;
pub mod create_invitation;
pub mod revoke_invitation;
pub mod accept_invitation;
pub mod list_deploy_keys;
pub mod add_deploy_key;
pub mod delete_deploy_key;
pub mod list_webhooks;
pub mod create_webhook;
pub mod update_webhook;
pub mod delete_webhook;
pub mod list_protection_rules;
pub mod get_protection_rule;
pub mod match_protection;
pub mod create_protection_rule;
pub mod update_protection_rule;
pub mod delete_protection_rule;
pub mod check_branch_merge;
pub mod list_commit_statuses;
pub mod create_commit_status;
pub mod list_commit_comments;
pub mod create_commit_comment;
pub mod resolve_commit_comment;
pub mod get_stats;
pub mod refresh_stats;
pub fn configure(cfg: &mut web::ServiceConfig) {
cfg.service(
web::scope("/workspaces/{workspace_name}/repos")
.route("", web::get().to(list::list))
.route("", web::post().to(create::create))
.route("/{repo_name}", web::get().to(get::get))
.route("/{repo_name}", web::put().to(update::update))
.route("/{repo_name}", web::delete().to(delete::delete))
.route("/{repo_name}/archive", web::post().to(archive::archive))
.route("/{repo_name}/unarchive", web::post().to(unarchive::unarchive))
.route(
"/{repo_name}/transfer-owner",
web::post().to(transfer_owner::transfer_owner),
)
.route("/{repo_name}/branches", web::get().to(list_branches::list_branches))
.route("/{repo_name}/branches", web::post().to(create_branch::create_branch))
.route(
"/{repo_name}/branches/{branch_id}/default",
web::put().to(set_default_branch::set_default_branch),
)
.route(
"/{repo_name}/branches/{branch_id}/protection",
web::put().to(set_branch_protection::set_branch_protection),
)
.route(
"/{repo_name}/branches/{branch_id}",
web::delete().to(delete_branch::delete_branch),
)
.route("/{repo_name}/tags", web::get().to(list_tags::list_tags))
.route("/{repo_name}/tags", web::post().to(create_tag::create_tag))
.route("/{repo_name}/tags/{tag_id}", web::delete().to(delete_tag::delete_tag))
.route("/{repo_name}/releases", web::get().to(list_releases::list_releases))
.route("/{repo_name}/releases", web::post().to(create_release::create_release))
.route(
"/{repo_name}/releases/{release_id}",
web::put().to(update_release::update_release),
)
.route(
"/{repo_name}/releases/{release_id}",
web::delete().to(delete_release::delete_release),
)
.route("/{repo_name}/forks", web::get().to(list_forks::list_forks))
.route("/{repo_name}/fork", web::post().to(fork_repo::fork_repo))
.route("/{repo_name}/sync", web::post().to(sync_fork::sync_fork))
.route("/{repo_name}/star", web::post().to(star_repo::star_repo))
.route("/{repo_name}/star", web::delete().to(unstar_repo::unstar_repo))
.route("/{repo_name}/stargazers", web::get().to(list_stargazers::list_stargazers))
.route("/{repo_name}/watch", web::post().to(watch_repo::watch_repo))
.route("/{repo_name}/watch", web::delete().to(unwatch_repo::unwatch_repo))
.route("/{repo_name}/watchers", web::get().to(list_watchers::list_watchers))
.route("/{repo_name}/members", web::get().to(list_members::list_members))
.route("/{repo_name}/members", web::post().to(add_member::add_member))
.route(
"/{repo_name}/members/{member_id}/role",
web::put().to(update_member_role::update_member_role),
)
.route(
"/{repo_name}/members/{member_id}",
web::delete().to(remove_member::remove_member),
)
.route("/{repo_name}/leave", web::post().to(leave_repo::leave_repo))
.route("/{repo_name}/invitations", web::get().to(list_invitations::list_invitations))
.route(
"/{repo_name}/invitations",
web::post().to(create_invitation::create_invitation),
)
.route(
"/{repo_name}/invitations/{invitation_id}",
web::delete().to(revoke_invitation::revoke_invitation),
)
.route("/{repo_name}/deploy-keys", web::get().to(list_deploy_keys::list_deploy_keys))
.route("/{repo_name}/deploy-keys", web::post().to(add_deploy_key::add_deploy_key))
.route(
"/{repo_name}/deploy-keys/{key_id}",
web::delete().to(delete_deploy_key::delete_deploy_key),
)
.route("/{repo_name}/webhooks", web::get().to(list_webhooks::list_webhooks))
.route("/{repo_name}/webhooks", web::post().to(create_webhook::create_webhook))
.route(
"/{repo_name}/webhooks/{webhook_id}",
web::put().to(update_webhook::update_webhook),
)
.route(
"/{repo_name}/webhooks/{webhook_id}",
web::delete().to(delete_webhook::delete_webhook),
)
.route(
"/{repo_name}/protection-rules",
web::get().to(list_protection_rules::list_protection_rules),
)
.route(
"/{repo_name}/protection-rules",
web::post().to(create_protection_rule::create_protection_rule),
)
.route(
"/{repo_name}/protection-rules/{rule_id}",
web::get().to(get_protection_rule::get_protection_rule),
)
.route(
"/{repo_name}/protection-rules/{rule_id}",
web::put().to(update_protection_rule::update_protection_rule),
)
.route(
"/{repo_name}/protection-rules/{rule_id}",
web::delete().to(delete_protection_rule::delete_protection_rule),
)
.route(
"/{repo_name}/protection/match",
web::get().to(match_protection::match_protection),
)
.route(
"/{repo_name}/branches/{target_branch}/merge-check",
web::get().to(check_branch_merge::check_branch_merge),
)
.route(
"/{repo_name}/commits/{push_commit_id}/statuses",
web::get().to(list_commit_statuses::list_commit_statuses),
)
.route(
"/{repo_name}/commit-statuses",
web::post().to(create_commit_status::create_commit_status),
)
.route(
"/{repo_name}/commits/{push_commit_id}/comments",
web::get().to(list_commit_comments::list_commit_comments),
)
.route(
"/{repo_name}/commit-comments",
web::post().to(create_commit_comment::create_commit_comment),
)
.route(
"/{repo_name}/commit-comments/{comment_id}/resolve",
web::post().to(resolve_commit_comment::resolve_commit_comment),
)
.route("/{repo_name}/stats", web::get().to(get_stats::get_stats))
.route(
"/{repo_name}/stats/refresh",
web::post().to(refresh_stats::refresh_stats),
),
)
.route(
"/repos/invitations/accept",
web::post().to(accept_invitation::accept_invitation),
);
}