modifying types for fork/pull betwen repos

pull/19/head
Niko PLP 6 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)]
pub struct PublishEvent(pub Event, #[serde(skip)] pub Option<OverlayId>);

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

@ -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;

@ -25,19 +25,29 @@ use std::collections::HashSet;
use std::sync::Arc;
impl RepositoryV0 {
pub fn new(id: &PubKey, metadata: &Vec<u8>) -> RepositoryV0 {
pub fn new_with_meta(id: &PubKey, metadata: &Vec<u8>) -> 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<u8>) -> 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<u8>) -> 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,

@ -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()));

@ -1020,6 +1020,11 @@ pub struct RepositoryV0 {
#[serde(with = "serde_bytes")]
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
pub creator: Option<UserId>,
@ -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<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
#[serde(with = "serde_bytes")]
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
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
#[serde(with = "serde_bytes")]
pub content: Vec<u8>,

Loading…
Cancel
Save