Skip to content

Commit

Permalink
adding metadata to the pycommit object
Browse files Browse the repository at this point in the history
  • Loading branch information
gschoeni committed Jul 15, 2023
1 parent 76ec466 commit c9a6edf
Showing 1 changed file with 35 additions and 2 deletions.
37 changes: 35 additions & 2 deletions oxen/src/py_commit.rs
Expand Up @@ -11,8 +11,41 @@ pub struct PyCommit {

#[pymethods]
impl PyCommit {
fn __repr__(&self) -> String {
format!("PyCommit(id={}, message={}, author={}, email={}, timestamp={}, parent_ids=[{}])", self.commit.id, self.commit.message, self.commit.author, self.commit.email, self.commit.timestamp, self.commit.parent_ids.join(", "))
}

fn __str__(&self) -> String {
self.commit.id.to_owned()
}

#[getter]
pub fn commit_id(&self) -> String {
self.commit.id.to_string()
}

#[getter]
pub fn message(&self) -> String {
self.commit.message.to_string()
}

#[getter]
pub fn author(&self) -> String {
self.commit.author.to_string()
}

#[getter]
pub fn email(&self) -> String {
self.commit.email.to_string()
}

#[getter]
pub fn timestamp(&self) -> String {
self.commit.timestamp.to_string()
}

#[getter]
pub fn commit_id(&self) -> PyResult<String> {
Ok(self.commit.id.to_string())
pub fn parent_ids(&self) -> Vec<String> {
self.commit.parent_ids.to_owned()
}
}

0 comments on commit c9a6edf

Please sign in to comment.