Module radicle_surf::vcs::git[][src]

use nonempty::NonEmpty;
use radicle_surf::file_system::{Directory, File, Label, Path, SystemType};
use radicle_surf::file_system::unsound;
use radicle_surf::vcs::git::*;
use std::collections::HashMap;

let repo = Repository::new("../data/git-platinum")?;

// Pin the browser to a parituclar commit.
let pin_commit = Oid::from_str("3873745c8f6ffb45c990eb23b491d4b4b6182f95")?;
let mut browser = Browser::new(&repo, Branch::local("master"))?;
browser.commit(pin_commit)?;

let directory = browser.get_directory()?;
let mut directory_contents = directory.list_directory();
directory_contents.sort();

assert_eq!(directory_contents, vec![
    SystemType::file(unsound::label::new(".i-am-well-hidden")),
    SystemType::file(unsound::label::new(".i-too-am-hidden")),
    SystemType::file(unsound::label::new("README.md")),
    SystemType::directory(unsound::label::new("bin")),
    SystemType::directory(unsound::label::new("src")),
    SystemType::directory(unsound::label::new("text")),
    SystemType::directory(unsound::label::new("this")),
]);

// find src directory in the Git directory and the in-memory directory
let src_directory = directory
    .find_directory(Path::new(unsound::label::new("src")))
    .expect("failed to find src");
let mut src_directory_contents = src_directory.list_directory();
src_directory_contents.sort();

assert_eq!(src_directory_contents, vec![
    SystemType::file(unsound::label::new("Eval.hs")),
    SystemType::file(unsound::label::new("Folder.svelte")),
    SystemType::file(unsound::label::new("memory.rs")),
]);

Re-exports

pub use git2;
pub use branch::Branch;
pub use branch::BranchName;
pub use branch::BranchType;
pub use tag::Tag;
pub use tag::TagName;
pub use commit::Author;
pub use commit::Commit;
pub use namespace::Namespace;
pub use stats::Stats;
pub use crate::diff::Diff;

Modules

branch

Provides the data for talking about branches.

commit

Provides the data for talking about commits.

error

Collection of errors and helper instances that can occur when performing operations from crate::vcs::git.

namespace

Provides the data for talking about namespaces.

stats

Provides the data for talking about repository statistics.

tag

Provides the data for talking about tags.

Structs

Git2Error

A structure to represent errors coming out of libgit2.

Oid

Unique identity of any object (commit, tree, blob, tag).

Repository

Wrapper around the git2’s git2::Repository type. This is to to limit the functionality that we can do on the underlying object.

RepositoryRef

A reference-only Repository. This means that we cannot mutate the underlying Repository. Not being able to mutate the Repository means that the functions defined for RepositoryRef should be thread-safe.

Signature

The signature of a commit

Time

Time in a signature

Enums

Ref

A structured way of referring to a git reference.

Rev

A revision within the repository.

Type Definitions

Browser

A crate::vcs::Browser that uses Repository as the underlying repository backend, git2::Commit as the artifact, and Error for error reporting.

History

A History that uses git2::Commit as the underlying artifact.