Represents a single, immutable historical point (snapshot) in the repository's history.
More...
#include <Commit.hxx>
|
|
| Commit () |
| | Default constructor.
|
| | Commit (std::string thash, std::vector< std::string > phashes, std::string auth, std::string msg, std::time_t tstamp=std::time(nullptr)) |
| | Main constructor for the Commit object.
|
| std::string | getType () const override |
| | Returns the type of the VCS object.
|
| std::string | serialize () const override |
| | Serializes the Commit metadata into a standardized, canonical format for hashing and storage.
|
| const std::string & | getTreeHash () const |
| | Returns the hash ID of the associated root Tree object.
|
| const std::vector< std::string > & | getParentHashes () const |
| | Returns the hash IDs of the parent commits.
|
| const std::string & | getAuthor () const |
| | Returns the author and email string for the commit.
|
| std::time_t | getTimestamp () const |
| | Returns the UNIX timestamp of the commit creation.
|
| const std::string & | getMessage () const |
| | Returns the user-defined commit message.
|
| void | setMessage (const std::string &msg) |
| | Sets the commit message.
|
| void | setTimestamp (std::time_t tstamp) |
| | Sets the commit timestamp.
|
|
void | setTimestampNow () |
| | Sets the commit timestamp to the current time.
|
| void | setParent (const std::string &parent) |
| | Sets a parent commit hash.
|
|
| VcsObject ()=default |
| | Default constructor. Required for derived classes.
|
| | VcsObject (const VcsObject &other)=default |
| | Copy constructor. Required for derived classes to correctly copy the hash_id.
|
| virtual | ~VcsObject ()=default |
| | Virtual destructor.
|
| std::string | getHashId () const |
| | Returns the unique hash identifier of the object.
|
|
| static Commit | deserialize (const std::string &raw_content) |
| | Creates a Commit object from a serialized string read from the object database.
|
| static std::string | calculateHash (const std::string &content) |
| | Calculates SHA-256 hash for given canonical content.
|
|
| void | computeHash (const std::string &content) |
| | Computes the cryptographic hash ID for the object's content.
|
| std::string | hash_id |
| | The unique cryptographic hash identifier (e.g., SHA-256) for this object.
|
Represents a single, immutable historical point (snapshot) in the repository's history.
This object binds the content structure (Tree hash) with the metadata (author, message, parent history).
◆ Commit()
| svcs::core::Commit::Commit |
( |
std::string | thash, |
|
|
std::vector< std::string > | phashes, |
|
|
std::string | auth, |
|
|
std::string | msg, |
|
|
std::time_t | tstamp = std::time(nullptr) ) |
Main constructor for the Commit object.
Initializes the metadata fields, sorts the parent hashes for consistency, and immediately computes the object's hash ID.
- Parameters
-
| thash | Hash of the root Tree object. |
| phashes | Hashes of the immediate parent commit(s). |
| auth | Author and email string. |
| msg | User-defined commit message. |
| tstamp | Time when the commit was created (default is current time). |
◆ deserialize()
| Commit svcs::core::Commit::deserialize |
( |
const std::string & | raw_content | ) |
|
|
static |
Creates a Commit object from a serialized string read from the object database.
- Parameters
-
| raw_content | The serialized string data, typically read from a decompressed object file. |
- Returns
- Commit A fully reconstructed Commit object.
◆ getAuthor()
| const std::string & svcs::core::Commit::getAuthor |
( |
| ) |
const |
|
nodiscard |
Returns the author and email string for the commit.
- Returns
- const std::string& The author string.
◆ getMessage()
| const std::string & svcs::core::Commit::getMessage |
( |
| ) |
const |
|
nodiscard |
Returns the user-defined commit message.
- Returns
- const std::string& The commit message.
◆ getParentHashes()
| const std::vector< std::string > & svcs::core::Commit::getParentHashes |
( |
| ) |
const |
|
nodiscard |
Returns the hash IDs of the parent commits.
- Returns
- const std::vector<std::string>& The list of parent hashes (sorted).
◆ getTimestamp()
| std::time_t svcs::core::Commit::getTimestamp |
( |
| ) |
const |
|
nodiscard |
Returns the UNIX timestamp of the commit creation.
- Returns
- std::time_t The timestamp value.
◆ getTreeHash()
| const std::string & svcs::core::Commit::getTreeHash |
( |
| ) |
const |
|
nodiscard |
Returns the hash ID of the associated root Tree object.
- Returns
- const std::string& The tree hash.
◆ getType()
| std::string svcs::core::Commit::getType |
( |
| ) |
const |
|
nodiscardoverridevirtual |
Returns the type of the VCS object.
- Returns
- std::string Always returns "commit". Pure virtual method to get the type of the VCS object.
This is crucial for object storage and reconstruction (e.g., "commit", "blob", "tree").
- Returns
- std::string The type identifier of the object.
Implements svcs::core::VcsObject.
◆ serialize()
| std::string svcs::core::Commit::serialize |
( |
| ) |
const |
|
nodiscardoverridevirtual |
Serializes the Commit metadata into a standardized, canonical format for hashing and storage.
The serialized format includes key/value pairs (tree, parent, author) followed by the message.
- Returns
- std::string The standardized, serialized commit data. Pure virtual method to serialize the object's core data.
The returned string content is what will be hashed and stored in the database.
- Returns
- std::string The standardized, serialized data of the object.
Implements svcs::core::VcsObject.
◆ setMessage()
| void svcs::core::Commit::setMessage |
( |
const std::string & | msg | ) |
|
Sets the commit message.
- Parameters
-
| msg | The new commit message. |
◆ setParent()
| void svcs::core::Commit::setParent |
( |
const std::string & | parent | ) |
|
Sets a parent commit hash.
- Parameters
-
| parent | The parent commit hash. |
◆ setTimestamp()
| void svcs::core::Commit::setTimestamp |
( |
std::time_t | tstamp | ) |
|
Sets the commit timestamp.
- Parameters
-
| tstamp | The new timestamp value. |
The documentation for this class was generated from the following files: