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)


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