-
-
Notifications
You must be signed in to change notification settings - Fork 605
/
Copy pathlib.rs
148 lines (141 loc) · 2.96 KB
/
lib.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
//! asyncgit
#![forbid(missing_docs)]
#![deny(
unused_imports,
unused_must_use,
dead_code,
unstable_name_collisions,
unused_assignments
)]
#![deny(clippy::all, clippy::perf, clippy::nursery, clippy::pedantic)]
#![deny(
clippy::filetype_is_file,
clippy::cargo,
clippy::unwrap_used,
clippy::panic,
clippy::match_like_matches_macro,
clippy::needless_update
//TODO: get this in someday since expect still leads us to crashes sometimes
// clippy::expect_used
)]
#![allow(
clippy::module_name_repetitions,
clippy::must_use_candidate,
clippy::missing_errors_doc,
clippy::empty_docs
)]
//TODO:
#![allow(
clippy::significant_drop_tightening,
clippy::missing_panics_doc,
clippy::multiple_crate_versions
)]
pub mod asyncjob;
mod blame;
mod branches;
pub mod cached;
mod commit_files;
mod diff;
mod error;
mod fetch_job;
mod file_history;
mod filter_commits;
mod progress;
mod pull;
mod push;
mod push_tags;
pub mod remote_progress;
pub mod remote_tags;
mod revlog;
mod status;
pub mod sync;
mod tags;
mod treefiles;
pub use crate::{
blame::{AsyncBlame, BlameParams},
branches::AsyncBranchesJob,
commit_files::{AsyncCommitFiles, CommitFilesParams},
diff::{AsyncDiff, DiffParams, DiffType},
error::{Error, Result},
fetch_job::AsyncFetchJob,
file_history::{
AsyncFileHistoryJob, FileHistoryEntry, FileHistoryEntryDelta,
},
filter_commits::{AsyncCommitFilterJob, CommitFilterResult},
progress::ProgressPercent,
pull::{AsyncPull, FetchRequest},
push::{AsyncPush, PushRequest},
push_tags::{AsyncPushTags, PushTagsRequest},
remote_progress::{RemoteProgress, RemoteProgressState},
revlog::{AsyncLog, FetchStatus},
status::{AsyncStatus, StatusParams},
sync::{
diff::{DiffLine, DiffLineType, FileDiff},
remotes::push::PushType,
status::{StatusItem, StatusItemType},
},
tags::AsyncTags,
treefiles::AsyncTreeFilesJob,
};
pub use git2::message_prettify;
use std::{
collections::hash_map::DefaultHasher,
hash::{Hash, Hasher},
};
/// this type is used to communicate events back through the channel
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum AsyncGitNotification {
/// this indicates that no new state was fetched but that a async process finished
FinishUnchanged,
///
Status,
///
Diff,
///
Log,
///
FileLog,
///
CommitFiles,
///
Tags,
///
Push,
///
PushTags,
///
Pull,
///
Blame,
///
RemoteTags,
///
Fetch,
///
Branches,
///
TreeFiles,
///
CommitFilter,
///
FileHistory,
}
/// helper function to calculate the hash of an arbitrary type that implements the `Hash` trait
pub fn hash<T: Hash + ?Sized>(v: &T) -> u64 {
let mut hasher = DefaultHasher::new();
v.hash(&mut hasher);
hasher.finish()
}
///
#[cfg(feature = "trace-libgit")]
pub fn register_tracing_logging() -> bool {
fn git_trace(level: git2::TraceLevel, msg: &[u8]) {
log::info!("[{:?}]: {}", level, String::from_utf8_lossy(msg));
}
git2::trace_set(git2::TraceLevel::Trace, git_trace).is_ok()
}
///
#[cfg(not(feature = "trace-libgit"))]
pub fn register_tracing_logging() -> bool {
true
}