Skip to content

Commit

Permalink
Add raw_commit_to_semantic_commit
Browse files Browse the repository at this point in the history
  • Loading branch information
JeongHunP authored and junha1 committed Aug 28, 2023
1 parent 453c87d commit 872cd6f
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion repository/src/format.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::{raw::SemanticCommit, UNKNOWN_COMMIT_AUTHOR};
use crate::{raw::RawCommit, raw::SemanticCommit, UNKNOWN_COMMIT_AUTHOR};
use eyre::{eyre, Error};
use regex::Regex;
use simperby_core::{reserved::ReservedState, *};
Expand Down Expand Up @@ -287,6 +287,26 @@ pub fn fp_from_semantic_commit(
}
}

pub fn raw_commit_to_semantic_commit(raw_commit: RawCommit) -> SemanticCommit {
let (title, body) = if let Some((title, body)) = raw_commit.message.split_once("\n\n") {
(title.to_string(), body.to_string())
} else {
(String::new(), String::new())
};
SemanticCommit {
title,
body,
diff: if raw_commit.diff.is_none() {
Diff::None
} else {
// TODO: should handle cases, `Reserved`, `NonReserved, `General`.
unimplemented!()
},
author: raw_commit.author,
timestamp: raw_commit.timestamp,
}
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down

0 comments on commit 872cd6f

Please sign in to comment.