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