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",
|
"/branches/is-conflicted",
|
||||||
web::get().to(branch::git_branch_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", web::get().to(commit::git_commit_log))
|
||||||
.route("/commits/count", web::get().to(commit::git_commit_count))
|
.route("/commits/count", web::get().to(commit::git_commit_count))
|
||||||
.route("/commits", web::post().to(commit::git_commit_create))
|
.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}",
|
"/commits/resolve/{rev}",
|
||||||
web::get().to(commit::git_commit_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::get().to(commit::git_commit_get))
|
||||||
.route("/commits/{oid}", web::patch().to(commit::git_commit_amend))
|
.route("/commits/{oid}", web::patch().to(commit::git_commit_amend))
|
||||||
.route(
|
.route(
|
||||||
@ -193,11 +200,6 @@ pub fn init_git_routes(cfg: &mut web::ServiceConfig) {
|
|||||||
"/commits/{oid}/refs",
|
"/commits/{oid}/refs",
|
||||||
web::get().to(commit::git_commit_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(
|
.route(
|
||||||
"/commits/{oid}/is-tip",
|
"/commits/{oid}/is-tip",
|
||||||
web::get().to(commit::git_commit_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",
|
"/commits/{oid}/ref-count",
|
||||||
web::get().to(commit::git_commit_ref_count),
|
web::get().to(commit::git_commit_ref_count),
|
||||||
)
|
)
|
||||||
.route("/commits/reflog", web::get().to(commit::git_commit_reflog))
|
|
||||||
.route(
|
.route(
|
||||||
"/commits/{oid}/ancestors",
|
"/commits/{oid}/ancestors",
|
||||||
web::get().to(commit::git_commit_ancestors),
|
web::get().to(commit::git_commit_ancestors),
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user