Skip to content

Commit

Permalink
refactor: simplify atom ref format
Browse files Browse the repository at this point in the history
  • Loading branch information
nrdxp committed Oct 20, 2024
1 parent 3dfc898 commit f00f25b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
14 changes: 7 additions & 7 deletions crates/atom/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@
//! ```console
//! ❯ git ls-remote
//! From https://github.com/ekala-project/eka
//! ceebaca6d44c4cda555db3fbf687c0604c4818eb refs/atoms/ひらがな/0.1.0
//! a87bff5ae43894a158dadf40938c775cb5b62d4b refs/atoms/ひらがな/_specs/0.1.0
//! 9f17c8c816bd1de6f8aa9c037d1b529212ab2a02 refs/atoms/ひらがな/_srcs/0.1.0
//! ceebaca6d44c4cda555db3fbf687c0604c4818eb refs/atoms/ひらがな/0.1.0/atom
//! a87bff5ae43894a158dadf40938c775cb5b62d4b refs/atoms/ひらがな/0.1.0/spec
//! 9f17c8c816bd1de6f8aa9c037d1b529212ab2a02 refs/atoms/ひらがな/0.1.0/src
//! ```
//!
//! Here the 0.1.0 ref points to the Atom's contents in full. The `_spec` refs points
//! Here the `atom` ref points to the Atom's contents in full. The `spec` ref points
//! to a git tree object containing only the manifest and its lock file, which will be
//! important for efficient resolution (not yet implemented). The refs under `_srcs`
//! point to the original commit from which the Atom's content references, ensuring
//! it remains live. Ensuring we can trivially verify an Atom's content at any time.
//! important for efficient resolution (not yet implemented). The refs under `src`
//! points to the original commit from which the Atom's content references, ensuring
//! it remains live, allowing trivially verification.
#![deny(missing_docs)]
#![cfg_attr(not(feature = "git"), allow(dead_code))]

Expand Down
9 changes: 4 additions & 5 deletions crates/atom/src/publish/git/inner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@ use gix::objs::tree::Entry as AtomEntry;
use gix::worktree::object::Tree as AtomTree;
use gix::{ObjectId, Reference};

use super::super::{ATOM_FORMAT_VERSION, ATOM_MANIFEST, EMPTY_SIG};
use super::{AtomContext, AtomRef, GitContext, GitResult, RefKind};
use crate::core::AtomPaths;
use crate::publish::ATOM_ORIGIN;
use crate::publish::error::git::Error;
use crate::publish::{ATOM, ATOM_FORMAT_VERSION, ATOM_MANIFEST, ATOM_ORIGIN, EMPTY_SIG};
use crate::store::git;
use crate::{Atom, AtomId, Manifest};
impl<'a> GitContext<'a> {
Expand Down Expand Up @@ -118,9 +117,9 @@ use std::fmt;
impl<'a> fmt::Display for AtomRef<'a> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self.kind {
RefKind::Content => write!(f, "{}/{}", self.prefix, self.version),
RefKind::Spec => write!(f, "{}/_{}s/{}", self.prefix, ATOM_MANIFEST, self.version),
RefKind::Origin => write!(f, "{}/_{}s/{}", self.prefix, ATOM_ORIGIN, self.version),
RefKind::Content => write!(f, "{}/{}/{}", self.prefix, self.version, ATOM),
RefKind::Origin => write!(f, "{}/{}/{}", self.prefix, self.version, ATOM_ORIGIN),
RefKind::Spec => write!(f, "{}/{}/{}", self.prefix, self.version, ATOM_MANIFEST),
}
}
}
Expand Down
1 change: 1 addition & 0 deletions crates/atom/src/publish/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ impl<R> Record<R> {
}

const EMPTY_SIG: &str = "";
const ATOM: &str = "atom";
const ATOM_FORMAT_VERSION: &str = "1";
const ATOM_REF_TOP_LEVEL: &str = "atoms";
const ATOM_MANIFEST: &str = "spec";
Expand Down

0 comments on commit f00f25b

Please sign in to comment.