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