2020-09-12 20:38:55 +03:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2020, Itamar S. <itamar8910@gmail.com>
|
|
|
|
*
|
2021-04-22 11:24:48 +03:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-09-12 20:38:55 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "Format.h"
|
|
|
|
#include <AK/String.h>
|
|
|
|
#include <AK/StringBuilder.h>
|
|
|
|
#include <AK/Vector.h>
|
|
|
|
|
|
|
|
namespace Diff {
|
|
|
|
String generate_only_additions(const String& text)
|
|
|
|
{
|
|
|
|
auto lines = text.split('\n', true); // Keep empty
|
|
|
|
StringBuilder builder;
|
2021-01-11 16:38:09 +03:00
|
|
|
builder.appendf("@@ -0,0 +1,%zu @@\n", lines.size());
|
2020-09-12 20:38:55 +03:00
|
|
|
for (const auto& line : lines) {
|
|
|
|
builder.appendf("+%s\n", line.characters());
|
|
|
|
}
|
|
|
|
return builder.to_string();
|
|
|
|
}
|
|
|
|
};
|