-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathremote_wrapper.cpp
More file actions
64 lines (51 loc) · 1.51 KB
/
remote_wrapper.cpp
File metadata and controls
64 lines (51 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include "../wrapper/remote_wrapper.hpp"
#include <string>
#include <vector>
#include <git2/remote.h>
#include "../utils/git_exception.hpp"
remote_wrapper::remote_wrapper(git_remote* remote)
: base_type(remote)
{
}
remote_wrapper::~remote_wrapper()
{
git_remote_free(p_resource);
p_resource = nullptr;
}
std::string_view remote_wrapper::name() const
{
const char* out = git_remote_name(*this);
return out ? std::string_view(out) : std::string_view();
}
std::string_view remote_wrapper::url() const
{
const char* out = git_remote_url(*this);
return out ? std::string_view(out) : std::string_view();
}
std::string_view remote_wrapper::pushurl() const
{
const char* out = git_remote_pushurl(*this);
return out ? std::string_view(out) : std::string_view();
}
std::vector<std::string> remote_wrapper::refspecs() const
{
git_strarray refspecs = {0};
std::vector<std::string> result;
if (git_remote_get_fetch_refspecs(&refspecs, *this) == 0)
{
for (size_t i = 0; i < refspecs.count; ++i)
{
result.emplace_back(refspecs.strings[i]);
}
git_strarray_dispose(&refspecs);
}
return result;
}
void remote_wrapper::fetch(const git_strarray* refspecs, const git_fetch_options* opts, const char* reflog_message)
{
throw_if_error(git_remote_fetch(*this, refspecs, opts, reflog_message));
}
void remote_wrapper::push(const git_strarray* refspecs, const git_push_options* opts)
{
throw_if_error(git_remote_push(*this, refspecs, opts));
}