Add path-filtered repository history
This commit is contained in:
@@ -450,9 +450,10 @@ pub async fn load_branch_commits(
|
||||
owner: &str,
|
||||
repository: &str,
|
||||
branch: &str,
|
||||
path: Option<&str>,
|
||||
pages: u32,
|
||||
) -> Result<Page<HistoryCommit>, String> {
|
||||
load_commits_for_ref(server, owner, repository, Some(branch), pages)
|
||||
load_commits_for_ref(server, owner, repository, Some(branch), path, pages)
|
||||
.await
|
||||
.map(|page| Page {
|
||||
has_more: page.has_more,
|
||||
@@ -476,15 +477,24 @@ pub async fn load_all_commits(
|
||||
owner: &str,
|
||||
repository: &str,
|
||||
branches: &[String],
|
||||
path: Option<&str>,
|
||||
pages: u32,
|
||||
) -> Result<Page<HistoryCommit>, String> {
|
||||
let mut tasks = JoinSet::new();
|
||||
for (lane, branch) in branches.iter().cloned().enumerate() {
|
||||
let (server, owner, repository) =
|
||||
(server.clone(), owner.to_string(), repository.to_string());
|
||||
let path = path.map(str::to_string);
|
||||
tasks.spawn(async move {
|
||||
let commits =
|
||||
load_commits_for_ref(&server, &owner, &repository, Some(&branch), pages).await?;
|
||||
let commits = load_commits_for_ref(
|
||||
&server,
|
||||
&owner,
|
||||
&repository,
|
||||
Some(&branch),
|
||||
path.as_deref(),
|
||||
pages,
|
||||
)
|
||||
.await?;
|
||||
Ok::<_, String>((lane, branch, commits))
|
||||
});
|
||||
}
|
||||
@@ -1024,6 +1034,7 @@ async fn load_commits_for_ref(
|
||||
owner: &str,
|
||||
repository: &str,
|
||||
branch: Option<&str>,
|
||||
path: Option<&str>,
|
||||
pages: u32,
|
||||
) -> Result<Page<models::Commit>, String> {
|
||||
let client =
|
||||
@@ -1037,7 +1048,7 @@ async fn load_commits_for_ref(
|
||||
owner,
|
||||
repository,
|
||||
branch,
|
||||
None,
|
||||
path,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
|
||||
@@ -599,6 +599,7 @@ impl GotchaCore {
|
||||
owner: String,
|
||||
repository: String,
|
||||
branch: Option<String>,
|
||||
path: String,
|
||||
pages: u32,
|
||||
) -> Result<CommitPage, GotchaError> {
|
||||
let server = self.server()?;
|
||||
@@ -612,11 +613,16 @@ impl GotchaCore {
|
||||
.map(|candidate| candidate.default_branch.clone())
|
||||
.unwrap_or_else(|| "main".into());
|
||||
let branches = load_branches(&server, &owner, &repository, &default_branch).await?;
|
||||
let path = (!path.is_empty()).then_some(path.as_str());
|
||||
let commits = match branch.as_deref() {
|
||||
Some(branch) => {
|
||||
load_branch_commits(&server, &owner, &repository, branch, pages.max(1)).await?
|
||||
load_branch_commits(&server, &owner, &repository, branch, path, pages.max(1))
|
||||
.await?
|
||||
}
|
||||
None => {
|
||||
load_all_commits(&server, &owner, &repository, &branches, path, pages.max(1))
|
||||
.await?
|
||||
}
|
||||
None => load_all_commits(&server, &owner, &repository, &branches, pages.max(1)).await?,
|
||||
};
|
||||
Ok(commit_page(
|
||||
branches,
|
||||
|
||||
Reference in New Issue
Block a user