File tree Expand file tree Collapse file tree 3 files changed +46
-0
lines changed Expand file tree Collapse file tree 3 files changed +46
-0
lines changed Original file line number Diff line number Diff line change @@ -49,6 +49,8 @@ set(GIT2CPP_SRC
49
49
${GIT2CPP_SOURCE_DIR} /utils/common.hpp
50
50
${GIT2CPP_SOURCE_DIR} /utils/git_exception.cpp
51
51
${GIT2CPP_SOURCE_DIR} /utils/git_exception.hpp
52
+ ${GIT2CPP_SOURCE_DIR} /wrapper/commit_wrapper.cpp
53
+ ${GIT2CPP_SOURCE_DIR} /wrapper/commit_wrapper.hpp
52
54
${GIT2CPP_SOURCE_DIR} /wrapper/index_wrapper.cpp
53
55
${GIT2CPP_SOURCE_DIR} /wrapper/index_wrapper.hpp
54
56
${GIT2CPP_SOURCE_DIR} /wrapper/refs_wrapper.cpp
Original file line number Diff line number Diff line change
1
+ #include " commit_wrapper.hpp"
2
+ #include " ../utils/git_exception.hpp"
3
+
4
+ commit_wrapper::~commit_wrapper ()
5
+ {
6
+ git_commit_free (p_resource);
7
+ p_resource = nullptr ;
8
+ }
9
+
10
+
11
+ commit_wrapper commit_wrapper::last_commit (const repository_wrapper& repo, const std::string& ref_name)
12
+ {
13
+ git_oid oid_parent_commit;
14
+ throwIfError (git_reference_name_to_id (&oid_parent_commit, repo, ref_name.c_str ()));
15
+
16
+ commit_wrapper cw;
17
+ throwIfError (git_commit_lookup (&(cw.p_resource ), repo, &oid_parent_commit));
18
+ return cw;
19
+ }
Original file line number Diff line number Diff line change
1
+ #pragma once
2
+
3
+ #include < string>
4
+
5
+ #include < git2.h>
6
+
7
+ #include " ../wrapper/repository_wrapper.hpp"
8
+ #include " ../wrapper/wrapper_base.hpp"
9
+
10
+ class commit_wrapper : public wrapper_base <git_commit>
11
+ {
12
+ public:
13
+
14
+ ~commit_wrapper ();
15
+
16
+ commit_wrapper (commit_wrapper&&) = default ;
17
+ commit_wrapper& operator =(commit_wrapper&&) = default ;
18
+
19
+ static commit_wrapper
20
+ last_commit (const repository_wrapper& repo, const std::string& ref_name = " HEAD" );
21
+
22
+ private:
23
+
24
+ commit_wrapper () = default ;
25
+ };
You can’t perform that action at this time.
0 commit comments