diff options
author | Luke Bennett <lukeeeebennettplus@gmail.com> | 2018-07-19 09:52:54 +0100 |
---|---|---|
committer | Luke Bennett <lukeeeebennettplus@gmail.com> | 2018-07-19 09:52:54 +0100 |
commit | fb511b66d689dd4dda0dff10759344f39e81ef8a (patch) | |
tree | 612955e40636e0623e497f8036f55b8f2de27acc /app/assets/javascripts/diffs/store/utils.js | |
parent | 820c37716b6190db6c09e1be1a836df5554db518 (diff) | |
parent | 98eccfc44c597ba14939659ca3b9150197129961 (diff) | |
download | gitlab-ce-fb511b66d689dd4dda0dff10759344f39e81ef8a.tar.gz |
Merge remote-tracking branch 'origin/master' into 45443-unable-to-save-user-profile-update-with-safari
Diffstat (limited to 'app/assets/javascripts/diffs/store/utils.js')
-rw-r--r-- | app/assets/javascripts/diffs/store/utils.js | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/app/assets/javascripts/diffs/store/utils.js b/app/assets/javascripts/diffs/store/utils.js index d9589baa76e..82082ac508a 100644 --- a/app/assets/javascripts/diffs/store/utils.js +++ b/app/assets/javascripts/diffs/store/utils.js @@ -173,3 +173,24 @@ export function trimFirstCharOfLineContent(line = {}) { return parsedLine; } + +export function getDiffRefsByLineCode(diffFiles) { + return diffFiles.reduce((acc, diffFile) => { + const { baseSha, headSha, startSha } = diffFile.diffRefs; + const { newPath, oldPath } = diffFile; + + // We can only use highlightedDiffLines to create the map of diff lines because + // highlightedDiffLines will also include every parallel diff line in it. + if (diffFile.highlightedDiffLines) { + diffFile.highlightedDiffLines.forEach(line => { + const { lineCode, oldLine, newLine } = line; + + if (lineCode) { + acc[lineCode] = { baseSha, headSha, startSha, newPath, oldPath, oldLine, newLine }; + } + }); + } + + return acc; + }, {}); +} |