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
41pub mod asyncjob;
42mod blame;
43mod branches;
44pub mod cached;
45mod commit_files;
46mod diff;
47mod error;
48mod fetch_job;
49mod filter_commits;
50//mod gitui;
51mod progress;
52mod pull;
53mod push;
54mod push_tags;
55pub mod remote_progress;
56pub mod remote_tags;
57mod revlog;
58mod status;
59pub mod sync;
60mod tags;
61mod treefiles;
62
63use std::{
64    collections::hash_map::DefaultHasher,
65    hash::{Hash, Hasher},
66};
67
68pub use git2::message_prettify;
69
70pub use crate::{
71    blame::{AsyncBlame, BlameParams},
72    branches::AsyncBranchesJob,
73    commit_files::{AsyncCommitFiles, CommitFilesParams},
74    diff::{AsyncDiff, DiffParams, DiffType},
75    error::{Error, Result},
76    fetch_job::AsyncFetchJob,
77    filter_commits::{AsyncCommitFilterJob, CommitFilterResult},
78    progress::ProgressPercent,
79    pull::{AsyncPull, FetchRequest},
80    push::{AsyncPush, PushRequest},
81    push_tags::{AsyncPushTags, PushTagsRequest},
82    remote_progress::{RemoteProgress, RemoteProgressState},
83    revlog::{AsyncLog, FetchStatus},
84    status::{AsyncStatus, StatusParams},
85    sync::{
86        diff::{DiffLine, DiffLineType, FileDiff},
87        remotes::push::PushType,
88        status::{StatusItem, StatusItemType},
89    },
90    tags::AsyncTags,
91    treefiles::AsyncTreeFilesJob,
92};
93
94/// this type is used to communicate events back through the channel
95#[derive(Copy, Clone, Debug, PartialEq, Eq)]
96pub enum AsyncGitNotification {
97    /// this indicates that no new state was fetched but that a async
98    /// process finished
99    FinishUnchanged,
100    ///
101    Status,
102    ///
103    Diff,
104    ///
105    Log,
106    ///
107    FileLog,
108    ///
109    CommitFiles,
110    ///
111    Tags,
112    ///
113    Push,
114    ///
115    PushTags,
116    ///
117    Pull,
118    ///
119    Blame,
120    ///
121    RemoteTags,
122    ///
123    Fetch,
124    ///
125    Branches,
126    ///
127    TreeFiles,
128    ///
129    CommitFilter,
130}
131
132/// helper function to calculate the hash of an arbitrary type that
133/// implements the `Hash` trait
134pub fn hash<T: Hash + ?Sized>(v: &T) -> u64 {
135    let mut hasher = DefaultHasher::new();
136    v.hash(&mut hasher);
137    hasher.finish()
138}
139
140///
141#[cfg(feature = "trace-libgit")]
142pub fn register_tracing_logging() -> bool {
143    fn git_trace(level: git2::TraceLevel, msg: &str) {
144        log::info!("[{:?}]: {}", level, msg);
145    }
146    git2::trace_set(git2::TraceLevel::Trace, git_trace)
147}
148
149///
150#[cfg(not(feature = "trace-libgit"))]
151pub fn register_tracing_logging() -> bool {
152    true
153}