fabricatio_thinking.rust
Classes
Represents a simple version control system for managing branches and their commits. |
Package Contents
- class fabricatio_thinking.rust.ThoughtVCS
Represents a simple version control system for managing branches and their commits.
- commit(content: str, serial: int, estimated: int, branch: str | None = None, insert: bool = True) int | None
Commits new content to a branch, creating the branch if necessary.
- Parameters:
content – The content of the commit.
serial – The serial number (1-based) for the commit.
estimated – The estimated total number of commits for the branch.
branch – The name of the branch, or None for the default branch.
insert – Whether to create the branch if it does not exist.
- Returns:
Some(new_commit_count) if the commit was added, or None otherwise.
- revise(content: str, serial: int, branch: str | None) int | None
Revises the content of an existing commit in a branch.
- Parameters:
content – The new content for the commit.
serial – The serial number (1-based) of the commit to revise.
branch – The name of the branch, or None for the default branch.
- Returns:
Some(serial) if the commit was revised, or None otherwise.
- checkout(branch: str, serial: int) str | None
Checks out a branch at a specific commit serial, truncating it to that point.
- Parameters:
branch – The name of the branch to checkout.
serial – The number of commits to include in the checked-out branch.
- Returns:
Some(branch_name) if the checkout was successful, or None otherwise.
- export_branch(branch: str | None = None) list[str]
Exports the list of commits for a given branch.
This function retrieves all commits associated with the specified branch. If the branch does not exist, it returns an empty vector.
- Parameters:
branch – An optional string representing the name of the branch. If None, the default branch is used.
- Returns:
A vector of strings where each string represents a commit in the branch. If the branch does not exist, an empty vector is returned.
- export_branch_string(branch: str | None = None) str
Exports the list of commits as a formatted string.
- Parameters:
branch – An optional string representing the name of the branch. If None, the default branch is used.
- Returns:
A formatted string where each line represents a commit in the branch. If the branch does not exist, returns an empty string.