clean up
Rust / build (macos-latest, stable) (push) Waiting to run
Rust / build (ubuntu-latest, stable) (push) Waiting to run
Rust / build (windows-latest, stable) (push) Waiting to run
Rust / build (macos-latest, stable) (pull_request) Waiting to run
Rust / build (ubuntu-latest, stable) (pull_request) Waiting to run
Rust / build (windows-latest, stable) (pull_request) Waiting to run

This commit is contained in:
2026-09-13 16:40:50 +07:00
parent 26653fa124
commit 596998810f
4 changed files with 4 additions and 332 deletions
+1 -13
View File
@@ -59,7 +59,6 @@ pub(super) struct RepoFilesView {
commits: HashMap<String, FileCommit>,
pending_commits: Vec<String>,
loading_commits: bool,
generation: u64,
tasks: Vec<Task<Result<(), Error>>>,
}
@@ -80,7 +79,6 @@ impl RepoFilesView {
commits: HashMap::new(),
pending_commits: Vec::new(),
loading_commits: false,
generation: 0,
tasks: Vec::new(),
}
}
@@ -142,7 +140,6 @@ impl RepoFilesView {
self.md = None;
self.code = None;
self.readme_name = None;
self.generation += 1;
}
/// Refresh after the mirror caught up with the remote.
@@ -466,7 +463,6 @@ impl RepoFilesView {
let path = path.to_string();
self.load_commit(&path, cx);
let generation = self.generation;
let task: Task<Result<(), Error>> = cx.spawn_in(window, async move |this, cx| {
let path_for_read = path.clone();
@@ -496,11 +492,6 @@ impl RepoFilesView {
.await;
this.update_in(cx, |this, window, cx| {
if generation != this.generation {
this.loading_files.remove(&path);
return;
}
this.loading_files.remove(&path);
match content {
@@ -616,7 +607,6 @@ impl RepoFilesView {
self.loading_commits = true;
let paths = std::mem::take(&mut self.pending_commits);
let generation = self.generation;
let task: Task<Result<(), Error>> = cx.spawn(async move |this, cx| {
let rels: Vec<PathBuf> = paths.iter().map(PathBuf::from).collect();
@@ -629,9 +619,7 @@ impl RepoFilesView {
this.update(cx, |this, cx| {
this.loading_commits = false;
if generation == this.generation
&& let Ok(found) = result
{
if let Ok(found) = result {
for (path, commit) in found {
this.commits
.insert(path.to_string_lossy().into_owned(), commit);
@@ -23,8 +23,6 @@ pub(super) struct RepoHistoryView {
loading_all_commits: bool,
scroll_handle: VirtualListScrollHandle,
item_sizes: Rc<Vec<Size<Pixels>>>,
/// Bumped on reload, so an in-flight walk of the previous HEAD is discarded.
generation: u64,
tasks: Vec<Task<Result<(), Error>>>,
}
@@ -38,7 +36,6 @@ impl RepoHistoryView {
loading_all_commits: false,
scroll_handle: VirtualListScrollHandle::new(),
item_sizes: Rc::new(Vec::new()),
generation: 0,
tasks: Vec::new(),
}
}
@@ -54,7 +51,6 @@ impl RepoHistoryView {
/// Drop the current list and walk HEAD again.
pub(super) fn reload(&mut self, cx: &mut Context<Self>) {
self.generation += 1;
self.all_commits = None;
self.loading_all_commits = false;
self.load(cx);
@@ -70,7 +66,6 @@ impl RepoHistoryView {
};
self.loading_all_commits = true;
let generation = self.generation;
let task: Task<Result<(), Error>> = cx.spawn(async move |this, cx| {
let result = cx
@@ -78,10 +73,6 @@ impl RepoHistoryView {
.await;
this.update(cx, |this, cx| {
if generation != this.generation {
return;
}
if let Ok(list) = result {
let count = list.commits.len();
this.item_sizes = Rc::new(vec![size(px(0.), px(COMMIT_ROW_HEIGHT)); count]);
+3 -19
View File
@@ -91,7 +91,6 @@ pub struct RepoDetailView {
error: Option<SharedString>,
head_commit: Option<FileCommit>,
refs: RefSwitcher,
ref_generation: u64,
banners: Banners,
tasks: Vec<Task<Result<(), Error>>>,
_subscriptions: Vec<Subscription>,
@@ -191,7 +190,6 @@ impl RepoDetailView {
error: None,
head_commit: None,
refs,
ref_generation: 0,
tasks: Vec::new(),
banners: Banners::default(),
focus_handle: cx.focus_handle(),
@@ -342,16 +340,13 @@ impl RepoDetailView {
let Some(announcement) = announcement else {
return;
};
self.repo_started = true;
let cache = GitStore::global(cx).cache().clone();
let addr = announcement.addr();
let clone_urls: Vec<Url> = announcement.clone.clone();
// Captured before the loads start.
// A branch/tag switch bumps the generation, discarding the refresh below.
let refresh_generation = self.ref_generation;
let disk = {
let cache = cache.clone();
let addr = addr.clone();
@@ -363,7 +358,7 @@ impl RepoDetailView {
})
};
let task: gpui::Task<Result<(), Error>> = cx.spawn_in(window, async move |this, cx| {
let task: Task<Result<(), Error>> = cx.spawn_in(window, async move |this, cx| {
let disk = disk.await;
let had_clone = matches!(&disk, Ok(Some(_)));
@@ -393,7 +388,6 @@ impl RepoDetailView {
// Refresh the clone from the network in the background.
// When it completes, update the refs and commit list.
// Loads started before a branch/tag switch are discarded via the generation.
if !had_clone {
return Ok(());
}
@@ -408,15 +402,10 @@ impl RepoDetailView {
};
// Best-effort, a fetch failure, e.g. offline, keeps the cached state.
// The state is already shown.
signed_git::fetch_all(&repo).ok();
let worktree = repo.workdir().map(Path::to_path_buf);
// A fetch never moves a mirror's local branches.
// A push landing on the grasp servers would never show up.
// That covers own repo pushes from a checkout and updates fetched here.
// Fast-forward branches from the remote, like `git pull --ff-only`.
// Only the checked-out branch's worktree can change on disk.
let moved = match &worktree {
Some(worktree) => {
signed_git::fast_forward_branches(worktree).unwrap_or(false)
@@ -441,10 +430,6 @@ impl RepoDetailView {
.await;
this.update_in(cx, |this, window, cx| {
if refresh_generation != this.ref_generation {
return;
}
if let Ok(Some((moved, branches, tags, current_branch, head_commit))) = refresh {
let branches: Vec<SharedString> = branches.iter().map(Into::into).collect();
let tags: Vec<SharedString> = tags.iter().map(Into::into).collect();
@@ -619,7 +604,6 @@ impl RepoDetailView {
}
self.refs.switching_ref = true;
self.ref_generation += 1;
cx.notify();
let checkout_name = name.clone();