2020-09-12 20:38:55 +03:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2020, Itamar S. <itamar8910@gmail.com>
|
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-09-12 20:38:55 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "Format.h"
|
2022-12-04 18:02:33 +00:00
|
|
|
#include <AK/DeprecatedString.h>
|
2020-09-12 20:38:55 +03:00
|
|
|
#include <AK/StringBuilder.h>
|
2021-11-10 11:05:21 +01:00
|
|
|
#include <AK/Vector.h>
|
2020-09-12 20:38:55 +03:00
|
|
|
|
|
|
|
namespace Diff {
|
2022-12-18 19:52:25 +01:00
|
|
|
DeprecatedString generate_only_additions(StringView text)
|
2020-09-12 20:38:55 +03:00
|
|
|
{
|
2022-12-18 19:52:25 +01:00
|
|
|
auto lines = text.split_view('\n', SplitBehavior::KeepEmpty);
|
2020-09-12 20:38:55 +03:00
|
|
|
StringBuilder builder;
|
2021-05-07 11:58:21 +02:00
|
|
|
builder.appendff("@@ -0,0 +1,{} @@\n", lines.size());
|
2022-04-01 20:58:27 +03:00
|
|
|
for (auto const& line : lines) {
|
2021-05-07 11:58:21 +02:00
|
|
|
builder.appendff("+{}\n", line);
|
2020-09-12 20:38:55 +03:00
|
|
|
}
|
2022-12-06 01:12:49 +00:00
|
|
|
return builder.to_deprecated_string();
|
2020-09-12 20:38:55 +03:00
|
|
|
}
|
|
|
|
};
|