Skip to content

Commit

Permalink
Don't convert diff if in correct format
Browse files Browse the repository at this point in the history
  • Loading branch information
rohit-gohri committed Feb 25, 2020
1 parent 86819ad commit cb00850
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion source/platforms/gitlab/GitLabGit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,19 @@ export const gitlabChangesToDiff = (changes: GitLabMRChange[]): string => {
// Gitlab doesn't return full raw git diff, relevant issue: https://gitlab.com/gitlab-org/gitlab/issues/24913
return changes
.map(change => {
const { diff } = change
if (diff.startsWith("diff --git a/") || diff.startsWith("--- a/") || diff.startsWith("--- /dev/null")) {
return diff
}

return `\
diff --git a/${change.old_path} b/${change.new_path}
${change.new_file ? `new file mode ${change.b_mode}` : ""}\
${change.deleted_file ? `deleted file mode ${change.a_mode}` : ""}\
${change.renamed_file ? `rename from ${change.old_path}\nrename to ${change.new_path}` : ""}
--- ${change.new_file ? "/dev/null" : "a/" + change.old_path}
+++ ${change.deleted_file ? "/dev/null" : "b/" + change.new_path}
${change.diff}`
${diff}`
})
.join("\n")
}

0 comments on commit cb00850

Please sign in to comment.