pub struct RawRepository { /* private fields */ }
Implementations§
Source§impl RawRepository
impl RawRepository
Sourcepub async fn init(
directory: &str,
init_commit_message: &str,
init_commit_branch: &Branch,
) -> Result<Self, Error>where
Self: Sized,
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.
Sourcepub async fn open(directory: &str) -> Result<Self, Error>where
Self: Sized,
pub async fn open(directory: &str) -> Result<Self, Error>where
Self: Sized,
Loads an exisitng repository.
Sourcepub async fn clone(directory: &str, url: &str) -> Result<Self, Error>where
Self: Sized,
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.
Sourcepub async fn retrieve_commit_hash(
&self,
revision_selection: String,
) -> Result<CommitHash, Error>
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.
Sourcepub async fn create_branch(
&self,
branch_name: Branch,
commit_hash: CommitHash,
) -> Result<(), Error>
pub async fn create_branch( &self, branch_name: Branch, commit_hash: CommitHash, ) -> Result<(), Error>
Creates a branch on the commit.
Sourcepub async fn locate_branch(&self, branch: Branch) -> Result<CommitHash, Error>
pub async fn locate_branch(&self, branch: Branch) -> Result<CommitHash, Error>
Gets the commit that the branch points to.
Sourcepub async fn get_branches(
&self,
commit_hash: CommitHash,
) -> Result<Vec<Branch>, Error>
pub async fn get_branches( &self, commit_hash: CommitHash, ) -> Result<Vec<Branch>, Error>
Gets the list of branches from the commit.
Sourcepub async fn move_branch(
&mut self,
branch: Branch,
commit_hash: CommitHash,
) -> Result<(), Error>
pub async fn move_branch( &mut self, branch: Branch, commit_hash: CommitHash, ) -> Result<(), Error>
Moves the branch.
Returns the list of tags.
Sourcepub async fn create_tag(
&mut self,
tag: Tag,
commit_hash: CommitHash,
) -> Result<(), Error>
pub async fn create_tag( &mut self, tag: Tag, commit_hash: CommitHash, ) -> Result<(), Error>
Creates a tag on the given commit.
Sourcepub async fn locate_tag(&self, tag: Tag) -> Result<CommitHash, Error>
pub async fn locate_tag(&self, tag: Tag) -> Result<CommitHash, Error>
Gets the commit that the tag points to.
Sourcepub async fn get_tag(&self, commit_hash: CommitHash) -> Result<Vec<Tag>, Error>
pub async fn get_tag(&self, commit_hash: CommitHash) -> Result<Vec<Tag>, Error>
Gets the tags on the given commit.
Sourcepub async fn create_commit(
&mut self,
commit: RawCommit,
) -> Result<CommitHash, Error>
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.
Sourcepub async fn create_commit_all(
&mut self,
commit: RawCommit,
) -> Result<CommitHash, Error>
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"
.
Sourcepub async fn read_commit(
&self,
commit_hash: CommitHash,
) -> Result<RawCommit, Error>
pub async fn read_commit( &self, commit_hash: CommitHash, ) -> Result<RawCommit, Error>
Reads the raw commit at given commit hash.
Sourcepub async fn create_semantic_commit(
&mut self,
commit: SemanticCommit,
authored_by_simperby: bool,
) -> Result<CommitHash, Error>
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.
Sourcepub async fn read_semantic_commit(
&self,
commit_hash: CommitHash,
) -> Result<SemanticCommit, Error>
pub async fn read_semantic_commit( &self, commit_hash: CommitHash, ) -> Result<SemanticCommit, Error>
Reads the semantic commmit at given commit hash.
Sourcepub async fn run_garbage_collection(&mut self) -> Result<(), Error>
pub async fn run_garbage_collection(&mut self) -> Result<(), Error>
Removes orphaned commits. Same as git gc --prune=now --aggressive
Sourcepub async fn checkout_clean(&mut self) -> Result<(), Error>
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
.
Sourcepub async fn checkout_detach(
&mut self,
commit_hash: CommitHash,
) -> Result<(), Error>
pub async fn checkout_detach( &mut self, commit_hash: CommitHash, ) -> Result<(), Error>
Checkouts to the commit and make HEAD
in a detached mode.
Sourcepub async fn stash(&mut self) -> Result<(), Error>
pub async fn stash(&mut self) -> Result<(), Error>
Saves the local modifications to a new stash.
Sourcepub async fn stash_pop(&mut self, index: bool) -> Result<(), Error>
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
.
Sourcepub async fn stash_apply(&mut self, index: bool) -> Result<(), Error>
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
.
Sourcepub async fn stash_drop(&mut self) -> Result<(), Error>
pub async fn stash_drop(&mut self) -> Result<(), Error>
Removes the most recent stash.
Sourcepub async fn check_clean(&self) -> Result<(), Error>
pub async fn check_clean(&self) -> Result<(), Error>
Checks if there are no unstaged, staged and untracked files.
Sourcepub async fn get_working_directory_path(&self) -> Result<String, Error>
pub async fn get_working_directory_path(&self) -> Result<String, Error>
Returns the path of working directory.
Sourcepub async fn get_head(&self) -> Result<CommitHash, Error>
pub async fn get_head(&self) -> Result<CommitHash, Error>
Returns the commit hash of the current HEAD.
Sourcepub async fn get_currently_checkout_branch(
&self,
) -> Result<Option<Branch>, Error>
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.
Sourcepub async fn get_initial_commit(&self) -> Result<CommitHash, Error>
pub async fn get_initial_commit(&self) -> Result<CommitHash, Error>
Returns the commit hash of the initial commit.
Fails if the repository is empty.
Sourcepub async fn get_patch(&self, commit_hash: CommitHash) -> Result<String, Error>
pub async fn get_patch(&self, commit_hash: CommitHash) -> Result<String, Error>
Returns the patch of the given commit.
Sourcepub async fn show_commit(
&self,
commit_hash: CommitHash,
) -> Result<String, Error>
pub async fn show_commit( &self, commit_hash: CommitHash, ) -> Result<String, Error>
Returns the diff of the given commit.
Sourcepub async fn list_ancestors(
&self,
commit_hash: CommitHash,
max: Option<usize>,
) -> Result<Vec<CommitHash>, Error>
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.
Sourcepub async fn query_commit_path(
&self,
ancestor: CommitHash,
descendant: CommitHash,
) -> Result<Vec<CommitHash>, Error>
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.
Sourcepub async fn list_children(
&self,
commit_hash: CommitHash,
) -> Result<Vec<CommitHash>, Error>
pub async fn list_children( &self, commit_hash: CommitHash, ) -> Result<Vec<CommitHash>, Error>
Returns the children commits of the given commit.
Sourcepub async fn find_merge_base(
&self,
commit_hash1: CommitHash,
commit_hash2: CommitHash,
) -> Result<CommitHash, Error>
pub async fn find_merge_base( &self, commit_hash1: CommitHash, commit_hash2: CommitHash, ) -> Result<CommitHash, Error>
Returns the merge base of the two commits.
Sourcepub async fn read_reserved_state(&self) -> Result<ReservedState, Error>
pub async fn read_reserved_state(&self) -> Result<ReservedState, Error>
Reads the reserved state from the currently checked out branch.
Sourcepub async fn read_reserved_state_at_commit(
&self,
commit_hash: CommitHash,
) -> Result<ReservedState, Error>
pub async fn read_reserved_state_at_commit( &self, commit_hash: CommitHash, ) -> Result<ReservedState, Error>
Reads the reserved state at given commit hash.
Sourcepub async fn add_remote(
&mut self,
remote_name: String,
remote_url: String,
) -> Result<(), Error>
pub async fn add_remote( &mut self, remote_name: String, remote_url: String, ) -> Result<(), Error>
Adds a remote repository.
Sourcepub async fn remove_remote(&mut self, remote_name: String) -> Result<(), Error>
pub async fn remove_remote(&mut self, remote_name: String) -> Result<(), Error>
Removes a remote repository.
Sourcepub async fn fetch_all(&mut self, prune: bool) -> Result<(), Error>
pub async fn fetch_all(&mut self, prune: bool) -> Result<(), Error>
Fetches the remote repository. Same as git fetch --all -j <LARGE NUMBER>
.
Sourcepub async fn push_option(
&self,
remote_name: String,
branch: Branch,
option: Option<String>,
) -> Result<(), Error>
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>
.
Sourcepub async fn ping_remote(&self, remote_name: String) -> Result<bool, Error>
pub async fn ping_remote(&self, remote_name: String) -> Result<bool, Error>
Checks if the server of remote repository is open.
Sourcepub async fn list_remotes(&self) -> Result<Vec<(String, String)>, Error>
pub async fn list_remotes(&self) -> Result<Vec<(String, String)>, Error>
Lists all the remote repositories.
Returns (remote_name, remote_url)
.
Sourcepub async fn list_remote_tracking_branches(
&self,
) -> Result<Vec<(String, String, CommitHash)>, Error>
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)
Sourcepub async fn locate_remote_tracking_branch(
&self,
remote_name: String,
branch_name: String,
) -> Result<CommitHash, Error>
pub async fn locate_remote_tracking_branch( &self, remote_name: String, branch_name: String, ) -> Result<CommitHash, Error>
Returns the commit of given remote branch.