Add proto fields for repository entry maintenance

This commit is contained in:
Mikayla Maki 2023-05-04 13:26:53 -07:00
parent c6d7ed33c2
commit 2fe5bf419b
No known key found for this signature in database
4 changed files with 40 additions and 3 deletions

View file

@ -43,6 +43,7 @@ use std::{
future::Future,
mem,
ops::{Deref, DerefMut},
os::unix::prelude::OsStrExt,
path::{Path, PathBuf},
pin::Pin,
sync::{
@ -143,6 +144,18 @@ impl RepositoryEntry {
}
}
impl From<&RepositoryEntry> for proto::RepositoryEntry {
fn from(value: &RepositoryEntry) -> Self {
proto::RepositoryEntry {
git_dir_entry_id: value.git_dir_entry_id.to_proto(),
scan_id: value.scan_id as u64,
git_dir_path: value.git_dir_path.as_os_str().as_bytes().to_vec(),
work_directory: value.work_directory.0.as_os_str().as_bytes().to_vec(),
branch: value.branch.as_ref().map(|str| str.to_string()),
}
}
}
/// This path corresponds to the 'content path' (the folder that contains the .git)
#[derive(Clone, Debug, Ord, PartialOrd, Eq, PartialEq)]
pub struct RepositoryWorkDirectory(Arc<Path>);
@ -1542,6 +1555,7 @@ impl LocalSnapshot {
removed_entries: Default::default(),
scan_id: self.scan_id as u64,
is_last_update: true,
updated_repositories: self.repository_entries.values().map(Into::into).collect(),
}
}
@ -1610,6 +1624,8 @@ impl LocalSnapshot {
removed_entries,
scan_id: self.scan_id as u64,
is_last_update: self.completed_scan_id == self.scan_id,
// TODO repo
updated_repositories: vec![],
}
}