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