Commit 41d0cc7b authored by Thomas Randolph's avatar Thomas Randolph

Skip adding the diff file ID if there's no content_sha

parent 15feba24
......@@ -48,7 +48,10 @@ export function prepareRawDiffFile({ file, allFiles, meta = false }) {
},
};
if (!meta) {
// It's possible, but not confirmed, that `content_sha` isn't available sometimes
// See: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/49506#note_464692057
// We don't want duplicate IDs if that's the case, so we just don't assign an ID
if (!meta && file.content_sha) {
additionalProperties.id = identifier(file);
}
......
......@@ -99,5 +99,18 @@ describe('diff_file utilities', () => {
expect(preppedFile).not.toHaveProp('id');
});
it('does not set the id property if the file is missing a `content_sha`', () => {
const fileMissingContentSha = { ...files[0] };
delete fileMissingContentSha.content_sha;
const preppedFile = prepareRawDiffFile({
file: fileMissingContentSha,
allFiles: files,
});
expect(preppedFile).not.toHaveProp('id');
});
});
});
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment