From 3cba2eb82cd0e4db15c69e86cf54485dfef2696f Mon Sep 17 00:00:00 2001 From: Mike Gelfand Date: Sun, 13 Jul 2014 12:10:27 +0300 Subject: [PATCH] Correct new line numbers in diff viewer With each new hunk, starting new line number was the same as starting old line number. Parse diff line a bit further to get real new line number. Fix HREFs for old line number links in both bootstrap3 and default themes so that thay work. --- src/GitList/Git/Repository.php | 4 ++-- themes/bootstrap3/twig/commit.twig | 2 +- themes/default/twig/commit.twig | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/GitList/Git/Repository.php b/src/GitList/Git/Repository.php index 08787c8..4b21e91 100644 --- a/src/GitList/Git/Repository.php +++ b/src/GitList/Git/Repository.php @@ -169,9 +169,9 @@ class Repository extends BaseRepository switch ($log[0]) { case "@": // Set the line numbers - preg_match('/@@ -([0-9]+)/', $log, $matches); + preg_match('/@@ -([0-9]+),[0-9]+ \+([0-9]+)/', $log, $matches); $lineNumOld = $matches[1] - 1; - $lineNumNew = $matches[1] - 1; + $lineNumNew = $matches[2] - 1; break; case "-": $lineNumOld++; diff --git a/themes/bootstrap3/twig/commit.twig b/themes/bootstrap3/twig/commit.twig index c4386e1..15955f2 100644 --- a/themes/bootstrap3/twig/commit.twig +++ b/themes/bootstrap3/twig/commit.twig @@ -46,7 +46,7 @@ {% if line.getType != 'chunk' %} - + {% endif %} {{ line.getNumOld }} {% if line.getType != 'chunk' %} diff --git a/themes/default/twig/commit.twig b/themes/default/twig/commit.twig index 3a4ce11..ed67964 100644 --- a/themes/default/twig/commit.twig +++ b/themes/default/twig/commit.twig @@ -45,7 +45,7 @@ {% if line.getType != 'chunk' %} - + {% endif %} {{ line.getNumOld }} {% if line.getType != 'chunk' %}