Compare commits
No commits in common. "ee4ff6c752297e82b272e985b1a37e277e110c46" and "4c49953572b88cde7cd270c851cd10e9d0ec288c" have entirely different histories.
ee4ff6c752
...
4c49953572
@ -54,17 +54,39 @@ 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 - specific routes first, then parameterized routes
|
// branch
|
||||||
.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),
|
||||||
@ -103,29 +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),
|
||||||
)
|
)
|
||||||
// parameterized routes with {name}
|
// commit
|
||||||
.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,13 +139,6 @@ 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(
|
||||||
@ -200,6 +193,11 @@ 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),
|
||||||
@ -208,6 +206,7 @@ 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),
|
||||||
@ -258,14 +257,13 @@ 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 - specific routes first, then parameterized routes
|
// refs
|
||||||
.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/rename", web::patch().to(refs::git_ref_rename))
|
|
||||||
.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::get().to(refs::git_ref_get))
|
||||||
.route("/refs/{name}", web::delete().to(refs::git_ref_delete))
|
.route("/refs/{name}", web::delete().to(refs::git_ref_delete))
|
||||||
|
.route("/refs/rename", web::patch().to(refs::git_ref_rename))
|
||||||
|
.route("/refs/update", web::patch().to(refs::git_ref_update))
|
||||||
.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,13 +133,7 @@ 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(|| {
|
let rev = query.r#ref.unwrap_or_else(|| repo.default_branch.clone());
|
||||||
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,13 +786,7 @@ 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(|| {
|
let rev_clone = query.rev.clone().or_else(|| Some(repo.default_branch.clone()));
|
||||||
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 -> {
|
||||||
@ -859,15 +853,11 @@ 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_ref = if repo.default_branch.is_empty() {
|
let default_branch = repo.default_branch.clone();
|
||||||
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(default_ref.as_deref());
|
let to_ref = to_clone.as_deref().or(Some(default_branch.as_str()));
|
||||||
domain.commit_count(from_ref, to_ref)
|
domain.commit_count(from_ref, to_ref)
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
@ -1286,13 +1276,7 @@ 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().or_else(|| {
|
let rev_clone = query.rev.clone();
|
||||||
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,13 +65,7 @@ impl AppService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let repo_clone = repo.clone();
|
let repo_clone = repo.clone();
|
||||||
let ref_name_clone = query.ref_name.clone().or_else(|| {
|
let ref_name_clone = query.ref_name.clone().or_else(|| Some(repo.default_branch.clone()));
|
||||||
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