Compare commits
4 Commits
4c49953572
...
ee4ff6c752
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ee4ff6c752 | ||
|
|
1272615d50 | ||
|
|
4cee9975d5 | ||
|
|
82ed726848 |
@ -54,39 +54,17 @@ pub fn init_git_routes(cfg: &mut web::ServiceConfig) {
|
|||||||
.route("/blob/{oid}/content", web::get().to(blob::git_blob_content))
|
.route("/blob/{oid}/content", web::get().to(blob::git_blob_content))
|
||||||
.route("/blob/{oid}/size", web::get().to(blob::git_blob_size))
|
.route("/blob/{oid}/size", web::get().to(blob::git_blob_size))
|
||||||
.route("/readme", web::get().to(blob::git_readme))
|
.route("/readme", web::get().to(blob::git_readme))
|
||||||
// branch
|
// branch - specific routes first, then parameterized routes
|
||||||
.route("/branches", web::get().to(branch::git_branch_list))
|
.route("/branches", web::get().to(branch::git_branch_list))
|
||||||
.route(
|
.route(
|
||||||
"/branches/summary",
|
"/branches/summary",
|
||||||
web::get().to(branch::git_branch_summary),
|
web::get().to(branch::git_branch_summary),
|
||||||
)
|
)
|
||||||
.route("/branches", web::post().to(branch::git_branch_create))
|
.route("/branches", web::post().to(branch::git_branch_create))
|
||||||
// NOTE: /branches/current MUST be before /branches/{name} to avoid being shadowed
|
|
||||||
.route(
|
.route(
|
||||||
"/branches/current",
|
"/branches/current",
|
||||||
web::get().to(branch::git_branch_current),
|
web::get().to(branch::git_branch_current),
|
||||||
)
|
)
|
||||||
.route("/branches/{name}", web::get().to(branch::git_branch_get))
|
|
||||||
.route(
|
|
||||||
"/branches/{name}",
|
|
||||||
web::delete().to(branch::git_branch_delete),
|
|
||||||
)
|
|
||||||
.route(
|
|
||||||
"/branches/{name}/exists",
|
|
||||||
web::get().to(branch::git_branch_exists),
|
|
||||||
)
|
|
||||||
.route(
|
|
||||||
"/branches/{name}/is-head",
|
|
||||||
web::get().to(branch::git_branch_is_head),
|
|
||||||
)
|
|
||||||
.route(
|
|
||||||
"/branches/{name}/upstream",
|
|
||||||
web::get().to(branch::git_branch_upstream),
|
|
||||||
)
|
|
||||||
.route(
|
|
||||||
"/branches/{name}/tracking-difference",
|
|
||||||
web::get().to(branch::git_branch_tracking_difference),
|
|
||||||
)
|
|
||||||
.route(
|
.route(
|
||||||
"/branches/remote/{name}",
|
"/branches/remote/{name}",
|
||||||
web::delete().to(branch::git_branch_delete_remote),
|
web::delete().to(branch::git_branch_delete_remote),
|
||||||
@ -125,7 +103,29 @@ 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
|
// parameterized routes with {name}
|
||||||
|
.route("/branches/{name}", web::get().to(branch::git_branch_get))
|
||||||
|
.route(
|
||||||
|
"/branches/{name}",
|
||||||
|
web::delete().to(branch::git_branch_delete),
|
||||||
|
)
|
||||||
|
.route(
|
||||||
|
"/branches/{name}/exists",
|
||||||
|
web::get().to(branch::git_branch_exists),
|
||||||
|
)
|
||||||
|
.route(
|
||||||
|
"/branches/{name}/is-head",
|
||||||
|
web::get().to(branch::git_branch_is_head),
|
||||||
|
)
|
||||||
|
.route(
|
||||||
|
"/branches/{name}/upstream",
|
||||||
|
web::get().to(branch::git_branch_upstream),
|
||||||
|
)
|
||||||
|
.route(
|
||||||
|
"/branches/{name}/tracking-difference",
|
||||||
|
web::get().to(branch::git_branch_tracking_difference),
|
||||||
|
)
|
||||||
|
// 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),
|
||||||
@ -257,13 +258,14 @@ pub fn init_git_routes(cfg: &mut web::ServiceConfig) {
|
|||||||
"/diff/side-by-side",
|
"/diff/side-by-side",
|
||||||
web::get().to(diff::git_diff_side_by_side),
|
web::get().to(diff::git_diff_side_by_side),
|
||||||
)
|
)
|
||||||
// refs
|
// refs - specific routes first, then parameterized routes
|
||||||
.route("/refs", web::get().to(refs::git_ref_list))
|
.route("/refs", web::get().to(refs::git_ref_list))
|
||||||
.route("/refs", web::post().to(refs::git_ref_create))
|
.route("/refs", web::post().to(refs::git_ref_create))
|
||||||
.route("/refs/{name}", web::get().to(refs::git_ref_get))
|
|
||||||
.route("/refs/{name}", web::delete().to(refs::git_ref_delete))
|
|
||||||
.route("/refs/rename", web::patch().to(refs::git_ref_rename))
|
.route("/refs/rename", web::patch().to(refs::git_ref_rename))
|
||||||
.route("/refs/update", web::patch().to(refs::git_ref_update))
|
.route("/refs/update", web::patch().to(refs::git_ref_update))
|
||||||
|
// parameterized routes with {name}
|
||||||
|
.route("/refs/{name}", web::get().to(refs::git_ref_get))
|
||||||
|
.route("/refs/{name}", web::delete().to(refs::git_ref_delete))
|
||||||
.route("/refs/{name}/exists", web::get().to(refs::git_ref_exists))
|
.route("/refs/{name}/exists", web::get().to(refs::git_ref_exists))
|
||||||
.route("/refs/{name}/target", web::get().to(refs::git_ref_target))
|
.route("/refs/{name}/target", web::get().to(refs::git_ref_target))
|
||||||
// repo (description, config, merge)
|
// repo (description, config, merge)
|
||||||
|
|||||||
@ -133,7 +133,13 @@ impl AppService {
|
|||||||
let repo = self
|
let repo = self
|
||||||
.utils_find_repo(namespace.clone(), repo_name.clone(), ctx)
|
.utils_find_repo(namespace.clone(), repo_name.clone(), ctx)
|
||||||
.await?;
|
.await?;
|
||||||
let rev = query.r#ref.unwrap_or_else(|| repo.default_branch.clone());
|
let rev = query.r#ref.unwrap_or_else(|| {
|
||||||
|
if repo.default_branch.is_empty() {
|
||||||
|
"HEAD".to_string()
|
||||||
|
} else {
|
||||||
|
format!("refs/heads/{}", repo.default_branch)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
let tree_oid: git::CommitOid = {
|
let tree_oid: git::CommitOid = {
|
||||||
let rev_clone = rev.clone();
|
let rev_clone = rev.clone();
|
||||||
|
|||||||
@ -786,7 +786,13 @@ impl AppService {
|
|||||||
let repo = self
|
let repo = self
|
||||||
.utils_find_repo(namespace.clone(), repo_name.clone(), ctx)
|
.utils_find_repo(namespace.clone(), repo_name.clone(), ctx)
|
||||||
.await?;
|
.await?;
|
||||||
let rev_clone = query.rev.clone().or_else(|| Some(repo.default_branch.clone()));
|
let rev_clone = query.rev.clone().or_else(|| {
|
||||||
|
if repo.default_branch.is_empty() {
|
||||||
|
None
|
||||||
|
} else {
|
||||||
|
Some(format!("refs/heads/{}", repo.default_branch))
|
||||||
|
}
|
||||||
|
});
|
||||||
let rev_for_count = rev_clone.clone();
|
let rev_for_count = rev_clone.clone();
|
||||||
|
|
||||||
let commits = git_spawn!(repo, domain -> {
|
let commits = git_spawn!(repo, domain -> {
|
||||||
@ -853,11 +859,15 @@ impl AppService {
|
|||||||
let repo = self.utils_find_repo(namespace, repo_name, ctx).await?;
|
let repo = self.utils_find_repo(namespace, repo_name, ctx).await?;
|
||||||
let from_clone = from.clone();
|
let from_clone = from.clone();
|
||||||
let to_clone = to.clone();
|
let to_clone = to.clone();
|
||||||
let default_branch = repo.default_branch.clone();
|
let default_ref = if repo.default_branch.is_empty() {
|
||||||
|
None
|
||||||
|
} else {
|
||||||
|
Some(format!("refs/heads/{}", repo.default_branch))
|
||||||
|
};
|
||||||
|
|
||||||
let count = git_spawn!(repo, domain -> {
|
let count = git_spawn!(repo, domain -> {
|
||||||
let from_ref = from_clone.as_deref();
|
let from_ref = from_clone.as_deref();
|
||||||
let to_ref = to_clone.as_deref().or(Some(default_branch.as_str()));
|
let to_ref = to_clone.as_deref().or(default_ref.as_deref());
|
||||||
domain.commit_count(from_ref, to_ref)
|
domain.commit_count(from_ref, to_ref)
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
@ -1276,7 +1286,13 @@ impl AppService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let repo = self.utils_find_repo(namespace, repo_name, ctx).await?;
|
let repo = self.utils_find_repo(namespace, repo_name, ctx).await?;
|
||||||
let rev_clone = query.rev.clone();
|
let rev_clone = query.rev.clone().or_else(|| {
|
||||||
|
if repo.default_branch.is_empty() {
|
||||||
|
None
|
||||||
|
} else {
|
||||||
|
Some(format!("refs/heads/{}", repo.default_branch))
|
||||||
|
}
|
||||||
|
});
|
||||||
let limit = query.limit.unwrap_or(0);
|
let limit = query.limit.unwrap_or(0);
|
||||||
let first_parent_only = query.first_parent_only;
|
let first_parent_only = query.first_parent_only;
|
||||||
let topological = query.topological;
|
let topological = query.topological;
|
||||||
|
|||||||
@ -65,7 +65,13 @@ impl AppService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let repo_clone = repo.clone();
|
let repo_clone = repo.clone();
|
||||||
let ref_name_clone = query.ref_name.clone().or_else(|| Some(repo.default_branch.clone()));
|
let ref_name_clone = query.ref_name.clone().or_else(|| {
|
||||||
|
if repo.default_branch.is_empty() {
|
||||||
|
None
|
||||||
|
} else {
|
||||||
|
Some(format!("refs/heads/{}", repo.default_branch))
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
let commits = tokio::task::spawn_blocking(move || {
|
let commits = tokio::task::spawn_blocking(move || {
|
||||||
let domain = git::GitDomain::from_model(repo_clone)?;
|
let domain = git::GitDomain::from_model(repo_clone)?;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user