fix(api): fix commit route order to prevent InvalidOid("reflog") error
Move specific routes (/commits/reflog, /commits/branches, /commits/tags)
before parameterized routes (/commits/{oid}) to avoid route shadowing.
Previously, /commits/reflog was matched by /commits/{oid} with oid="reflog",
causing InvalidOid("reflog") errors.
Also fixes other potential route shadowing issues in commit routes.
This commit is contained in:
parent
82ed726848
commit
4cee9975d5
@ -125,7 +125,7 @@ pub fn init_git_routes(cfg: &mut web::ServiceConfig) {
|
||||
"/branches/is-conflicted",
|
||||
web::get().to(branch::git_branch_is_conflicted),
|
||||
)
|
||||
// commit
|
||||
// commit - specific routes first, then parameterized routes
|
||||
.route("/commits", web::get().to(commit::git_commit_log))
|
||||
.route("/commits/count", web::get().to(commit::git_commit_count))
|
||||
.route("/commits", web::post().to(commit::git_commit_create))
|
||||
@ -139,6 +139,13 @@ pub fn init_git_routes(cfg: &mut web::ServiceConfig) {
|
||||
"/commits/resolve/{rev}",
|
||||
web::get().to(commit::git_commit_resolve_rev),
|
||||
)
|
||||
.route("/commits/reflog", web::get().to(commit::git_commit_reflog))
|
||||
.route(
|
||||
"/commits/branches",
|
||||
web::get().to(commit::git_commit_branches),
|
||||
)
|
||||
.route("/commits/tags", web::get().to(commit::git_commit_tags))
|
||||
// parameterized routes with {oid}
|
||||
.route("/commits/{oid}", web::get().to(commit::git_commit_get))
|
||||
.route("/commits/{oid}", web::patch().to(commit::git_commit_amend))
|
||||
.route(
|
||||
@ -193,11 +200,6 @@ pub fn init_git_routes(cfg: &mut web::ServiceConfig) {
|
||||
"/commits/{oid}/refs",
|
||||
web::get().to(commit::git_commit_refs),
|
||||
)
|
||||
.route(
|
||||
"/commits/branches",
|
||||
web::get().to(commit::git_commit_branches),
|
||||
)
|
||||
.route("/commits/tags", web::get().to(commit::git_commit_tags))
|
||||
.route(
|
||||
"/commits/{oid}/is-tip",
|
||||
web::get().to(commit::git_commit_is_tip),
|
||||
@ -206,7 +208,6 @@ pub fn init_git_routes(cfg: &mut web::ServiceConfig) {
|
||||
"/commits/{oid}/ref-count",
|
||||
web::get().to(commit::git_commit_ref_count),
|
||||
)
|
||||
.route("/commits/reflog", web::get().to(commit::git_commit_reflog))
|
||||
.route(
|
||||
"/commits/{oid}/ancestors",
|
||||
web::get().to(commit::git_commit_ancestors),
|
||||
|
||||
Loading…
Reference in New Issue
Block a user