aboutsummaryrefslogtreecommitdiff
path: root/apps/servers/octopus/supergit/src/lib.rs
diff options
context:
space:
mode:
authorKatharina Fey <kookie@spacekookie.de>2020-10-31 18:57:39 +0100
committerMx Kookie <kookie@spacekookie.de>2020-12-21 05:10:08 +0100
commit9dacf748651ea7139c0e9f3dee9ae66d949bf73f (patch)
tree7101bc20d5a531218ccd1b4cb9e04c67995f6d0e /apps/servers/octopus/supergit/src/lib.rs
parent4e09fe2509904ee64d2470ca8d41006d51e4ffd6 (diff)
Add 'apps/servers/octopus/' from commit '623954d19fdf0dca47db319e5c88ee561aa8d25c'
git-subtree-dir: apps/servers/octopus git-subtree-mainline: 4e09fe2509904ee64d2470ca8d41006d51e4ffd6 git-subtree-split: 623954d19fdf0dca47db319e5c88ee561aa8d25c
Diffstat (limited to 'apps/servers/octopus/supergit/src/lib.rs')
-rw-r--r--apps/servers/octopus/supergit/src/lib.rs55
1 files changed, 55 insertions, 0 deletions
diff --git a/apps/servers/octopus/supergit/src/lib.rs b/apps/servers/octopus/supergit/src/lib.rs
new file mode 100644
index 000000000000..887ccc029e1f
--- /dev/null
+++ b/apps/servers/octopus/supergit/src/lib.rs
@@ -0,0 +1,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)
+}