-
Notifications
You must be signed in to change notification settings - Fork 2
/
Branch.cpp
39 lines (31 loc) · 972 Bytes
/
Branch.cpp
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
#include "Branch.h"
#include "Repository.h"
#include "SmartLibGitHeapPointerTemplate.hpp"
#include <stdexcept>
using Reference = Git::Reference;
using Branch = Git::Branch;
using Repository = Git::Repository;
Branch::Branch(const std::string& _repositoryKey
, const std::string& _name
, bool _isLocal /* = true */
) : Reference(_repositoryKey, _name), local(_isLocal)
{
Repository repository(_repositoryKey);
if(!repository.isOwnedByRepo(*this))
{
throw std::invalid_argument("Not found in repository.");
}
}
/* private */ uniquePtr<git_commit> Branch::getReferenceHeadLibGitCommit(const std::string& branchName) const
{
std::string fullReferenceName;
if(isLocal())
{
fullReferenceName = "refs/heads/" + branchName;
}
else
{
fullReferenceName = "refs/remotes/" + branchName;
}
return Reference::getReferenceHeadLibGitCommit(fullReferenceName);
}