Skip to content
44 changes: 42 additions & 2 deletions crates/gitcomet-core/src/services.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,19 @@ pub enum RemoteUrlKind {
Push,
}

#[derive(Clone, Debug, Eq, PartialEq)]
pub struct SubmoduleTrustTarget {
pub submodule_path: PathBuf,
pub display_source: String,
pub local_source_path: PathBuf,
}

#[derive(Clone, Debug, Eq, PartialEq)]
pub enum SubmoduleTrustDecision {
Proceed,
Prompt { sources: Vec<SubmoduleTrustTarget> },
}

#[derive(Clone, Debug, Eq, PartialEq)]
pub struct BlameLine {
pub commit_id: Arc<str>,
Expand Down Expand Up @@ -541,13 +554,40 @@ pub trait GitRepository: Send + Sync {
)))
}

fn add_submodule_with_output(&self, _url: &str, _path: &Path) -> Result<CommandOutput> {
fn check_submodule_add_trust(
&self,
_url: &str,
_path: &Path,
) -> Result<SubmoduleTrustDecision> {
Err(Error::new(ErrorKind::Unsupported(
"submodule trust checks are not implemented for this backend",
)))
}

fn check_submodule_update_trust(&self) -> Result<SubmoduleTrustDecision> {
Err(Error::new(ErrorKind::Unsupported(
"submodule trust checks are not implemented for this backend",
)))
}

fn add_submodule_with_output(
&self,
_url: &str,
_path: &Path,
_branch: Option<&str>,
_name: Option<&str>,
_force: bool,
_approved_sources: &[SubmoduleTrustTarget],
) -> Result<CommandOutput> {
Err(Error::new(ErrorKind::Unsupported(
"submodule add is not implemented for this backend",
)))
}

fn update_submodules_with_output(&self) -> Result<CommandOutput> {
fn update_submodules_with_output(
&self,
_approved_sources: &[SubmoduleTrustTarget],
) -> Result<CommandOutput> {
Err(Error::new(ErrorKind::Unsupported(
"submodule update is not implemented for this backend",
)))
Expand Down
29 changes: 24 additions & 5 deletions crates/gitcomet-git-gix/src/repo/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use gitcomet_core::error::{Error, ErrorKind};
use gitcomet_core::git_ops_trace::{self, GitOpTraceKind};
use gitcomet_core::services::{
BlameLine, CommandOutput, ConflictFileStages, ConflictSide, GitRepository, MergetoolResult,
PullMode, RemoteUrlKind, ResetMode, Result,
PullMode, RemoteUrlKind, ResetMode, Result, SubmoduleTrustDecision, SubmoduleTrustTarget,
};
use std::path::{Path, PathBuf};
use std::process::Command;
Expand Down Expand Up @@ -529,12 +529,31 @@ impl GitRepository for GixRepo {
self.list_submodules_impl()
}

fn add_submodule_with_output(&self, url: &str, path: &Path) -> Result<CommandOutput> {
self.add_submodule_with_output_impl(url, path)
fn check_submodule_add_trust(&self, url: &str, path: &Path) -> Result<SubmoduleTrustDecision> {
self.check_submodule_add_trust_impl(url, path)
}

fn update_submodules_with_output(&self) -> Result<CommandOutput> {
self.update_submodules_with_output_impl()
fn check_submodule_update_trust(&self) -> Result<SubmoduleTrustDecision> {
self.check_submodule_update_trust_impl()
}

fn add_submodule_with_output(
&self,
url: &str,
path: &Path,
branch: Option<&str>,
name: Option<&str>,
force: bool,
approved_sources: &[SubmoduleTrustTarget],
) -> Result<CommandOutput> {
self.add_submodule_with_output_impl(url, path, branch, name, force, approved_sources)
}

fn update_submodules_with_output(
&self,
approved_sources: &[SubmoduleTrustTarget],
) -> Result<CommandOutput> {
self.update_submodules_with_output_impl(approved_sources)
}

fn remove_submodule_with_output(&self, path: &Path) -> Result<CommandOutput> {
Expand Down
Loading
Loading