Welcome to mirror list, hosted at ThFree Co, Russian Federation.

diff_utils.js « utils « lib « components « vue_shared « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 221c4f5b8a8061cb94c375e6887dfb3ef77d5549 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
function trimFirstCharOfLineContent(text) {
  if (!text) {
    return text;
  }

  return text.replace(/^( |\+|-)/, '');
}

function cleanSuggestionLine(line = {}) {
  return {
    ...line,
    text: trimFirstCharOfLineContent(line.text),
    rich_text: trimFirstCharOfLineContent(line.rich_text),
  };
}

export function selectDiffLines(lines) {
  return lines.filter(line => line.type !== 'match').map(line => cleanSuggestionLine(line));
}