pub struct Repo {
pub path: PathBuf,
pub conf: Config,
}Fields§
§path: PathBufThe absolute path of the opened repo.
conf: ConfigImplementations§
Source§impl Repo
impl Repo
Sourcepub fn open(path: impl AsRef<Path>) -> Result<Self>
pub fn open(path: impl AsRef<Path>) -> Result<Self>
Open a repo. The path argument must be an absolute path.
pub fn path(&self) -> &Path
pub fn to_absolute_path(&self, path: impl AsRef<Path>) -> PathBuf
Sourcepub fn get_key(&self) -> Result<String>
pub fn get_key(&self) -> Result<String>
Read the master key from git config.
Returns an error if the key has not been configured.
Sourcepub fn set_key_interactive(&self) -> Result<()>
pub fn set_key_interactive(&self) -> Result<()>
Set the key interactively by prompting on stdin.
Sourcepub fn check(&self, paths: &[PathBuf], staged: bool) -> Result<()>
pub fn check(&self, paths: &[PathBuf], staged: bool) -> Result<()>
Check if all files in the crypt list (or given paths) are encrypted.
When staged is true, only files staged for the current commit are
checked, by intersecting staged files against the crypt list. This is
used by the pre-commit hook to avoid checking the entire repo.
Returns Ok(()) if all files are encrypted, or an error summarizing
which files are not encrypted. The process exits with a non-zero code
when files are not encrypted, suitable for CI usage.
Sourcepub fn install_hook(&self) -> Result<()>
pub fn install_hook(&self) -> Result<()>
Install a pre-commit hook that runs git-se check before each commit.
Creates <repo>/.git/hooks/pre-commit with the check script.
Fails if a hook already exists and is not managed by git-se.
Sourcepub fn run(&self, args: &[&str]) -> Result<()>
pub fn run(&self, args: &[&str]) -> Result<()>
Run a git command in the repo, discarding its stdout/stderr.
Sourcepub fn run_with_output(&self, args: &[&str]) -> Result<String>
pub fn run_with_output(&self, args: &[&str]) -> Result<String>
Run a git command and return its trimmed stdout as a String.
Sourcepub fn set_config(&self, key: &str, value: &str) -> Result<()>
pub fn set_config(&self, key: &str, value: &str) -> Result<()>
Write a value to <prefix>.<key> in the repo-local git config.
Note: the value is stored verbatim (no trimming), so callers should
sanitize it themselves if needed. This matters for the key field,
which holds a user-supplied password and must not be silently modified.
Sourcepub fn get_config(&self, key: &str) -> Result<String>
pub fn get_config(&self, key: &str) -> Result<String>
Read <prefix>.<key> from the repo-local git config.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Repo
impl RefUnwindSafe for Repo
impl Send for Repo
impl Sync for Repo
impl Unpin for Repo
impl UnsafeUnpin for Repo
impl UnwindSafe for Repo
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.