mirror of
https://github.com/gitui-org/gitui
synced 2026-05-23 08:58:21 +00:00
forbid unsafe/undoc'd
This commit is contained in:
parent
e557be6de0
commit
96b2b30052
6 changed files with 37 additions and 3 deletions
|
|
@ -11,6 +11,7 @@ struct DiffRequest(String, bool);
|
|||
|
||||
struct Request<R, A>(R, Option<A>);
|
||||
|
||||
///
|
||||
pub struct AsyncDiff {
|
||||
current: Arc<Mutex<Request<u64, Diff>>>,
|
||||
sender: Sender<AsyncNotification>,
|
||||
|
|
|
|||
|
|
@ -1,3 +1,7 @@
|
|||
//! asyncgit
|
||||
|
||||
#![forbid(unsafe_code)]
|
||||
#![warn(missing_docs)]
|
||||
mod diff;
|
||||
mod status;
|
||||
pub mod sync;
|
||||
|
|
@ -16,18 +20,23 @@ use std::{
|
|||
time::{SystemTime, UNIX_EPOCH},
|
||||
};
|
||||
|
||||
/// this type is used to communicate events back through the channel
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
pub enum AsyncNotification {
|
||||
///
|
||||
Status,
|
||||
///
|
||||
Diff,
|
||||
}
|
||||
|
||||
/// helper function to calculate the hash of an arbitrary type that implements the `Hash` trait
|
||||
pub fn hash<T: Hash>(v: &T) -> u64 {
|
||||
let mut hasher = DefaultHasher::new();
|
||||
v.hash(&mut hasher);
|
||||
hasher.finish()
|
||||
}
|
||||
|
||||
/// helper function to return the current tick since unix epoch
|
||||
pub fn current_tick() -> u64 {
|
||||
SystemTime::now()
|
||||
.duration_since(UNIX_EPOCH)
|
||||
|
|
|
|||
|
|
@ -1,14 +1,20 @@
|
|||
//! sync git api for fetching a diff
|
||||
|
||||
use super::utils;
|
||||
use git2::{Delta, DiffDelta, DiffFormat, DiffOptions, Patch};
|
||||
use scopetime::scope_time;
|
||||
use std::fs;
|
||||
|
||||
///
|
||||
#[derive(Copy, Clone, PartialEq)]
|
||||
#[derive(Copy, Clone, PartialEq, Hash)]
|
||||
pub enum DiffLineType {
|
||||
///
|
||||
None,
|
||||
///
|
||||
Header,
|
||||
///
|
||||
Add,
|
||||
///
|
||||
Delete,
|
||||
}
|
||||
|
||||
|
|
@ -19,14 +25,16 @@ impl Default for DiffLineType {
|
|||
}
|
||||
|
||||
///
|
||||
#[derive(Default, PartialEq, Clone)]
|
||||
#[derive(Default, Clone, Hash)]
|
||||
pub struct DiffLine {
|
||||
///
|
||||
pub content: String,
|
||||
///
|
||||
pub line_type: DiffLineType,
|
||||
}
|
||||
|
||||
///
|
||||
#[derive(Default, PartialEq, Clone)]
|
||||
#[derive(Default, Clone, Hash)]
|
||||
pub struct Diff(pub Vec<DiffLine>);
|
||||
|
||||
///
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
//! sync git api
|
||||
|
||||
pub mod diff;
|
||||
pub mod status;
|
||||
pub mod utils;
|
||||
|
|
|
|||
|
|
@ -1,13 +1,21 @@
|
|||
//! sync git api for fetching a status
|
||||
|
||||
use crate::sync::utils;
|
||||
use git2::{Status, StatusOptions, StatusShow};
|
||||
use scopetime::scope_time;
|
||||
|
||||
///
|
||||
#[derive(Copy, Clone, Hash)]
|
||||
pub enum StatusItemType {
|
||||
///
|
||||
New,
|
||||
///
|
||||
Modified,
|
||||
///
|
||||
Deleted,
|
||||
///
|
||||
Renamed,
|
||||
///
|
||||
Typechange,
|
||||
}
|
||||
|
||||
|
|
@ -30,14 +38,18 @@ impl From<Status> for StatusItemType {
|
|||
///
|
||||
#[derive(Default, Clone, Hash)]
|
||||
pub struct StatusItem {
|
||||
///
|
||||
pub path: String,
|
||||
///
|
||||
pub status: Option<StatusItemType>,
|
||||
}
|
||||
|
||||
///
|
||||
#[derive(Copy, Clone)]
|
||||
pub enum StatusType {
|
||||
///
|
||||
WorkingDir,
|
||||
///
|
||||
Stage,
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
//! sync git api (various methods)
|
||||
|
||||
use git2::{
|
||||
build::CheckoutBuilder, IndexAddOption, ObjectType, Repository,
|
||||
RepositoryOpenFlags,
|
||||
|
|
|
|||
Loading…
Reference in a new issue