Implement embedded HTTPS Git synchronization
This commit is contained in:
@@ -24,6 +24,7 @@ pub struct TreeCommit {
|
||||
action: MutationAction,
|
||||
source: String,
|
||||
destination: Option<String>,
|
||||
changed_paths: Vec<std::path::PathBuf>,
|
||||
message: String,
|
||||
}
|
||||
|
||||
@@ -37,6 +38,9 @@ impl TreeCommit {
|
||||
pub fn destination(&self) -> Option<&str> {
|
||||
self.destination.as_deref()
|
||||
}
|
||||
pub fn changed_paths(&self) -> &[std::path::PathBuf] {
|
||||
&self.changed_paths
|
||||
}
|
||||
pub fn message(&self) -> &str {
|
||||
&self.message
|
||||
}
|
||||
@@ -148,6 +152,16 @@ impl<'a> TreeMutator<'a> {
|
||||
action: MutationAction::Remove,
|
||||
source: display.clone(),
|
||||
destination: None,
|
||||
changed_paths: entries
|
||||
.iter()
|
||||
.map(|entry| entry.source.encrypted_relative_path())
|
||||
.chain(policies.iter().flat_map(|policy| {
|
||||
[
|
||||
policy.directory.as_path().join(".gpg-id"),
|
||||
policy.directory.as_path().join(".gpg-id.sig"),
|
||||
]
|
||||
}))
|
||||
.collect(),
|
||||
message: format!("Remove {display} from store."),
|
||||
};
|
||||
if let Err(error) = committer.commit(&change) {
|
||||
@@ -452,10 +466,34 @@ impl<'a> TreeMutator<'a> {
|
||||
MutationAction::Copy
|
||||
};
|
||||
let verb = if moving { "Rename" } else { "Copy" };
|
||||
let mut changed_paths = entries
|
||||
.iter()
|
||||
.map(|entry| entry.destination.encrypted_relative_path())
|
||||
.chain(policies.iter().flat_map(|policy| {
|
||||
[
|
||||
policy.destination.as_path().join(".gpg-id"),
|
||||
policy.destination.as_path().join(".gpg-id.sig"),
|
||||
]
|
||||
}))
|
||||
.collect::<Vec<_>>();
|
||||
if moving {
|
||||
changed_paths.extend(
|
||||
source_entries
|
||||
.iter()
|
||||
.map(|entry| entry.source.encrypted_relative_path()),
|
||||
);
|
||||
changed_paths.extend(source_policies.iter().flat_map(|policy| {
|
||||
[
|
||||
policy.directory.as_path().join(".gpg-id"),
|
||||
policy.directory.as_path().join(".gpg-id.sig"),
|
||||
]
|
||||
}));
|
||||
}
|
||||
let change = TreeCommit {
|
||||
action,
|
||||
source: source.to_owned(),
|
||||
destination: Some(destination.to_owned()),
|
||||
changed_paths,
|
||||
message: format!("{verb} {source} to {destination}."),
|
||||
};
|
||||
if let Err(error) = committer.commit(&change) {
|
||||
|
||||
Reference in New Issue
Block a user