-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGitSource.cpp
More file actions
69 lines (61 loc) · 2.39 KB
/
Copy pathGitSource.cpp
File metadata and controls
69 lines (61 loc) · 2.39 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
65
66
67
68
69
#include "runcpp2/Data/GitSource.hpp"
#include "runcpp2/Data/ParseCommon.hpp"
#include "runcpp2/ParseUtil.hpp"
#include "ssLogger/ssLog.hpp"
bool runcpp2::Data::GitSource::ParseYAML_Node(YAML::ConstNodePtr node)
{
std::vector<NodeRequirement> requirements =
{
NodeRequirement("URL", YAML::NodeType::Scalar, true, false),
NodeRequirement("Branch", YAML::NodeType::Scalar, false, false),
NodeRequirement("FullHistory", YAML::NodeType::Scalar, false, false),
NodeRequirement("SubmoduleInitType", YAML::NodeType::Scalar, false, false)
};
if(!CheckNodeRequirements(node, requirements))
{
ssLOG_ERROR("GitSource: Failed to meet requirements");
return false;
}
URL = node->GetMapValueScalar<std::string>("URL").value();
if(ExistAndHasChild(node, "Branch"))
{
Branch = node->GetMapValueScalar<std::string>("Branch").DS_TRY_ACT(return false);
}
if(ExistAndHasChild(node, "FullHistory"))
{
FullHistory = node->GetMapValueScalar<bool>("FullHistory").DS_TRY_ACT(return false);
}
if(ExistAndHasChild(node, "SubmoduleInitType"))
{
std::string submoduleTypeString =
node->GetMapValueScalar<std::string>("SubmoduleInitType").value();
CurrentSubmoduleInitType = StringToSubmoduleInitType(submoduleTypeString);
if(CurrentSubmoduleInitType == SubmoduleInitType::COUNT)
{
ssLOG_ERROR("GitSource: Invalid submodule init type " << submoduleTypeString);
return false;
}
}
return true;
}
std::string runcpp2::Data::GitSource::ToString(std::string indentation) const
{
std::string out;
out += indentation + "Git:\n";
out += indentation + " URL: " + GetEscapedYAMLString(URL) + "\n";
if(!Branch.empty())
out += indentation + " Branch: " + GetEscapedYAMLString(Branch) + "\n";
out += indentation + " FullHistory: " + (FullHistory ? "true" : "false") + "\n";
out += indentation +
" SubmoduleInitType: " +
SubmoduleInitTypeToString(CurrentSubmoduleInitType) +
"\n";
return out;
}
bool runcpp2::Data::GitSource::Equals(const GitSource& other) const
{
return URL == other.URL &&
Branch == other.Branch &&
FullHistory == other.FullHistory &&
CurrentSubmoduleInitType == other.CurrentSubmoduleInitType;
}