Skip to content

Commit 07fb9bd

Browse files
committed
refactor to use all commits actually
1 parent b9e3e5d commit 07fb9bd

File tree

1 file changed

+8
-16
lines changed

1 file changed

+8
-16
lines changed

src/lib/src/core/index/pusher.rs

+8-16
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,14 @@ async fn get_commit_objects_to_sync(
321321
} else {
322322
// Remote branch does not exist. Find commits to push with reference to whatever
323323
// remote branch head comes first in the local newbranch history, aka what it was branched off of.
324+
325+
// Early return to avoid checking for remote commits: if full local history and no remote branch,
326+
// push full local branch history.
327+
if api::local::commits::commit_history_is_complete(local_repo, local_commit) {
328+
return api::local::commits::list_from(local_repo, &local_commit.id);
329+
}
330+
331+
// Otherwise, find the remote commit that the local branch was branched off of and push everything since then.
324332
let all_commits = api::remote::commits::list_all(remote_repo).await?;
325333
log::debug!("got all remote commits as {:#?}", all_commits);
326334
let maybe_remote_commit =
@@ -333,22 +341,6 @@ async fn get_commit_objects_to_sync(
333341
&remote_commit,
334342
local_commit,
335343
)?;
336-
337-
println!("🐂 Getting commit history...");
338-
let remote_history =
339-
api::remote::commits::list_commit_history(remote_repo, &branch.name)
340-
.await
341-
.unwrap_or_else(|_| vec![]);
342-
log::debug!(
343-
"get_commit_objects_to_sync calculated {} commits",
344-
commits_to_sync.len()
345-
);
346-
347-
commits_to_sync.retain(|commit| {
348-
!remote_history
349-
.iter()
350-
.any(|remote_commit| remote_commit.id == commit.id)
351-
});
352344
} else {
353345
commits_to_sync = api::local::commits::list_from(local_repo, &local_commit.id)?;
354346
}

0 commit comments

Comments
 (0)