modifying types for fork/pull betwen repos

pull/19/head
Niko PLP 7 months ago
parent a4d96aa92c
commit 3ae83bac3b
  1. 2
      ng-net/src/types.rs
  2. 1
      ng-repo/src/branch.rs
  3. 14
      ng-repo/src/commit.rs
  4. 18
      ng-repo/src/repo.rs
  5. 8
      ng-repo/src/store.rs
  6. 16
      ng-repo/src/types.rs

@ -3067,7 +3067,7 @@ impl ObjectDel {
} }
} }
/// Request to delete an object /// Request to publish an event in pubsub
#[derive(Clone, Debug, Serialize, Deserialize)] #[derive(Clone, Debug, Serialize, Deserialize)]
pub struct PublishEvent(pub Event, #[serde(skip)] pub Option<OverlayId>); pub struct PublishEvent(pub Event, #[serde(skip)] pub Option<OverlayId>);

@ -39,6 +39,7 @@ impl BranchV0 {
root_branch_readcap_id, root_branch_readcap_id,
topic, topic,
topic_privkey, topic_privkey,
pulled_from: vec![],
metadata, metadata,
} }
} }

@ -1592,12 +1592,7 @@ mod test {
let metadata = Vec::from("some metadata"); let metadata = Vec::from("some metadata");
let body = CommitBody::V0(CommitBodyV0::Repository(Repository::V0(RepositoryV0 { let body = CommitBody::V0(CommitBodyV0::Repository(Repository::new(&branch)));
id: branch,
verification_program: vec![],
creator: None,
metadata: vec![],
})));
let max_object_size = 0; let max_object_size = 0;
@ -1708,12 +1703,7 @@ mod test {
let metadata = Vec::from("some metadata"); let metadata = Vec::from("some metadata");
let body = CommitBody::V0(CommitBodyV0::Repository(Repository::V0(RepositoryV0 { let body = CommitBody::V0(CommitBodyV0::Repository(Repository::new(&branch)));
id: branch,
verification_program: vec![],
creator: None,
metadata: vec![],
})));
let max_object_size = 0; let max_object_size = 0;

@ -25,19 +25,29 @@ use std::collections::HashSet;
use std::sync::Arc; use std::sync::Arc;
impl RepositoryV0 { impl RepositoryV0 {
pub fn new(id: &PubKey, metadata: &Vec<u8>) -> RepositoryV0 { pub fn new_with_meta(id: &PubKey, metadata: &Vec<u8>) -> RepositoryV0 {
RepositoryV0 { RepositoryV0 {
id: id.clone(), id: id.clone(),
metadata: metadata.clone(), metadata: metadata.clone(),
verification_program: vec![], verification_program: vec![],
fork_of: vec![],
creator: None, creator: None,
} }
} }
} }
impl Repository { impl Repository {
pub fn new(id: &PubKey, metadata: &Vec<u8>) -> Repository { pub fn new(id: &RepoId) -> Self {
Repository::V0(RepositoryV0::new(id, metadata)) Repository::V0(RepositoryV0 {
id: id.clone(),
verification_program: vec![],
creator: None,
fork_of: vec![],
metadata: vec![],
})
}
pub fn new_with_meta(id: &PubKey, metadata: &Vec<u8>) -> Repository {
Repository::V0(RepositoryV0::new_with_meta(id, metadata))
} }
pub fn id(&self) -> &PubKey { pub fn id(&self) -> &PubKey {
match self { match self {
@ -178,7 +188,7 @@ impl Repo {
); );
Self { Self {
id: id.clone(), id: id.clone(),
repo_def: Repository::new(id, &vec![]), repo_def: Repository::new(&id),
members, members,
store, store,
signer: None, signer: None,

@ -173,6 +173,7 @@ impl Store {
branch_pub_key, branch_pub_key,
repo_write_cap_secret, repo_write_cap_secret,
), ),
pulled_from: vec![],
metadata: vec![], metadata: vec![],
}))); })));
@ -266,12 +267,7 @@ impl Store {
// creating the Repository commit // creating the Repository commit
let repository = Repository::V0(RepositoryV0 { let repository = Repository::new(&repo_pub_key);
id: repo_pub_key,
verification_program: vec![],
creator: None,
metadata: vec![],
});
let repository_commit_body = CommitBody::V0(CommitBodyV0::Repository(repository.clone())); let repository_commit_body = CommitBody::V0(CommitBodyV0::Repository(repository.clone()));

@ -1020,6 +1020,11 @@ pub struct RepositoryV0 {
#[serde(with = "serde_bytes")] #[serde(with = "serde_bytes")]
pub verification_program: Vec<u8>, pub verification_program: Vec<u8>,
/// Optional serialization of a ReadBranchLink (of a rootbranch or a transactional branch), if the repository is a fork of another one.
/// then transaction branches of this new repo, will be able to reference the forked repo/branches commits as DEPS in their singleton Branch commit.
#[serde(with = "serde_bytes")]
pub fork_of: Vec<u8>,
/// User ID who created this repo /// User ID who created this repo
pub creator: Option<UserId>, pub creator: Option<UserId>,
@ -1246,7 +1251,7 @@ pub enum BranchContentType {
/// the previous branch heads, and the ACKS are empty. /// the previous branch heads, and the ACKS are empty.
/// ///
/// Can be used also to update the branch definition when users are removed /// Can be used also to update the branch definition when users are removed
/// In this case, the total_order quorum is needed, and DEPS indicates the previous branch definition, ACKS indicate the current HEAD /// In this case, the total_order quorum is needed, and DEPS indicates the BranchCapRefresh commit
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)] #[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
pub struct BranchV0 { pub struct BranchV0 {
/// Branch public key ID /// Branch public key ID
@ -1273,6 +1278,11 @@ pub struct BranchV0 {
#[serde(with = "serde_bytes")] #[serde(with = "serde_bytes")]
pub topic_privkey: Vec<u8>, pub topic_privkey: Vec<u8>,
/// optional: this branch is the result of a pull request coming from another repo.
/// contains a serialization of a ReadBranchLink of a transactional branch from another repo
#[serde(with = "serde_bytes")]
pub pulled_from: Vec<u8>,
/// App-specific metadata /// App-specific metadata
#[serde(with = "serde_bytes")] #[serde(with = "serde_bytes")]
pub metadata: Vec<u8>, pub metadata: Vec<u8>,
@ -1859,6 +1869,10 @@ pub struct CompactV0 {
// Branch heads the snapshot was made from, can be useful when shared outside and the commit_header_key is set to None. otherwise it is redundant to ACKS // Branch heads the snapshot was made from, can be useful when shared outside and the commit_header_key is set to None. otherwise it is redundant to ACKS
pub heads: Vec<ObjectId>, pub heads: Vec<ObjectId>,
// optional serialization of a ReadBranchLink, if the snapshot is made from another repo.
#[serde(with = "serde_bytes")]
pub origin: Vec<u8>,
/// Snapshot data structure /// Snapshot data structure
#[serde(with = "serde_bytes")] #[serde(with = "serde_bytes")]
pub content: Vec<u8>, pub content: Vec<u8>,

Loading…
Cancel
Save