mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Improve git commit hash lookup (#5225)
- Also get the branch name. - Use rev-parse instead of describe to get a clean hash. - Return the git hash and branch name in server_info for admin connections. - Include git hash and branch name on separate lines in --version.
This commit is contained in:
@@ -86,21 +86,42 @@ admin = 127.0.0.1
|
||||
|
||||
{
|
||||
Env env(*this);
|
||||
auto const result = env.rpc("server_info");
|
||||
BEAST_EXPECT(!result[jss::result].isMember(jss::error));
|
||||
BEAST_EXPECT(result[jss::result][jss::status] == "success");
|
||||
BEAST_EXPECT(result[jss::result].isMember(jss::info));
|
||||
auto const serverinfo = env.rpc("server_info");
|
||||
BEAST_EXPECT(serverinfo.isMember(jss::result));
|
||||
auto const& result = serverinfo[jss::result];
|
||||
BEAST_EXPECT(!result.isMember(jss::error));
|
||||
BEAST_EXPECT(result[jss::status] == "success");
|
||||
BEAST_EXPECT(result.isMember(jss::info));
|
||||
auto const& info = result[jss::info];
|
||||
BEAST_EXPECT(info.isMember(jss::build_version));
|
||||
// Git info is not guaranteed to be present
|
||||
if (info.isMember(jss::git))
|
||||
{
|
||||
auto const& git = info[jss::git];
|
||||
BEAST_EXPECT(
|
||||
git.isMember(jss::hash) || git.isMember(jss::branch));
|
||||
BEAST_EXPECT(
|
||||
!git.isMember(jss::hash) ||
|
||||
(git[jss::hash].isString() &&
|
||||
git[jss::hash].asString().size() == 40));
|
||||
BEAST_EXPECT(
|
||||
!git.isMember(jss::branch) ||
|
||||
(git[jss::branch].isString() &&
|
||||
git[jss::branch].asString().size() != 0));
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
Env env(*this);
|
||||
|
||||
// Call NetworkOPs directly and set the admin flag to false.
|
||||
// Expect that the admin ports are not included in the result.
|
||||
auto const result =
|
||||
env.app().getOPs().getServerInfo(true, false, 0);
|
||||
// Expect that the admin ports are not included in the result.
|
||||
auto const& ports = result[jss::ports];
|
||||
BEAST_EXPECT(ports.isArray() && ports.size() == 0);
|
||||
// Expect that git info is absent
|
||||
BEAST_EXPECT(!result.isMember(jss::git));
|
||||
}
|
||||
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user