From 8032c3590253587ea532d93f13510ff040564b58 Mon Sep 17 00:00:00 2001 From: Stephan Dilly Date: Mon, 7 Jun 2021 23:04:07 +0200 Subject: [PATCH] refactor better name --- asyncgit/src/blame.rs | 10 +++++----- asyncgit/src/commit_files.rs | 8 ++++---- asyncgit/src/diff.rs | 10 +++++----- asyncgit/src/fetch.rs | 10 +++++----- asyncgit/src/lib.rs | 2 +- asyncgit/src/push.rs | 10 +++++----- asyncgit/src/push_tags.rs | 10 +++++----- asyncgit/src/remote_progress.rs | 6 +++--- asyncgit/src/revlog.rs | 14 ++++++++------ asyncgit/src/status.rs | 8 ++++---- asyncgit/src/tags.rs | 10 +++++----- src/app.rs | 6 +++--- src/components/blame_file.rs | 8 ++++---- src/components/commit_details/mod.rs | 4 ++-- src/components/inspect_commit.rs | 10 +++++----- src/components/pull.rs | 9 +++++---- src/components/push.rs | 8 ++++---- src/components/push_tags.rs | 8 ++++---- src/components/revision_files.rs | 6 +++--- src/components/revision_files_popup.rs | 6 +++--- src/components/syntax_text.rs | 12 ++++++------ src/main.rs | 9 +++++---- src/tabs/files.rs | 6 +++--- src/tabs/revlog.rs | 12 ++++++------ src/tabs/stashing.rs | 8 ++++---- src/tabs/status.rs | 20 +++++++++++--------- 26 files changed, 118 insertions(+), 112 deletions(-) diff --git a/asyncgit/src/blame.rs b/asyncgit/src/blame.rs index 12a9948f..9bacfab8 100644 --- a/asyncgit/src/blame.rs +++ b/asyncgit/src/blame.rs @@ -2,7 +2,7 @@ use crate::{ error::Result, hash, sync::{self, FileBlame}, - AsyncNotification, CWD, + AsyncGitNotification, CWD, }; use crossbeam_channel::Sender; use std::{ @@ -33,13 +33,13 @@ struct LastResult { pub struct AsyncBlame { current: Arc>>, last: Arc>>>, - sender: Sender, + sender: Sender, pending: Arc, } impl AsyncBlame { /// - pub fn new(sender: &Sender) -> Self { + pub fn new(sender: &Sender) -> Self { Self { current: Arc::new(Mutex::new(Request(0, None))), last: Arc::new(Mutex::new(None)), @@ -120,9 +120,9 @@ impl AsyncBlame { sender .send(if notify { - AsyncNotification::Blame + AsyncGitNotification::Blame } else { - AsyncNotification::FinishUnchanged + AsyncGitNotification::FinishUnchanged }) .expect("error sending blame"); }); diff --git a/asyncgit/src/commit_files.rs b/asyncgit/src/commit_files.rs index aa8c0d96..a0948312 100644 --- a/asyncgit/src/commit_files.rs +++ b/asyncgit/src/commit_files.rs @@ -1,7 +1,7 @@ use crate::{ error::Result, sync::{self, CommitId}, - AsyncNotification, StatusItem, CWD, + AsyncGitNotification, StatusItem, CWD, }; use crossbeam_channel::Sender; use std::sync::{ @@ -15,13 +15,13 @@ struct Request(R, A); /// pub struct AsyncCommitFiles { current: Arc>>>, - sender: Sender, + sender: Sender, pending: Arc, } impl AsyncCommitFiles { /// - pub fn new(sender: &Sender) -> Self { + pub fn new(sender: &Sender) -> Self { Self { current: Arc::new(Mutex::new(None)), sender: sender.clone(), @@ -74,7 +74,7 @@ impl AsyncCommitFiles { arc_pending.fetch_sub(1, Ordering::Relaxed); sender - .send(AsyncNotification::CommitFiles) + .send(AsyncGitNotification::CommitFiles) .expect("error sending"); }); diff --git a/asyncgit/src/diff.rs b/asyncgit/src/diff.rs index 92797c8c..9214c50b 100644 --- a/asyncgit/src/diff.rs +++ b/asyncgit/src/diff.rs @@ -2,7 +2,7 @@ use crate::{ error::Result, hash, sync::{self, CommitId}, - AsyncNotification, FileDiff, CWD, + AsyncGitNotification, FileDiff, CWD, }; use crossbeam_channel::Sender; use std::{ @@ -46,13 +46,13 @@ struct LastResult { pub struct AsyncDiff { current: Arc>>, last: Arc>>>, - sender: Sender, + sender: Sender, pending: Arc, } impl AsyncDiff { /// - pub fn new(sender: &Sender) -> Self { + pub fn new(sender: &Sender) -> Self { Self { current: Arc::new(Mutex::new(Request(0, None))), last: Arc::new(Mutex::new(None)), @@ -129,9 +129,9 @@ impl AsyncDiff { sender .send(if notify { - AsyncNotification::Diff + AsyncGitNotification::Diff } else { - AsyncNotification::FinishUnchanged + AsyncGitNotification::FinishUnchanged }) .expect("error sending diff"); }); diff --git a/asyncgit/src/fetch.rs b/asyncgit/src/fetch.rs index 58130c86..a0063e67 100644 --- a/asyncgit/src/fetch.rs +++ b/asyncgit/src/fetch.rs @@ -4,7 +4,7 @@ use crate::{ cred::BasicAuthCredential, remotes::{fetch, push::ProgressNotification}, }, - AsyncNotification, RemoteProgress, CWD, + AsyncGitNotification, RemoteProgress, CWD, }; use crossbeam_channel::{unbounded, Sender}; use std::{ @@ -33,12 +33,12 @@ pub struct AsyncFetch { state: Arc>>, last_result: Arc>>, progress: Arc>>, - sender: Sender, + sender: Sender, } impl AsyncFetch { /// - pub fn new(sender: &Sender) -> Self { + pub fn new(sender: &Sender) -> Self { Self { state: Arc::new(Mutex::new(None)), last_result: Arc::new(Mutex::new(None)), @@ -85,7 +85,7 @@ impl AsyncFetch { let (progress_sender, receiver) = unbounded(); let handle = RemoteProgress::spawn_receiver_thread( - AsyncNotification::Fetch, + AsyncGitNotification::Fetch, sender.clone(), receiver, arc_progress, @@ -109,7 +109,7 @@ impl AsyncFetch { Self::clear_request(&arc_state).expect("clear error"); sender - .send(AsyncNotification::Fetch) + .send(AsyncGitNotification::Fetch) .expect("AsyncNotification error"); }); diff --git a/asyncgit/src/lib.rs b/asyncgit/src/lib.rs index dbee02b1..c9a1a121 100644 --- a/asyncgit/src/lib.rs +++ b/asyncgit/src/lib.rs @@ -61,7 +61,7 @@ use std::{ /// this type is used to communicate events back through the channel #[derive(Copy, Clone, Debug, PartialEq)] -pub enum AsyncNotification { +pub enum AsyncGitNotification { /// this indicates that no new state was fetched but that a async process finished FinishUnchanged, /// diff --git a/asyncgit/src/push.rs b/asyncgit/src/push.rs index 2af757bd..c2648477 100644 --- a/asyncgit/src/push.rs +++ b/asyncgit/src/push.rs @@ -4,7 +4,7 @@ use crate::{ cred::BasicAuthCredential, remotes::push::push, remotes::push::ProgressNotification, }, - AsyncNotification, RemoteProgress, CWD, + AsyncGitNotification, RemoteProgress, CWD, }; use crossbeam_channel::{unbounded, Sender}; use std::{ @@ -35,12 +35,12 @@ pub struct AsyncPush { state: Arc>>, last_result: Arc>>, progress: Arc>>, - sender: Sender, + sender: Sender, } impl AsyncPush { /// - pub fn new(sender: &Sender) -> Self { + pub fn new(sender: &Sender) -> Self { Self { state: Arc::new(Mutex::new(None)), last_result: Arc::new(Mutex::new(None)), @@ -87,7 +87,7 @@ impl AsyncPush { let (progress_sender, receiver) = unbounded(); let handle = RemoteProgress::spawn_receiver_thread( - AsyncNotification::Push, + AsyncGitNotification::Push, sender.clone(), receiver, arc_progress, @@ -113,7 +113,7 @@ impl AsyncPush { Self::clear_request(&arc_state).expect("clear error"); sender - .send(AsyncNotification::Push) + .send(AsyncGitNotification::Push) .expect("error sending push"); }); diff --git a/asyncgit/src/push_tags.rs b/asyncgit/src/push_tags.rs index d0e2bbc7..4661917b 100644 --- a/asyncgit/src/push_tags.rs +++ b/asyncgit/src/push_tags.rs @@ -4,7 +4,7 @@ use crate::{ cred::BasicAuthCredential, remotes::tags::{push_tags, PushTagsProgress}, }, - AsyncNotification, RemoteProgress, CWD, + AsyncGitNotification, RemoteProgress, CWD, }; use crossbeam_channel::{unbounded, Sender}; use std::{ @@ -31,12 +31,12 @@ pub struct AsyncPushTags { state: Arc>>, last_result: Arc>>, progress: Arc>>, - sender: Sender, + sender: Sender, } impl AsyncPushTags { /// - pub fn new(sender: &Sender) -> Self { + pub fn new(sender: &Sender) -> Self { Self { state: Arc::new(Mutex::new(None)), last_result: Arc::new(Mutex::new(None)), @@ -83,7 +83,7 @@ impl AsyncPushTags { let (progress_sender, receiver) = unbounded(); let handle = RemoteProgress::spawn_receiver_thread( - AsyncNotification::PushTags, + AsyncGitNotification::PushTags, sender.clone(), receiver, arc_progress, @@ -103,7 +103,7 @@ impl AsyncPushTags { Self::clear_request(&arc_state).expect("clear error"); sender - .send(AsyncNotification::PushTags) + .send(AsyncGitNotification::PushTags) .expect("error sending push"); }); diff --git a/asyncgit/src/remote_progress.rs b/asyncgit/src/remote_progress.rs index 79c15911..23cb9d34 100644 --- a/asyncgit/src/remote_progress.rs +++ b/asyncgit/src/remote_progress.rs @@ -4,7 +4,7 @@ use crate::{ error::Result, progress::ProgressPercent, sync::remotes::push::{AsyncProgress, ProgressNotification}, - AsyncNotification, + AsyncGitNotification, }; use crossbeam_channel::{Receiver, Sender}; use git2::PackBuilderStage; @@ -71,8 +71,8 @@ impl RemoteProgress { pub(crate) fn spawn_receiver_thread< T: 'static + AsyncProgress, >( - notification_type: AsyncNotification, - sender: Sender, + notification_type: AsyncGitNotification, + sender: Sender, receiver: Receiver, progress: Arc>>, ) -> JoinHandle<()> { diff --git a/asyncgit/src/revlog.rs b/asyncgit/src/revlog.rs index 35bd506b..e13c5895 100644 --- a/asyncgit/src/revlog.rs +++ b/asyncgit/src/revlog.rs @@ -1,7 +1,7 @@ use crate::{ error::Result, sync::{utils::repo, CommitId, LogWalker}, - AsyncNotification, CWD, + AsyncGitNotification, CWD, }; use crossbeam_channel::Sender; use git2::Oid; @@ -29,7 +29,7 @@ pub enum FetchStatus { /// pub struct AsyncLog { current: Arc>>, - sender: Sender, + sender: Sender, pending: Arc, background: Arc, } @@ -40,7 +40,7 @@ static SLEEP_BACKGROUND: Duration = Duration::from_millis(1000); impl AsyncLog { /// - pub fn new(sender: &Sender) -> Self { + pub fn new(sender: &Sender) -> Self { Self { current: Arc::new(Mutex::new(Vec::new())), sender: sender.clone(), @@ -147,7 +147,7 @@ impl AsyncLog { fn fetch_helper( arc_current: &Arc>>, arc_background: &Arc, - sender: &Sender, + sender: &Sender, ) -> Result<()> { let mut entries = Vec::with_capacity(LIMIT_COUNT); let r = repo(CWD)?; @@ -183,7 +183,9 @@ impl AsyncLog { Ok(()) } - fn notify(sender: &Sender) { - sender.send(AsyncNotification::Log).expect("error sending"); + fn notify(sender: &Sender) { + sender + .send(AsyncGitNotification::Log) + .expect("error sending"); } } diff --git a/asyncgit/src/status.rs b/asyncgit/src/status.rs index 811c4533..8533227a 100644 --- a/asyncgit/src/status.rs +++ b/asyncgit/src/status.rs @@ -2,7 +2,7 @@ use crate::{ error::Result, hash, sync::{self, status::StatusType}, - AsyncNotification, StatusItem, CWD, + AsyncGitNotification, StatusItem, CWD, }; use crossbeam_channel::Sender; use std::{ @@ -49,13 +49,13 @@ struct Request(R, Option); pub struct AsyncStatus { current: Arc>>, last: Arc>, - sender: Sender, + sender: Sender, pending: Arc, } impl AsyncStatus { /// - pub fn new(sender: Sender) -> Self { + pub fn new(sender: Sender) -> Self { Self { current: Arc::new(Mutex::new(Request(0, None))), last: Arc::new(Mutex::new(Status::default())), @@ -125,7 +125,7 @@ impl AsyncStatus { if ok { sender - .send(AsyncNotification::Status) + .send(AsyncGitNotification::Status) .expect("error sending status"); } }); diff --git a/asyncgit/src/tags.rs b/asyncgit/src/tags.rs index 388a60b4..1cc40e9b 100644 --- a/asyncgit/src/tags.rs +++ b/asyncgit/src/tags.rs @@ -2,7 +2,7 @@ use crate::{ error::Result, hash, sync::{self}, - AsyncNotification, CWD, + AsyncGitNotification, CWD, }; use crossbeam_channel::Sender; use std::{ @@ -24,13 +24,13 @@ struct TagsResult { /// pub struct AsyncTags { last: Arc>>, - sender: Sender, + sender: Sender, pending: Arc, } impl AsyncTags { /// - pub fn new(sender: &Sender) -> Self { + pub fn new(sender: &Sender) -> Self { Self { last: Arc::new(Mutex::new(None)), sender: sender.clone(), @@ -84,9 +84,9 @@ impl AsyncTags { sender .send(if notify { - AsyncNotification::Tags + AsyncGitNotification::Tags } else { - AsyncNotification::FinishUnchanged + AsyncGitNotification::FinishUnchanged }) .expect("error sending notify"); }); diff --git a/src/app.rs b/src/app.rs index 6b181aed..7bba071c 100644 --- a/src/app.rs +++ b/src/app.rs @@ -20,7 +20,7 @@ use crate::{ ui::style::{SharedTheme, Theme}, }; use anyhow::{bail, Result}; -use asyncgit::{sync, AsyncNotification, CWD}; +use asyncgit::{sync, AsyncGitNotification, CWD}; use crossbeam_channel::Sender; use crossterm::event::{Event, KeyEvent}; use std::{ @@ -78,7 +78,7 @@ impl App { /// #[allow(clippy::too_many_lines)] pub fn new( - sender: &Sender, + sender: &Sender, input: Input, theme: Theme, key_config: KeyConfig, @@ -343,7 +343,7 @@ impl App { /// pub fn update_git( &mut self, - ev: AsyncNotification, + ev: AsyncGitNotification, ) -> Result<()> { log::trace!("update_git: {:?}", ev); diff --git a/src/components/blame_file.rs b/src/components/blame_file.rs index 45f308fd..aa817409 100644 --- a/src/components/blame_file.rs +++ b/src/components/blame_file.rs @@ -12,7 +12,7 @@ use crate::{ use anyhow::Result; use asyncgit::{ sync::{BlameHunk, CommitId, FileBlame}, - AsyncBlame, AsyncNotification, BlameParams, + AsyncBlame, AsyncGitNotification, BlameParams, }; use crossbeam_channel::Sender; use crossterm::event::Event; @@ -245,7 +245,7 @@ impl BlameFileComponent { /// pub fn new( queue: &Queue, - sender: &Sender, + sender: &Sender, title: &str, theme: SharedTheme, key_config: SharedKeyConfig, @@ -284,10 +284,10 @@ impl BlameFileComponent { /// pub fn update_git( &mut self, - event: AsyncNotification, + event: AsyncGitNotification, ) -> Result<()> { if self.is_visible() { - if let AsyncNotification::Blame = event { + if let AsyncGitNotification::Blame = event { self.update()?; } } diff --git a/src/components/commit_details/mod.rs b/src/components/commit_details/mod.rs index 850dfc86..7966a388 100644 --- a/src/components/commit_details/mod.rs +++ b/src/components/commit_details/mod.rs @@ -11,7 +11,7 @@ use crate::{ use anyhow::Result; use asyncgit::{ sync::{CommitId, CommitTags}, - AsyncCommitFiles, AsyncNotification, + AsyncCommitFiles, AsyncGitNotification, }; use crossbeam_channel::Sender; use crossterm::event::Event; @@ -36,7 +36,7 @@ impl CommitDetailsComponent { /// pub fn new( queue: &Queue, - sender: &Sender, + sender: &Sender, theme: SharedTheme, key_config: SharedKeyConfig, ) -> Self { diff --git a/src/components/inspect_commit.rs b/src/components/inspect_commit.rs index ff596fa8..397ea943 100644 --- a/src/components/inspect_commit.rs +++ b/src/components/inspect_commit.rs @@ -13,7 +13,7 @@ use crate::{ use anyhow::Result; use asyncgit::{ sync::{CommitId, CommitTags}, - AsyncDiff, AsyncNotification, DiffParams, DiffType, + AsyncDiff, AsyncGitNotification, DiffParams, DiffType, }; use crossbeam_channel::Sender; use crossterm::event::Event; @@ -176,7 +176,7 @@ impl InspectCommitComponent { /// pub fn new( queue: &Queue, - sender: &Sender, + sender: &Sender, theme: SharedTheme, key_config: SharedKeyConfig, ) -> Self { @@ -223,12 +223,12 @@ impl InspectCommitComponent { /// pub fn update_git( &mut self, - ev: AsyncNotification, + ev: AsyncGitNotification, ) -> Result<()> { if self.is_visible() { - if let AsyncNotification::CommitFiles = ev { + if let AsyncGitNotification::CommitFiles = ev { self.update()?; - } else if let AsyncNotification::Diff = ev { + } else if let AsyncGitNotification::Diff = ev { self.update_diff()?; } } diff --git a/src/components/pull.rs b/src/components/pull.rs index a041edbe..18c34771 100644 --- a/src/components/pull.rs +++ b/src/components/pull.rs @@ -19,7 +19,8 @@ use asyncgit::{ }, get_default_remote, }, - AsyncFetch, AsyncNotification, FetchRequest, RemoteProgress, CWD, + AsyncFetch, AsyncGitNotification, FetchRequest, RemoteProgress, + CWD, }; use crossbeam_channel::Sender; use crossterm::event::Event; @@ -48,7 +49,7 @@ impl PullComponent { /// pub fn new( queue: &Queue, - sender: &Sender, + sender: &Sender, theme: SharedTheme, key_config: SharedKeyConfig, ) -> Self { @@ -111,10 +112,10 @@ impl PullComponent { /// pub fn update_git( &mut self, - ev: AsyncNotification, + ev: AsyncGitNotification, ) -> Result<()> { if self.is_visible() { - if let AsyncNotification::Fetch = ev { + if let AsyncGitNotification::Fetch = ev { self.update()?; } } diff --git a/src/components/push.rs b/src/components/push.rs index 4ea025f1..11d9ebbe 100644 --- a/src/components/push.rs +++ b/src/components/push.rs @@ -17,7 +17,7 @@ use asyncgit::{ }, get_branch_remote, get_default_remote, }, - AsyncNotification, AsyncPush, PushRequest, RemoteProgress, + AsyncGitNotification, AsyncPush, PushRequest, RemoteProgress, RemoteProgressState, CWD, }; use crossbeam_channel::Sender; @@ -48,7 +48,7 @@ impl PushComponent { /// pub fn new( queue: &Queue, - sender: &Sender, + sender: &Sender, theme: SharedTheme, key_config: SharedKeyConfig, ) -> Self { @@ -130,10 +130,10 @@ impl PushComponent { /// pub fn update_git( &mut self, - ev: AsyncNotification, + ev: AsyncGitNotification, ) -> Result<()> { if self.is_visible() { - if let AsyncNotification::Push = ev { + if let AsyncGitNotification::Push = ev { self.update()?; } } diff --git a/src/components/push_tags.rs b/src/components/push_tags.rs index 9ea4ca68..f2c84207 100644 --- a/src/components/push_tags.rs +++ b/src/components/push_tags.rs @@ -17,7 +17,7 @@ use asyncgit::{ }, get_default_remote, AsyncProgress, PushTagsProgress, }, - AsyncNotification, AsyncPushTags, PushTagsRequest, CWD, + AsyncGitNotification, AsyncPushTags, PushTagsRequest, CWD, }; use crossbeam_channel::Sender; use crossterm::event::Event; @@ -45,7 +45,7 @@ impl PushTagsComponent { /// pub fn new( queue: &Queue, - sender: &Sender, + sender: &Sender, theme: SharedTheme, key_config: SharedKeyConfig, ) -> Self { @@ -99,10 +99,10 @@ impl PushTagsComponent { /// pub fn update_git( &mut self, - ev: AsyncNotification, + ev: AsyncGitNotification, ) -> Result<()> { if self.is_visible() { - if let AsyncNotification::PushTags = ev { + if let AsyncGitNotification::PushTags = ev { self.update()?; } } diff --git a/src/components/revision_files.rs b/src/components/revision_files.rs index 8f009a0c..8266509b 100644 --- a/src/components/revision_files.rs +++ b/src/components/revision_files.rs @@ -12,7 +12,7 @@ use crate::{ use anyhow::Result; use asyncgit::{ sync::{self, CommitId, TreeFile}, - AsyncNotification, CWD, + AsyncGitNotification, CWD, }; use crossbeam_channel::Sender; use crossterm::event::Event; @@ -52,7 +52,7 @@ impl RevisionFilesComponent { /// pub fn new( queue: &Queue, - sender: &Sender, + sender: &Sender, theme: SharedTheme, key_config: SharedKeyConfig, ) -> Self { @@ -90,7 +90,7 @@ impl RevisionFilesComponent { } /// - pub fn update(&mut self, ev: AsyncNotification) { + pub fn update(&mut self, ev: AsyncGitNotification) { self.current_file.update(ev); } diff --git a/src/components/revision_files_popup.rs b/src/components/revision_files_popup.rs index b90b3ff4..437fe42d 100644 --- a/src/components/revision_files_popup.rs +++ b/src/components/revision_files_popup.rs @@ -10,7 +10,7 @@ use crate::{ ui::style::SharedTheme, }; use anyhow::Result; -use asyncgit::{sync::CommitId, AsyncNotification}; +use asyncgit::{sync::CommitId, AsyncGitNotification}; use crossbeam_channel::Sender; use crossterm::event::Event; use tui::{backend::Backend, layout::Rect, widgets::Clear, Frame}; @@ -25,7 +25,7 @@ impl RevisionFilesPopup { /// pub fn new( queue: &Queue, - sender: &Sender, + sender: &Sender, theme: SharedTheme, key_config: SharedKeyConfig, ) -> Self { @@ -50,7 +50,7 @@ impl RevisionFilesPopup { } /// - pub fn update(&mut self, ev: AsyncNotification) { + pub fn update(&mut self, ev: AsyncGitNotification) { self.files.update(ev); } diff --git a/src/components/syntax_text.rs b/src/components/syntax_text.rs index 978f9840..a3850f6d 100644 --- a/src/components/syntax_text.rs +++ b/src/components/syntax_text.rs @@ -14,7 +14,7 @@ use anyhow::Result; use asyncgit::{ asyncjob::AsyncSingleJob, sync::{self, TreeFile}, - AsyncNotification, CWD, + AsyncGitNotification, CWD, }; use crossbeam_channel::Sender; use crossterm::event::Event; @@ -32,7 +32,7 @@ use tui::{ pub struct SyntaxTextComponent { current_file: Option<(String, Either)>, async_highlighting: - AsyncSingleJob, + AsyncSingleJob, key_config: SharedKeyConfig, paragraph_state: Cell, focused: bool, @@ -42,14 +42,14 @@ pub struct SyntaxTextComponent { impl SyntaxTextComponent { /// pub fn new( - sender: &Sender, + sender: &Sender, key_config: SharedKeyConfig, theme: SharedTheme, ) -> Self { Self { async_highlighting: AsyncSingleJob::new( sender.clone(), - AsyncNotification::SyntaxHighlighting, + AsyncGitNotification::SyntaxHighlighting, ), current_file: None, paragraph_state: Cell::new(ParagraphState::default()), @@ -60,8 +60,8 @@ impl SyntaxTextComponent { } /// - pub fn update(&mut self, ev: AsyncNotification) { - if ev == AsyncNotification::SyntaxHighlighting { + pub fn update(&mut self, ev: AsyncGitNotification) { + if ev == AsyncGitNotification::SyntaxHighlighting { if let Some(job) = self.async_highlighting.take_last() { if let Some((path, content)) = self.current_file.as_mut() diff --git a/src/main.rs b/src/main.rs index 68efee4a..9c4fae7c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -37,7 +37,7 @@ mod version; use crate::{app::App, args::process_cmdline}; use anyhow::{bail, Result}; -use asyncgit::AsyncNotification; +use asyncgit::AsyncGitNotification; use backtrace::Backtrace; use crossbeam_channel::{tick, unbounded, Receiver, Select}; use crossterm::{ @@ -72,7 +72,7 @@ static SPINNER_INTERVAL: Duration = Duration::from_millis(80); pub enum QueueEvent { Tick, SpinnerUpdate, - GitEvent(AsyncNotification), + GitEvent(AsyncGitNotification), InputEvent(InputEvent), } @@ -148,7 +148,8 @@ fn main() -> Result<()> { } QueueEvent::Tick => app.update()?, QueueEvent::GitEvent(ev) - if ev != AsyncNotification::FinishUnchanged => + if ev + != AsyncGitNotification::FinishUnchanged => { app.update_git(ev)?; } @@ -215,7 +216,7 @@ fn valid_path() -> Result { fn select_event( rx_input: &Receiver, - rx_git: &Receiver, + rx_git: &Receiver, rx_ticker: &Receiver, rx_spinner: &Receiver, ) -> Result { diff --git a/src/tabs/files.rs b/src/tabs/files.rs index 5e48fc2f..61d60857 100644 --- a/src/tabs/files.rs +++ b/src/tabs/files.rs @@ -14,7 +14,7 @@ use crate::{ ui::style::SharedTheme, }; use anyhow::Result; -use asyncgit::{sync, AsyncNotification, CWD}; +use asyncgit::{sync, AsyncGitNotification, CWD}; use crossbeam_channel::Sender; pub struct FilesTab { @@ -27,7 +27,7 @@ pub struct FilesTab { impl FilesTab { /// pub fn new( - sender: &Sender, + sender: &Sender, queue: &Queue, theme: SharedTheme, key_config: SharedKeyConfig, @@ -60,7 +60,7 @@ impl FilesTab { } /// - pub fn update_git(&mut self, ev: AsyncNotification) { + pub fn update_git(&mut self, ev: AsyncGitNotification) { if self.is_visible() { self.files.update(ev); } diff --git a/src/tabs/revlog.rs b/src/tabs/revlog.rs index 12e846e9..35779265 100644 --- a/src/tabs/revlog.rs +++ b/src/tabs/revlog.rs @@ -13,7 +13,7 @@ use anyhow::Result; use asyncgit::{ cached, sync::{self, CommitId}, - AsyncLog, AsyncNotification, AsyncTags, FetchStatus, CWD, + AsyncGitNotification, AsyncLog, AsyncTags, FetchStatus, CWD, }; use crossbeam_channel::Sender; use crossterm::event::Event; @@ -43,7 +43,7 @@ impl Revlog { /// pub fn new( queue: &Queue, - sender: &Sender, + sender: &Sender, theme: SharedTheme, key_config: SharedKeyConfig, ) -> Self { @@ -111,13 +111,13 @@ impl Revlog { /// pub fn update_git( &mut self, - ev: AsyncNotification, + ev: AsyncGitNotification, ) -> Result<()> { if self.visible { match ev { - AsyncNotification::CommitFiles - | AsyncNotification::Log => self.update()?, - AsyncNotification::Tags => { + AsyncGitNotification::CommitFiles + | AsyncGitNotification::Log => self.update()?, + AsyncGitNotification::Tags => { if let Some(tags) = self.git_tags.last()? { self.list.set_tags(tags); self.update()?; diff --git a/src/tabs/stashing.rs b/src/tabs/stashing.rs index 2479b8bc..9cd1bde0 100644 --- a/src/tabs/stashing.rs +++ b/src/tabs/stashing.rs @@ -13,7 +13,7 @@ use crate::{ use anyhow::Result; use asyncgit::{ sync::{self, status::StatusType}, - AsyncNotification, AsyncStatus, StatusParams, CWD, + AsyncGitNotification, AsyncStatus, StatusParams, CWD, }; use crossbeam_channel::Sender; use crossterm::event::Event; @@ -45,7 +45,7 @@ impl Stashing { /// pub fn new( - sender: &Sender, + sender: &Sender, queue: &Queue, theme: SharedTheme, key_config: SharedKeyConfig, @@ -88,10 +88,10 @@ impl Stashing { /// pub fn update_git( &mut self, - ev: AsyncNotification, + ev: AsyncGitNotification, ) -> Result<()> { if self.is_visible() { - if let AsyncNotification::Status = ev { + if let AsyncGitNotification::Status = ev { let status = self.git_status.last()?; self.index.update(&status.items)?; } diff --git a/src/tabs/status.rs b/src/tabs/status.rs index 73e27ec0..40fac37a 100644 --- a/src/tabs/status.rs +++ b/src/tabs/status.rs @@ -16,8 +16,8 @@ use asyncgit::{ cached, sync::BranchCompare, sync::{self, status::StatusType, RepoState}, - AsyncDiff, AsyncNotification, AsyncStatus, DiffParams, DiffType, - StatusParams, CWD, + AsyncDiff, AsyncGitNotification, AsyncStatus, DiffParams, + DiffType, StatusParams, CWD, }; use crossbeam_channel::Sender; use crossterm::event::Event; @@ -131,7 +131,7 @@ impl Status { /// pub fn new( queue: &Queue, - sender: &Sender, + sender: &Sender, theme: SharedTheme, key_config: SharedKeyConfig, ) -> Self { @@ -339,14 +339,16 @@ impl Status { /// pub fn update_git( &mut self, - ev: AsyncNotification, + ev: AsyncGitNotification, ) -> Result<()> { match ev { - AsyncNotification::Diff => self.update_diff()?, - AsyncNotification::Status => self.update_status()?, - AsyncNotification::Push - | AsyncNotification::Fetch - | AsyncNotification::CommitFiles => self.branch_compare(), + AsyncGitNotification::Diff => self.update_diff()?, + AsyncGitNotification::Status => self.update_status()?, + AsyncGitNotification::Push + | AsyncGitNotification::Fetch + | AsyncGitNotification::CommitFiles => { + self.branch_compare() + } _ => (), }