Diff is returning extra line when viewing first commit of a repository
Steps
pro = Project.find_with_namespace('gitlab-org/gitlab-ce')
ci2 = pro.commit('93efff945215a4407afcaf0cba15ac601b56df0d')
d2 = ci2.diffs.first
f2 = Gitlab::Diff::File.new(d2)
Expected
f2.diff_lines.map(&:text)
should return:
=> ["+.bundle",
"+.rbx/",
"+db/*.sqlite3",
"+log/*.log",
"+tmp/",
"+.sass-cache/",
"+coverage/*",
"+*.swp",
"+public/uploads/"]
Actual
=> ["+++ a/.gitignore",
"+.bundle",
"+.rbx/",
"+db/*.sqlite3",
"+log/*.log",
"+tmp/",
"+.sass-cache/",
"+coverage/*",
"+*.swp",
"+public/uploads/"]
The curious thing that I've noted when inspecting the diff is that the output is different than when using the native git diff
command:
"--- /dev/null\n+++ a/.gitignore\n@@ -0,0 +1,9 @@\n+.bundle\n+.rbx/\n+db/*.sqlite3\n+log/*.log\n+tmp/\n+.sass-cache/\n+coverage/*\n+*.swp\n+public/uploads/\n”
It's showing a/.gitignore
instead of b/.gitignore
Here is the output from the native git diff command: