diff --git a/asyncgit/src/commit_files.rs b/asyncgit/src/commit_files.rs index 360db0a2..e837c453 100644 --- a/asyncgit/src/commit_files.rs +++ b/asyncgit/src/commit_files.rs @@ -1,12 +1,13 @@ use crate::{ - error::Result, sync, AsyncNotification, StatusItem, CWD, + error::Result, + sync::{self, CommitId}, + AsyncNotification, StatusItem, CWD, }; use crossbeam_channel::Sender; use std::sync::{ atomic::{AtomicUsize, Ordering}, Arc, Mutex, }; -use sync::CommitId; type ResultType = Vec; struct Request(R, A); diff --git a/asyncgit/src/diff.rs b/asyncgit/src/diff.rs index f13cd06e..69ace089 100644 --- a/asyncgit/src/diff.rs +++ b/asyncgit/src/diff.rs @@ -1,5 +1,8 @@ use crate::{ - error::Result, hash, sync, AsyncNotification, FileDiff, CWD, + error::Result, + hash, + sync::{self, CommitId}, + AsyncNotification, FileDiff, CWD, }; use crossbeam_channel::Sender; use std::{ @@ -9,7 +12,6 @@ use std::{ Arc, Mutex, }, }; -use sync::CommitId; /// #[derive(Hash, Clone, PartialEq)] diff --git a/asyncgit/src/status.rs b/asyncgit/src/status.rs index 16c0afe6..6c802469 100644 --- a/asyncgit/src/status.rs +++ b/asyncgit/src/status.rs @@ -1,5 +1,8 @@ use crate::{ - error::Result, hash, sync, AsyncNotification, StatusItem, CWD, + error::Result, + hash, + sync::{self, status::StatusType}, + AsyncNotification, StatusItem, CWD, }; use crossbeam_channel::Sender; use std::{ @@ -10,7 +13,6 @@ use std::{ }, time::{SystemTime, UNIX_EPOCH}, }; -use sync::status::StatusType; fn current_tick() -> u64 { SystemTime::now() diff --git a/asyncgit/src/sync/diff.rs b/asyncgit/src/sync/diff.rs index 9bdb6370..8965b750 100644 --- a/asyncgit/src/sync/diff.rs +++ b/asyncgit/src/sync/diff.rs @@ -1,6 +1,10 @@ //! sync git api for fetching a diff -use super::{commit_files::get_commit_diff, utils, CommitId}; +use super::{ + commit_files::get_commit_diff, + utils::{self, get_head_repo, work_dir}, + CommitId, +}; use crate::{error::Error, error::Result, hash}; use git2::{ Delta, Diff, DiffDelta, DiffFormat, DiffHunk, DiffOptions, Patch, @@ -8,7 +12,6 @@ use git2::{ }; use scopetime::scope_time; use std::{cell::RefCell, fs, path::Path, rc::Rc}; -use utils::{get_head_repo, work_dir}; /// type of diff of a single line #[derive(Copy, Clone, PartialEq, Hash, Debug)] diff --git a/asyncgit/src/sync/hooks.rs b/asyncgit/src/sync/hooks.rs index d217b175..6b34a1b8 100644 --- a/asyncgit/src/sync/hooks.rs +++ b/asyncgit/src/sync/hooks.rs @@ -4,8 +4,7 @@ use scopetime::scope_time; use std::{ fs::File, io::{Read, Write}, - path::Path, - path::PathBuf, + path::{Path, PathBuf}, process::Command, }; diff --git a/src/app.rs b/src/app.rs index c5ab5621..304d84b7 100644 --- a/src/app.rs +++ b/src/app.rs @@ -1,4 +1,3 @@ -use crate::input::InputState; use crate::{ accessors, cmdbar::CommandBar, @@ -8,10 +7,10 @@ use crate::{ InspectCommitComponent, MsgComponent, ResetComponent, StashMsgComponent, }, - input::InputEvent, + input::{InputEvent, InputState}, keys, queue::{Action, InternalEvent, NeedsUpdate, Queue}, - strings, + strings::{self, commands, order}, tabs::{Revlog, StashList, Stashing, Status}, ui::style::{SharedTheme, Theme}, }; @@ -19,9 +18,7 @@ use anyhow::{anyhow, Result}; use asyncgit::{sync, AsyncNotification, CWD}; use crossbeam_channel::Sender; use crossterm::event::{Event, KeyEvent}; -use std::cell::Cell; -use std::{cell::RefCell, rc::Rc}; -use strings::{commands, order}; +use std::{cell::Cell, cell::RefCell, rc::Rc}; use tui::{ backend::Backend, layout::{Constraint, Direction, Layout, Rect}, diff --git a/src/components/commit.rs b/src/components/commit.rs index 3fff88b4..91743926 100644 --- a/src/components/commit.rs +++ b/src/components/commit.rs @@ -6,12 +6,12 @@ use crate::{ get_app_config_path, keys, queue::{InternalEvent, NeedsUpdate, Queue}, strings, - strings::COMMIT_EDITOR_MSG, + strings::{commands, COMMIT_EDITOR_MSG}, ui::style::SharedTheme, }; use anyhow::{anyhow, Result}; use asyncgit::{ - sync::{self, CommitId}, + sync::{self, CommitId, HookResult}, CWD, }; use crossterm::{ @@ -20,13 +20,13 @@ use crossterm::{ ExecutableCommand, }; use scopeguard::defer; -use std::env; -use std::fs::File; -use std::io::{self, Read, Write}; -use std::path::PathBuf; -use std::process::Command; -use strings::commands; -use sync::HookResult; +use std::{ + env, + fs::File, + io::{self, Read, Write}, + path::PathBuf, + process::Command, +}; use tui::{backend::Backend, layout::Rect, Frame}; pub struct CommitComponent { diff --git a/src/components/commit_details/details.rs b/src/components/commit_details/details.rs index 51d7d06d..76975ad7 100644 --- a/src/components/commit_details/details.rs +++ b/src/components/commit_details/details.rs @@ -8,12 +8,11 @@ use crate::{ }; use anyhow::Result; use asyncgit::{ - sync::{self, CommitDetails}, + sync::{self, CommitDetails, CommitId, Tags}, CWD, }; use crossterm::event::Event; use std::borrow::Cow; -use sync::{CommitId, Tags}; use tui::{ backend::Backend, layout::{Constraint, Direction, Layout, Rect}, diff --git a/src/components/commitlist.rs b/src/components/commitlist.rs index 93b2d56d..33e48ecd 100644 --- a/src/components/commitlist.rs +++ b/src/components/commitlist.rs @@ -10,12 +10,11 @@ use crate::{ ui::style::{SharedTheme, Theme}, }; use anyhow::Result; -use asyncgit::sync; +use asyncgit::sync::Tags; use crossterm::event::Event; use std::{ borrow::Cow, cell::Cell, cmp, convert::TryFrom, time::Instant, }; -use sync::Tags; use tui::{ backend::Backend, layout::{Alignment, Rect}, diff --git a/src/components/diff.rs b/src/components/diff.rs index f004563b..110031b7 100644 --- a/src/components/diff.rs +++ b/src/components/diff.rs @@ -3,14 +3,13 @@ use crate::{ components::{CommandInfo, Component}, keys, queue::{Action, InternalEvent, NeedsUpdate, Queue, ResetItem}, - strings, + strings::{self, commands}, ui::{calc_scroll_top, style::SharedTheme}, }; use asyncgit::{hash, sync, DiffLine, DiffLineType, FileDiff, CWD}; use bytesize::ByteSize; use crossterm::event::Event; use std::{borrow::Cow, cell::Cell, cmp, path::Path}; -use strings::commands; use tui::{ backend::Backend, layout::{Alignment, Rect}, diff --git a/src/components/filetree.rs b/src/components/filetree.rs index c4f5fd75..d07ab220 100644 --- a/src/components/filetree.rs +++ b/src/components/filetree.rs @@ -9,14 +9,14 @@ use crate::{ components::{CommandInfo, Component}, keys, queue::{InternalEvent, NeedsUpdate, Queue}, - strings, ui, + strings::{commands, order}, + ui, ui::style::SharedTheme, }; use anyhow::Result; use asyncgit::{hash, StatusItem, StatusItemType}; use crossterm::event::Event; use std::{borrow::Cow, convert::From, path::Path}; -use strings::{commands, order}; use tui::{backend::Backend, layout::Rect, widgets::Text, Frame}; /// diff --git a/src/components/help.rs b/src/components/help.rs index afae7235..b6b9507d 100644 --- a/src/components/help.rs +++ b/src/components/help.rs @@ -2,12 +2,16 @@ use super::{ visibility_blocking, CommandBlocking, CommandInfo, Component, DrawableComponent, }; -use crate::{keys, strings, ui, version::Version}; +use crate::{ + keys, + strings::{self, commands}, + ui, + version::Version, +}; use asyncgit::hash; use crossterm::event::Event; use itertools::Itertools; use std::{borrow::Cow, cmp, convert::TryFrom}; -use strings::commands; use tui::{ backend::Backend, layout::{Alignment, Constraint, Direction, Layout, Rect}, diff --git a/src/components/inspect_commit.rs b/src/components/inspect_commit.rs index db10861e..c320f575 100644 --- a/src/components/inspect_commit.rs +++ b/src/components/inspect_commit.rs @@ -4,16 +4,16 @@ use super::{ DrawableComponent, }; use crate::{ - accessors, keys, queue::Queue, strings, ui::style::SharedTheme, + accessors, keys, queue::Queue, strings::commands, + ui::style::SharedTheme, }; use anyhow::Result; use asyncgit::{ - sync, AsyncDiff, AsyncNotification, DiffParams, DiffType, + sync::{CommitId, Tags}, + AsyncDiff, AsyncNotification, DiffParams, DiffType, }; use crossbeam_channel::Sender; use crossterm::event::Event; -use strings::commands; -use sync::{CommitId, Tags}; use tui::{ backend::Backend, layout::{Constraint, Direction, Layout, Rect}, diff --git a/src/components/mod.rs b/src/components/mod.rs index 78eab8b5..3d8a6691 100644 --- a/src/components/mod.rs +++ b/src/components/mod.rs @@ -12,13 +12,15 @@ mod reset; mod stashmsg; mod textinput; mod utils; + use anyhow::Result; +use crossterm::event::Event; + pub use changes::ChangesComponent; pub use command::{CommandInfo, CommandText}; pub use commit::CommitComponent; pub use commit_details::CommitDetailsComponent; pub use commitlist::CommitList; -use crossterm::event::Event; pub use diff::DiffComponent; pub use filetree::FileTreeComponent; pub use help::HelpComponent; diff --git a/src/components/msg.rs b/src/components/msg.rs index 36935a92..643c4a02 100644 --- a/src/components/msg.rs +++ b/src/components/msg.rs @@ -2,10 +2,13 @@ use super::{ visibility_blocking, CommandBlocking, CommandInfo, Component, DrawableComponent, }; -use crate::{keys, strings, ui}; +use crate::{ + keys, + strings::{self, commands}, + ui, +}; use crossterm::event::Event; use std::borrow::Cow; -use strings::commands; use tui::{ backend::Backend, layout::{Alignment, Rect}, diff --git a/src/components/reset.rs b/src/components/reset.rs index 5d0e96aa..90ce98dd 100644 --- a/src/components/reset.rs +++ b/src/components/reset.rs @@ -4,12 +4,12 @@ use crate::{ CommandInfo, Component, DrawableComponent, }, queue::{Action, InternalEvent, Queue}, - strings, ui, + strings::{self, commands}, + ui, }; use anyhow::Result; use crossterm::event::{Event, KeyCode}; use std::borrow::Cow; -use strings::commands; use tui::{ backend::Backend, layout::Rect, diff --git a/src/components/stashmsg.rs b/src/components/stashmsg.rs index f4122d6a..28cd52c3 100644 --- a/src/components/stashmsg.rs +++ b/src/components/stashmsg.rs @@ -4,14 +4,13 @@ use super::{ }; use crate::{ queue::{InternalEvent, NeedsUpdate, Queue}, - strings, + strings::{self, commands}, tabs::StashingOptions, ui::style::SharedTheme, }; use anyhow::Result; use asyncgit::{sync, CWD}; use crossterm::event::{Event, KeyCode}; -use strings::commands; use tui::{backend::Backend, layout::Rect, Frame}; pub struct StashMsgComponent { diff --git a/src/components/textinput.rs b/src/components/textinput.rs index ed303272..c906dc4a 100644 --- a/src/components/textinput.rs +++ b/src/components/textinput.rs @@ -3,11 +3,11 @@ use crate::{ popup_paragraph, visibility_blocking, CommandBlocking, CommandInfo, Component, DrawableComponent, }, - strings, ui, + strings::commands, + ui::{self, style::SharedTheme}, }; use anyhow::Result; use crossterm::event::{Event, KeyCode, KeyModifiers}; -use strings::commands; use tui::{ backend::Backend, layout::Rect, @@ -15,7 +15,6 @@ use tui::{ widgets::{Clear, Text}, Frame, }; -use ui::style::SharedTheme; /// primarily a subcomponet for user input of text (used in `CommitComponent`) pub struct TextInputComponent { diff --git a/src/components/utils/filetree.rs b/src/components/utils/filetree.rs index 15e4ec2e..a48f650c 100644 --- a/src/components/utils/filetree.rs +++ b/src/components/utils/filetree.rs @@ -1,14 +1,13 @@ +use anyhow::Result; use asyncgit::StatusItem; use std::{ collections::BTreeSet, convert::TryFrom, + ffi::OsStr, ops::{Index, IndexMut}, path::Path, }; -use anyhow::Result; -use std::ffi::OsStr; - /// holds the information shared among all `FileTreeItem` in a `FileTree` #[derive(Debug, Clone)] pub struct TreeItemInfo { diff --git a/src/tabs/revlog.rs b/src/tabs/revlog.rs index 14c10e02..4310818e 100644 --- a/src/tabs/revlog.rs +++ b/src/tabs/revlog.rs @@ -6,15 +6,16 @@ use crate::{ }, keys, queue::{InternalEvent, Queue}, - strings, + strings::{self, commands}, ui::style::SharedTheme, }; use anyhow::Result; -use asyncgit::{sync, AsyncLog, AsyncNotification, FetchStatus, CWD}; +use asyncgit::{ + sync::{self, CommitId}, + AsyncLog, AsyncNotification, FetchStatus, CWD, +}; use crossbeam_channel::Sender; use crossterm::event::Event; -use strings::commands; -use sync::CommitId; use tui::{ backend::Backend, layout::{Constraint, Direction, Layout, Rect}, diff --git a/src/tabs/stashing.rs b/src/tabs/stashing.rs index ba5df5c8..a3259194 100644 --- a/src/tabs/stashing.rs +++ b/src/tabs/stashing.rs @@ -7,7 +7,7 @@ use crate::{ }, keys, queue::{InternalEvent, Queue}, - strings, + strings::{self, commands}, ui::style::SharedTheme, }; use anyhow::Result; @@ -18,7 +18,6 @@ use asyncgit::{ use crossbeam_channel::Sender; use crossterm::event::Event; use std::borrow::Cow; -use strings::commands; use tui::{ layout::{Alignment, Constraint, Direction, Layout}, widgets::{Block, Borders, Paragraph, Text}, diff --git a/src/tabs/stashlist.rs b/src/tabs/stashlist.rs index f6e59192..0d20930d 100644 --- a/src/tabs/stashlist.rs +++ b/src/tabs/stashlist.rs @@ -5,15 +5,15 @@ use crate::{ }, keys, queue::{Action, InternalEvent, Queue}, - strings, + strings::{self, commands}, ui::style::SharedTheme, }; use anyhow::Result; -use asyncgit::sync; -use asyncgit::CWD; +use asyncgit::{ + sync::{self, CommitId}, + CWD, +}; use crossterm::event::Event; -use strings::commands; -use sync::CommitId; pub struct StashList { list: CommitList, diff --git a/src/tabs/status.rs b/src/tabs/status.rs index 66b30108..a0459515 100644 --- a/src/tabs/status.rs +++ b/src/tabs/status.rs @@ -1,13 +1,13 @@ use crate::{ accessors, components::{ - self, event_pump, ChangesComponent, CommandBlocking, - CommandInfo, Component, DiffComponent, DrawableComponent, - FileTreeItemKind, + command_pump, event_pump, visibility_blocking, + ChangesComponent, CommandBlocking, CommandInfo, Component, + DiffComponent, DrawableComponent, FileTreeItemKind, }, keys, queue::{InternalEvent, Queue, ResetItem}, - strings, + strings::{self, commands, order}, ui::style::SharedTheme, }; use anyhow::Result; @@ -16,10 +16,8 @@ use asyncgit::{ AsyncDiff, AsyncNotification, AsyncStatus, DiffParams, DiffType, StatusParams, CWD, }; -use components::{command_pump, visibility_blocking}; use crossbeam_channel::Sender; use crossterm::event::Event; -use strings::{commands, order}; use tui::layout::{Constraint, Direction, Layout}; /// diff --git a/src/ui/mod.rs b/src/ui/mod.rs index 6fb6b2cf..26721ffe 100644 --- a/src/ui/mod.rs +++ b/src/ui/mod.rs @@ -1,5 +1,6 @@ mod scrolllist; pub mod style; + use scrolllist::ScrollableList; use style::SharedTheme; use tui::{ diff --git a/src/ui/style.rs b/src/ui/style.rs index 686cd3af..2d15544e 100644 --- a/src/ui/style.rs +++ b/src/ui/style.rs @@ -6,10 +6,10 @@ use ron::{ ser::{to_string_pretty, PrettyConfig}, }; use serde::{Deserialize, Serialize}; -use std::path::PathBuf; use std::{ fs::File, io::{Read, Write}, + path::PathBuf, rc::Rc, }; use tui::style::{Color, Modifier, Style};