Struct RawRepository

Source
pub struct RawRepository { /* private fields */ }

Implementations§

Source§

impl RawRepository

Source

pub async fn init( directory: &str, init_commit_message: &str, init_commit_branch: &Branch, ) -> Result<Self, Error>
where Self: Sized,

Initialize the genesis repository from the genesis working tree.

Fails if there is already a repository.

Source

pub async fn open(directory: &str) -> Result<Self, Error>
where Self: Sized,

Loads an exisitng repository.

Source

pub async fn clone(directory: &str, url: &str) -> Result<Self, Error>
where Self: Sized,

Clones an exisitng repository.

Fails if there is no repository with url.

Source

pub async fn retrieve_commit_hash( &self, revision_selection: String, ) -> Result<CommitHash, Error>

Returns the full commit hash from the revision selection string.

See the reference.

Source

pub async fn list_branches(&self) -> Result<Vec<Branch>, Error>

Returns the list of branches.

Source

pub async fn create_branch( &self, branch_name: Branch, commit_hash: CommitHash, ) -> Result<(), Error>

Creates a branch on the commit.

Source

pub async fn locate_branch(&self, branch: Branch) -> Result<CommitHash, Error>

Gets the commit that the branch points to.

Source

pub async fn get_branches( &self, commit_hash: CommitHash, ) -> Result<Vec<Branch>, Error>

Gets the list of branches from the commit.

Source

pub async fn move_branch( &mut self, branch: Branch, commit_hash: CommitHash, ) -> Result<(), Error>

Moves the branch.

Source

pub async fn delete_branch(&mut self, branch: Branch) -> Result<(), Error>

Deletes the branch.

Source

pub async fn list_tags(&self) -> Result<Vec<Tag>, Error>

Returns the list of tags.

Source

pub async fn create_tag( &mut self, tag: Tag, commit_hash: CommitHash, ) -> Result<(), Error>

Creates a tag on the given commit.

Source

pub async fn locate_tag(&self, tag: Tag) -> Result<CommitHash, Error>

Gets the commit that the tag points to.

Source

pub async fn get_tag(&self, commit_hash: CommitHash) -> Result<Vec<Tag>, Error>

Gets the tags on the given commit.

Source

pub async fn remove_tag(&mut self, tag: Tag) -> Result<(), Error>

Removes the tag.

Source

pub async fn create_commit( &mut self, commit: RawCommit, ) -> Result<CommitHash, Error>

Creates a commit from the currently checked out branch by applying the patch.

The commit will be empty commit if diff in RawCommit is None. Committer will be the same as the author.

Source

pub async fn create_commit_all( &mut self, commit: RawCommit, ) -> Result<CommitHash, Error>

Creates a commit from the currently checked out branch without applying the patch.

diff in RawCommit is not used in this function. This is same as git add . && git commit -m "commit_message".

Source

pub async fn read_commit( &self, commit_hash: CommitHash, ) -> Result<RawCommit, Error>

Reads the raw commit at given commit hash.

Source

pub async fn create_semantic_commit( &mut self, commit: SemanticCommit, authored_by_simperby: bool, ) -> Result<CommitHash, Error>

Creates a semantic commit from the currently checked out branch.

It fails if the diff is not Diff::Reserved or Diff::None. If authored_by_simperby is true, the author of commit will be Simperby, otherwise, that will be user.

Source

pub async fn read_semantic_commit( &self, commit_hash: CommitHash, ) -> Result<SemanticCommit, Error>

Reads the semantic commmit at given commit hash.

Source

pub async fn run_garbage_collection(&mut self) -> Result<(), Error>

Removes orphaned commits. Same as git gc --prune=now --aggressive

Source

pub async fn checkout_clean(&mut self) -> Result<(), Error>

Checkouts and cleans the current working tree. This is same as git checkout . && git clean -fd.

Source

pub async fn checkout(&mut self, branch: Branch) -> Result<(), Error>

Checkouts to the branch.

Source

pub async fn checkout_detach( &mut self, commit_hash: CommitHash, ) -> Result<(), Error>

Checkouts to the commit and make HEAD in a detached mode.

Source

pub async fn stash(&mut self) -> Result<(), Error>

Saves the local modifications to a new stash.

Source

pub async fn stash_pop(&mut self, index: bool) -> Result<(), Error>

Pops the most recent stash. If index is true, this is same as git stash pop --index.

Source

pub async fn stash_apply(&mut self, index: bool) -> Result<(), Error>

Applies the most recent stash. If index is true, this is same as git stash apply --index.

Source

pub async fn stash_drop(&mut self) -> Result<(), Error>

Removes the most recent stash.

Source

pub async fn check_clean(&self) -> Result<(), Error>

Checks if there are no unstaged, staged and untracked files.

Source

pub async fn get_working_directory_path(&self) -> Result<String, Error>

Returns the path of working directory.

Source

pub async fn get_head(&self) -> Result<CommitHash, Error>

Returns the commit hash of the current HEAD.

Source

pub async fn get_currently_checkout_branch( &self, ) -> Result<Option<Branch>, Error>

Returns the currently checked-out branch, if any. If the repository is in a detached HEAD state, it returns None.

Source

pub async fn get_initial_commit(&self) -> Result<CommitHash, Error>

Returns the commit hash of the initial commit.

Fails if the repository is empty.

Source

pub async fn get_patch(&self, commit_hash: CommitHash) -> Result<String, Error>

Returns the patch of the given commit.

Source

pub async fn show_commit( &self, commit_hash: CommitHash, ) -> Result<String, Error>

Returns the diff of the given commit.

Source

pub async fn list_ancestors( &self, commit_hash: CommitHash, max: Option<usize>, ) -> Result<Vec<CommitHash>, Error>

Lists the ancestor commits of the given commit (The first element is the direct parent).

It fails if there is a merge commit.

  • max: the maximum number of entries to be returned.
Source

pub async fn query_commit_path( &self, ancestor: CommitHash, descendant: CommitHash, ) -> Result<Vec<CommitHash>, Error>

Queries the commits from the very next commit of ancestor to descendant. ancestor not included, descendant included.

It fails if the two commits are the same. It fails if the ancestor is not the merge base of the two commits.

Source

pub async fn list_children( &self, commit_hash: CommitHash, ) -> Result<Vec<CommitHash>, Error>

Returns the children commits of the given commit.

Source

pub async fn find_merge_base( &self, commit_hash1: CommitHash, commit_hash2: CommitHash, ) -> Result<CommitHash, Error>

Returns the merge base of the two commits.

Source

pub async fn read_reserved_state(&self) -> Result<ReservedState, Error>

Reads the reserved state from the currently checked out branch.

Source

pub async fn read_reserved_state_at_commit( &self, commit_hash: CommitHash, ) -> Result<ReservedState, Error>

Reads the reserved state at given commit hash.

Source

pub async fn add_remote( &mut self, remote_name: String, remote_url: String, ) -> Result<(), Error>

Adds a remote repository.

Source

pub async fn remove_remote(&mut self, remote_name: String) -> Result<(), Error>

Removes a remote repository.

Source

pub async fn fetch_all(&mut self, prune: bool) -> Result<(), Error>

Fetches the remote repository. Same as git fetch --all -j <LARGE NUMBER>.

Source

pub async fn push_option( &self, remote_name: String, branch: Branch, option: Option<String>, ) -> Result<(), Error>

Pushes to the remote repository with the push option. This is same as git push <remote_name> <branch_name> --push-option=<string>.

Source

pub async fn ping_remote(&self, remote_name: String) -> Result<bool, Error>

Checks if the server of remote repository is open.

Source

pub async fn list_remotes(&self) -> Result<Vec<(String, String)>, Error>

Lists all the remote repositories.

Returns (remote_name, remote_url).

Source

pub async fn list_remote_tracking_branches( &self, ) -> Result<Vec<(String, String, CommitHash)>, Error>

Lists all the remote tracking branches.

Returns (remote_name, branch_name, commit_hash)

Source

pub async fn locate_remote_tracking_branch( &self, remote_name: String, branch_name: String, ) -> Result<CommitHash, Error>

Returns the commit of given remote branch.

Trait Implementations§

Source§

impl Debug for RawRepository

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,