gnostr_asyncgit/
lib.rs

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