summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorSiarhei Navatski <navatski@gmail.com>2016-07-22 21:18:56 +0300
committer无闻 <u@gogs.io>2016-07-23 02:18:56 +0800
commitcf85e9eb7b125156fc3289f6a1306e16b748929b (patch)
tree3afbdcf3038054ee1af1dde79bba5aaa8e28e591 /models
parent599716bb1b78e6be903db92fde6d9bf65d79bf3e (diff)
downloadgitea-cf85e9eb7b125156fc3289f6a1306e16b748929b.tar.gz
gitea-cf85e9eb7b125156fc3289f6a1306e16b748929b.zip
add IsSubmodule field to DiffFile and hide view file button on diff page for submodules (#3097)
Diffstat (limited to 'models')
-rw-r--r--models/git_diff.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/models/git_diff.go b/models/git_diff.go
index f893200876..33a63295f0 100644
--- a/models/git_diff.go
+++ b/models/git_diff.go
@@ -160,6 +160,7 @@ type DiffFile struct {
IsDeleted bool
IsBin bool
IsRenamed bool
+ IsSubmodule bool
Sections []*DiffSection
IsIncomplete bool
}
@@ -306,7 +307,7 @@ func ParsePatch(maxLines, maxLineCharacteres, maxFiles int, reader io.Reader) (*
}
curFileLinesCount = 0
- // Check file diff type.
+ // Check file diff type and is submodule.
for {
line, err := input.ReadString('\n')
if err != nil {
@@ -333,6 +334,9 @@ func ParsePatch(maxLines, maxLineCharacteres, maxFiles int, reader io.Reader) (*
curFile.Name = b
}
if curFile.Type > 0 {
+ if strings.HasSuffix(line, " 160000\n") {
+ curFile.IsSubmodule = true
+ }
break
}
}