1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-19 16:59:35 +01:00

Apply clang-format universally.

* It is tough to contribute to a project that doesn't use a formatter,
* It is extra hard to contribute to a project which has configured the formatter, but ignores it for some files
* Code formatting makes it harder to hide obscure / weird bugs by accident or on purpose,

Let's rip the bandaid off?

Note that PRs currently in flight should be able to be merged relatively easily by applying `clang-format` to their tip prior to merge.
This commit is contained in:
Graham Christensen 2025-07-18 12:47:27 -04:00
parent 41bf87ec70
commit e4f62e4608
587 changed files with 23258 additions and 23135 deletions

View file

@ -3,44 +3,37 @@
#include <iostream>
using std::cout;
namespace nix {
static std::string dotQuote(std::string_view s)
{
return "\"" + std::string(s) + "\"";
}
static const std::string & nextColour()
{
static int n = 0;
static std::vector<std::string> colours
{ "black", "red", "green", "blue"
, "magenta", "burlywood" };
static std::vector<std::string> colours{"black", "red", "green", "blue", "magenta", "burlywood"};
return colours[n++ % colours.size()];
}
static std::string makeEdge(std::string_view src, std::string_view dst)
{
return fmt("%1% -> %2% [color = %3%];\n",
dotQuote(src), dotQuote(dst), dotQuote(nextColour()));
return fmt("%1% -> %2% [color = %3%];\n", dotQuote(src), dotQuote(dst), dotQuote(nextColour()));
}
static std::string makeNode(std::string_view id, std::string_view label,
std::string_view colour)
static std::string makeNode(std::string_view id, std::string_view label, std::string_view colour)
{
return fmt("%1% [label = %2%, shape = box, "
return fmt(
"%1% [label = %2%, shape = box, "
"style = filled, fillcolor = %3%];\n",
dotQuote(id), dotQuote(label), dotQuote(colour));
dotQuote(id),
dotQuote(label),
dotQuote(colour));
}
void printDotGraph(ref<Store> store, StorePathSet && roots)
{
StorePathSet workList(std::move(roots));
@ -51,7 +44,8 @@ void printDotGraph(ref<Store> store, StorePathSet && roots)
while (!workList.empty()) {
auto path = std::move(workList.extract(workList.begin()).value());
if (!doneSet.insert(path).second) continue;
if (!doneSet.insert(path).second)
continue;
cout << makeNode(std::string(path.to_string()), path.name(), "#ff0000");
@ -66,5 +60,4 @@ void printDotGraph(ref<Store> store, StorePathSet && roots)
cout << "}\n";
}
}
} // namespace nix

View file

@ -4,12 +4,10 @@
#include <iostream>
using std::cout;
namespace nix {
static inline std::string_view xmlQuote(std::string_view s)
{
// Luckily, store paths shouldn't contain any character that needs to be
@ -17,20 +15,16 @@ static inline std::string_view xmlQuote(std::string_view s)
return s;
}
static std::string symbolicName(std::string_view p)
{
return std::string(p.substr(0, p.find('-') + 1));
}
static std::string makeEdge(std::string_view src, std::string_view dst)
{
return fmt(" <edge source=\"%1%\" target=\"%2%\"/>\n",
xmlQuote(src), xmlQuote(dst));
return fmt(" <edge source=\"%1%\" target=\"%2%\"/>\n", xmlQuote(src), xmlQuote(dst));
}
static std::string makeNode(const ValidPathInfo & info)
{
return fmt(
@ -45,7 +39,6 @@ static std::string makeNode(const ValidPathInfo & info)
(info.path.isDerivation() ? "derivation" : "output-path"));
}
void printGraphML(ref<Store> store, StorePathSet && roots)
{
StorePathSet workList(std::move(roots));
@ -65,7 +58,8 @@ void printGraphML(ref<Store> store, StorePathSet && roots)
auto path = std::move(workList.extract(workList.begin()).value());
ret = doneSet.insert(path);
if (ret.second == false) continue;
if (ret.second == false)
continue;
auto info = store->queryPathInfo(path);
cout << makeNode(*info);
@ -76,12 +70,10 @@ void printGraphML(ref<Store> store, StorePathSet && roots)
cout << makeEdge(path.to_string(), p.to_string());
}
}
}
cout << "</graph>\n";
cout << "</graphml>\n";
}
}
} // namespace nix

File diff suppressed because it is too large Load diff