gnostr_asyncgit/
lib.rs

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