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

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 = GitRepository::new("./data/git-platinum")
    .expect("Could not retrieve ./data/git-platinum as git repository");
let browser = GitBrowser::new(&repo).expect("Could not initialise Browser");
let directory = browser.get_directory().expect("Could not render 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")))
    .unwrap();
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;

Structs

Branch

The combination of a branch's name and where its locality (remote or local).

BranchName

A newtype wrapper over String to separate out the fact that a caller wants to fetch a branch.

GitRepository

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

Sha1

A newtype wrapper over String to separate out the fact that a caller wants to fetch a commit.

TagName

A newtype wrapper over String to separate out the fact that a caller wants to fetch a tag.

Enums

GitError
GitObject

An enumeration of git objects we can fetch and turn into a GitHistory.

Type Definitions

GitBrowser

A Browser that uses GitRepository as the underlying repository backend, git2::Commit as the artifact, and GitError for error reporting.

GitHistory

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