startgit

Static page generator for git repositories
git clone git://git.dimitrijedobrota.com/startgit.git
Log | Files | Refs | README | LICENSE | HACKING | CONTRIBUTING | CODE_OF_CONDUCT | BUILDING |

commit.cpp (1504B)


1 #include "commit.hpp" 2 3 #include <git2wrap/diff.hpp> 4 #include <git2wrap/signature.hpp> 5 6 #include "utils.hpp" 7 8 namespace startgit 9 { 10 11 commit::commit(git2wrap::commit cmmt) 12 : m_commit(std::move(cmmt)) 13 , m_diff(m_commit) 14 { 15 } 16 17 std::string commit::get_id() const 18 { 19 return m_commit.get_id().get_hex_string(shasize); 20 } 21 22 std::string commit::get_parent_id() const 23 { 24 return m_commit.get_parent().get_id().get_hex_string(shasize); 25 } 26 27 size_t commit::get_parentcount() const 28 { 29 return m_commit.get_parentcount(); 30 } 31 32 std::string commit::get_summary() const 33 { 34 std::string summary = m_commit.get_summary(); 35 36 static const int summary_limit = 50; 37 if (summary.size() > summary_limit) { 38 summary.resize(summary_limit); 39 for (size_t i = summary.size() - 1; i >= summary.size() - 4; i--) { 40 summary[i] = '.'; 41 } 42 } 43 44 return summary; 45 } 46 47 std::string commit::get_time() const 48 { 49 return time_short(m_commit.get_author().get_time().time); 50 } 51 52 std::string commit::get_time_long() const 53 { 54 return time_long(m_commit.get_author().get_time()); 55 } 56 57 int64_t commit::get_time_raw() const 58 { 59 return m_commit.get_author().get_time().time; 60 } 61 62 std::string commit::get_author_name() const 63 { 64 return m_commit.get_author().get_name(); 65 } 66 67 std::string commit::get_author_email() const 68 { 69 return m_commit.get_author().get_email(); 70 } 71 72 git2wrap::tree commit::get_tree() const 73 { 74 return m_commit.get_tree(); 75 } 76 77 std::string commit::get_message() const 78 { 79 return m_commit.get_message(); 80 } 81 82 } // namespace startgit