blob: 887ccc029e1f10e60a45bde7afb68d8020768fe9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
//! Strongly typed git repository explorer library
//!
//! This library exposes a read-only view into a git repository. To
//! get started, open an existing bare repo, and then call `sync()` to
//! build a cache of it. Every time you want your view of the repo to
//! update, call `sync()` again. If you want the sync operation to be
//! blocking, call `sync_blocking()` instead.
//!
//!
mod branch;
pub use branch::{Branch, BranchCommit};
mod commit;
pub use commit::{CommitId, Commit};
mod diff;
pub use diff::Diff;
pub mod raw;
use std::sync::atomic::{AtomicUsize, Ordering};
use async_std::sync::{Arc, RwLock};
use raw::RawRepository;
/// Represents a git repository with lazy data loading
pub struct Repository {
raw: RawRepository,
}
impl Repository {
pub fn open(path: &std::path::Path) -> Arc<Self> {
todo!()
}
/// Sync the repository with the backing git files
///
/// This function can be invoked manually, but should be invoked
/// basically every time your program expects changes to have
/// happened. Polling this function is not recommended.
pub fn sync(&self) {
todo!()
}
}
/////////// IDs are created from the same pool to save on code size ////////////
const ID_CTR: AtomicUsize = AtomicUsize::new(0);
/// Get monotonically increasing IDs for objects
pub(crate) fn id() -> usize {
ID_CTR.fetch_add(1, Ordering::Relaxed)
}
|