mirror of
https://github.com/extrawurst/gitui.git
synced 2024-12-24 17:45:00 +03:00
better asyncgit crate structure
This commit is contained in:
parent
08a8e07322
commit
b0b9fb570d
@ -1,18 +1,16 @@
|
||||
mod diff;
|
||||
mod status;
|
||||
mod utils;
|
||||
pub mod sync;
|
||||
|
||||
pub use crate::{
|
||||
diff::{get_diff, Diff, DiffLine, DiffLineType},
|
||||
status::{get_index, StatusItem, StatusItemType, StatusType},
|
||||
utils::{commit, index_reset, stage_add, stage_reset},
|
||||
};
|
||||
use crossbeam_channel::Sender;
|
||||
use std::{
|
||||
collections::hash_map::DefaultHasher,
|
||||
hash::{Hash, Hasher},
|
||||
sync::{Arc, Mutex},
|
||||
};
|
||||
use sync::diff::get_diff;
|
||||
pub use sync::{
|
||||
diff::{Diff, DiffLine, DiffLineType},
|
||||
status::{StatusItem, StatusItemType, StatusType},
|
||||
};
|
||||
|
||||
#[derive(Default, Hash)]
|
||||
struct DiffRequest(String, bool);
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::utils;
|
||||
use super::utils;
|
||||
use git2::{DiffFormat, DiffOptions};
|
||||
use scopetime::scope_time;
|
||||
|
6
asyncgit/src/sync/mod.rs
Normal file
6
asyncgit/src/sync/mod.rs
Normal file
@ -0,0 +1,6 @@
|
||||
pub mod diff;
|
||||
pub mod status;
|
||||
pub mod utils;
|
||||
|
||||
pub use status::get_index;
|
||||
pub use utils::{commit, index_reset, stage_add, stage_reset};
|
@ -1,8 +1,7 @@
|
||||
use crate::utils;
|
||||
use crate::sync::utils;
|
||||
use git2::{Status, StatusOptions, StatusShow};
|
||||
use scopetime::scope_time;
|
||||
|
||||
///
|
||||
#[derive(PartialEq, Copy, Clone)]
|
||||
pub enum StatusItemType {
|
||||
New,
|
@ -5,7 +5,7 @@ use crate::{
|
||||
},
|
||||
keys, strings,
|
||||
};
|
||||
use asyncgit::{AsyncDiff, StatusType};
|
||||
use asyncgit::{sync, AsyncDiff, StatusType};
|
||||
use crossbeam_channel::Sender;
|
||||
use crossterm::event::Event;
|
||||
use itertools::Itertools;
|
||||
@ -353,7 +353,7 @@ impl App {
|
||||
if let Some(i) = self.index_wd.selection() {
|
||||
let path = Path::new(i.path.as_str());
|
||||
|
||||
if asyncgit::stage_add(path) {
|
||||
if sync::stage_add(path) {
|
||||
self.update();
|
||||
}
|
||||
}
|
||||
@ -361,7 +361,7 @@ impl App {
|
||||
if let Some(i) = self.index.selection() {
|
||||
let path = Path::new(i.path.as_str());
|
||||
|
||||
if asyncgit::stage_reset(path) {
|
||||
if sync::stage_reset(path) {
|
||||
self.update();
|
||||
}
|
||||
}
|
||||
@ -373,7 +373,7 @@ impl App {
|
||||
if let Some(i) = self.index_wd.selection() {
|
||||
let path = Path::new(i.path.as_str());
|
||||
|
||||
if asyncgit::index_reset(path) {
|
||||
if sync::index_reset(path) {
|
||||
self.update();
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
use super::{CommandInfo, Component};
|
||||
use crate::{strings, ui};
|
||||
use asyncgit::sync;
|
||||
use crossterm::event::{Event, KeyCode};
|
||||
use std::borrow::Cow;
|
||||
use tui::{
|
||||
@ -100,7 +101,7 @@ impl Component for CommitComponent {
|
||||
|
||||
impl CommitComponent {
|
||||
fn commit(&mut self) {
|
||||
asyncgit::commit(&self.msg);
|
||||
sync::commit(&self.msg);
|
||||
self.msg.clear();
|
||||
|
||||
self.hide();
|
||||
|
@ -1,6 +1,6 @@
|
||||
use crate::components::{CommandInfo, Component};
|
||||
use crate::ui;
|
||||
use asyncgit::{StatusItem, StatusItemType, StatusType};
|
||||
use asyncgit::{sync, StatusItem, StatusItemType, StatusType};
|
||||
use crossterm::event::{Event, KeyCode};
|
||||
use std::{borrow::Cow, cmp};
|
||||
use tui::{
|
||||
@ -39,7 +39,7 @@ impl IndexComponent {
|
||||
}
|
||||
///
|
||||
pub fn update(&mut self) {
|
||||
let new_status = asyncgit::get_index(self.index_type.into());
|
||||
let new_status = sync::get_index(self.index_type.into());
|
||||
|
||||
if self.items != new_status {
|
||||
self.items = new_status;
|
||||
|
Loading…
Reference in New Issue
Block a user