Skip to content

Commit 2f157a6

Browse files
committed
Use scanned tree commit in inspect links
1 parent ac34da2 commit 2f157a6

3 files changed

Lines changed: 295 additions & 97 deletions

File tree

tools/inspect/function_hyper.hpp

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -20,45 +20,44 @@ using hpx::filesystem::path;
2020
// When you have a specific line and the line is the location of the link
2121
inline std::string linelink(path const& full_path, std::string const& linenumb)
2222
{
23-
std::string commit = HPX_HAVE_GIT_COMMIT;
23+
std::string blob_prefix = boost::inspect::search_root_git_blob_prefix();
24+
if (blob_prefix.empty())
25+
{
26+
return linenumb;
27+
}
28+
2429
std::string location = boost::inspect::relative_to(
25-
full_path, boost::inspect::search_root_path());
26-
//The erase function for location is to get rid of the first /hpx that will always
27-
//be present in any full path this tool is used for (repeated in wordlink and
28-
// loclink)
29-
std::string total =
30-
"<a href = \"https://github.com/TheHPXProject/hpx/blob/" + commit +
31-
location + "#L" + linenumb + "\">";
32-
total = total + linenumb;
33-
total = total + "</a>";
34-
return total;
30+
full_path, boost::inspect::search_root_git_path());
31+
return "<a href = \"" + blob_prefix + location + "#L" + linenumb + "\">" +
32+
linenumb + "</a>";
3533
}
3634

3735
// When you have a specific line, but a word is the location of the link
3836
inline std::string wordlink(
3937
path const& full_path, std::string const& linenumb, std::string const& word)
4038
{
41-
std::string commit = HPX_HAVE_GIT_COMMIT;
39+
std::string blob_prefix = boost::inspect::search_root_git_blob_prefix();
40+
if (blob_prefix.empty())
41+
{
42+
return word;
43+
}
44+
4245
std::string location = boost::inspect::relative_to(
43-
full_path, boost::inspect::search_root_path());
44-
std::string total =
45-
"<a href = \"https://github.com/TheHPXProject/hpx/blob/" + commit +
46-
location + "#L" + linenumb + "\">";
47-
total = total + word;
48-
total = total + "</a>";
49-
return total;
46+
full_path, boost::inspect::search_root_git_path());
47+
return "<a href = \"" + blob_prefix + location + "#L" + linenumb + "\">" +
48+
word + "</a>";
5049
}
5150

5251
// When you don't have a specific line
5352
inline std::string loclink(path const& full_path, std::string const& word)
5453
{
55-
std::string commit = HPX_HAVE_GIT_COMMIT;
54+
std::string blob_prefix = boost::inspect::search_root_git_blob_prefix();
55+
if (blob_prefix.empty())
56+
{
57+
return word;
58+
}
59+
5660
std::string location = boost::inspect::relative_to(
57-
full_path, boost::inspect::search_root_path());
58-
std::string total =
59-
"<a href = \"https://github.com/TheHPXProject/hpx/blob/" + commit +
60-
location + "\">";
61-
total = total + word;
62-
total = total + "</a>";
63-
return total;
61+
full_path, boost::inspect::search_root_git_path());
62+
return "<a href = \"" + blob_prefix + location + "\">" + word + "</a>";
6463
}

0 commit comments

Comments
 (0)