diff --git a/ng-net/src/types.rs b/ng-net/src/types.rs index 205a3bd..6c755e2 100644 --- a/ng-net/src/types.rs +++ b/ng-net/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)] pub struct PublishEvent(pub Event, #[serde(skip)] pub Option); diff --git a/ng-repo/src/branch.rs b/ng-repo/src/branch.rs index 961acf7..a163aa5 100644 --- a/ng-repo/src/branch.rs +++ b/ng-repo/src/branch.rs @@ -39,6 +39,7 @@ impl BranchV0 { root_branch_readcap_id, topic, topic_privkey, + pulled_from: vec![], metadata, } } diff --git a/ng-repo/src/commit.rs b/ng-repo/src/commit.rs index 12171ad..7eb3575 100644 --- a/ng-repo/src/commit.rs +++ b/ng-repo/src/commit.rs @@ -1592,12 +1592,7 @@ mod test { let metadata = Vec::from("some metadata"); - let body = CommitBody::V0(CommitBodyV0::Repository(Repository::V0(RepositoryV0 { - id: branch, - verification_program: vec![], - creator: None, - metadata: vec![], - }))); + let body = CommitBody::V0(CommitBodyV0::Repository(Repository::new(&branch))); let max_object_size = 0; @@ -1708,12 +1703,7 @@ mod test { let metadata = Vec::from("some metadata"); - let body = CommitBody::V0(CommitBodyV0::Repository(Repository::V0(RepositoryV0 { - id: branch, - verification_program: vec![], - creator: None, - metadata: vec![], - }))); + let body = CommitBody::V0(CommitBodyV0::Repository(Repository::new(&branch))); let max_object_size = 0; diff --git a/ng-repo/src/repo.rs b/ng-repo/src/repo.rs index 4c976a7..f0c2144 100644 --- a/ng-repo/src/repo.rs +++ b/ng-repo/src/repo.rs @@ -25,19 +25,29 @@ use std::collections::HashSet; use std::sync::Arc; impl RepositoryV0 { - pub fn new(id: &PubKey, metadata: &Vec) -> RepositoryV0 { + pub fn new_with_meta(id: &PubKey, metadata: &Vec) -> RepositoryV0 { RepositoryV0 { id: id.clone(), metadata: metadata.clone(), verification_program: vec![], + fork_of: vec![], creator: None, } } } impl Repository { - pub fn new(id: &PubKey, metadata: &Vec) -> Repository { - Repository::V0(RepositoryV0::new(id, metadata)) + pub fn new(id: &RepoId) -> Self { + 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) -> Repository { + Repository::V0(RepositoryV0::new_with_meta(id, metadata)) } pub fn id(&self) -> &PubKey { match self { @@ -178,7 +188,7 @@ impl Repo { ); Self { id: id.clone(), - repo_def: Repository::new(id, &vec![]), + repo_def: Repository::new(&id), members, store, signer: None, diff --git a/ng-repo/src/store.rs b/ng-repo/src/store.rs index cd88cf8..58b3ce2 100644 --- a/ng-repo/src/store.rs +++ b/ng-repo/src/store.rs @@ -173,6 +173,7 @@ impl Store { branch_pub_key, repo_write_cap_secret, ), + pulled_from: vec![], metadata: vec![], }))); @@ -266,12 +267,7 @@ impl Store { // creating the Repository commit - let repository = Repository::V0(RepositoryV0 { - id: repo_pub_key, - verification_program: vec![], - creator: None, - metadata: vec![], - }); + let repository = Repository::new(&repo_pub_key); let repository_commit_body = CommitBody::V0(CommitBodyV0::Repository(repository.clone())); diff --git a/ng-repo/src/types.rs b/ng-repo/src/types.rs index 19c839c..31fe757 100644 --- a/ng-repo/src/types.rs +++ b/ng-repo/src/types.rs @@ -1020,6 +1020,11 @@ pub struct RepositoryV0 { #[serde(with = "serde_bytes")] pub verification_program: Vec, + /// 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, + /// User ID who created this repo pub creator: Option, @@ -1246,7 +1251,7 @@ pub enum BranchContentType { /// the previous branch heads, and the ACKS are empty. /// /// 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)] pub struct BranchV0 { /// Branch public key ID @@ -1273,6 +1278,11 @@ pub struct BranchV0 { #[serde(with = "serde_bytes")] pub topic_privkey: Vec, + /// 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, + /// App-specific metadata #[serde(with = "serde_bytes")] pub metadata: Vec, @@ -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 pub heads: Vec, + // optional serialization of a ReadBranchLink, if the snapshot is made from another repo. + #[serde(with = "serde_bytes")] + pub origin: Vec, + /// Snapshot data structure #[serde(with = "serde_bytes")] pub content: Vec,