aboutsummaryrefslogtreecommitdiffstats
path: root/models/git_diff.go
diff options
context:
space:
mode:
authorLauris BH <lauris@nix.lv>2018-09-17 17:59:49 +0300
committerGitHub <noreply@github.com>2018-09-17 17:59:49 +0300
commit4befec242aa3563f5a8a38bd390d834e4aa2797b (patch)
treef372612f3911ceb304bc6868b051a4c972025013 /models/git_diff.go
parent756eafaaf68b3cadb3f33f37554a6aa2d83921ef (diff)
downloadgitea-4befec242aa3563f5a8a38bd390d834e4aa2797b.tar.gz
gitea-4befec242aa3563f5a8a38bd390d834e4aa2797b.zip
Code review UI improvements and bugfixes (#4682)
* Code review UI improvements * More fixes to dark theme * Style fix * Fix to allow add code review comments only on review files tab * More readability dark style fixes * Fix commenting on deleted files. Fixes #4752 * Fix line blame getting for multiple corner cases
Diffstat (limited to 'models/git_diff.go')
-rw-r--r--models/git_diff.go8
1 files changed, 6 insertions, 2 deletions
diff --git a/models/git_diff.go b/models/git_diff.go
index d288ea50b1..44e7291c1f 100644
--- a/models/git_diff.go
+++ b/models/git_diff.go
@@ -273,7 +273,7 @@ func (diff *Diff) NumFiles() int {
}
// Example: @@ -1,8 +1,9 @@ => [..., 1, 8, 1, 9]
-var hunkRegex = regexp.MustCompile(`^@@ -([0-9]+),([0-9]+) \+([0-9]+),([0-9]+) @@`)
+var hunkRegex = regexp.MustCompile(`^@@ -([0-9]+),([0-9]+) \+([0-9]+)(,([0-9]+))? @@`)
func isHeader(lof string) bool {
return strings.HasPrefix(lof, cmdDiffHead) || strings.HasPrefix(lof, "---") || strings.HasPrefix(lof, "+++")
@@ -319,7 +319,11 @@ func CutDiffAroundLine(originalDiff io.Reader, line int64, old bool, numbersOfLi
otherLine = com.StrTo(groups[3]).MustInt64()
} else {
begin = com.StrTo(groups[3]).MustInt64()
- end = com.StrTo(groups[4]).MustInt64()
+ if groups[5] != "" {
+ end = com.StrTo(groups[5]).MustInt64()
+ } else {
+ end = 0
+ }
// init otherLine with begin of opposite side
otherLine = com.StrTo(groups[1]).MustInt64()
}