Преглед изворни кода

add IsSubmodule field to DiffFile and hide view file button on diff page for submodules (#3097)

tags/v0.9.99
Siarhei Navatski пре 7 година
родитељ
комит
cf85e9eb7b
2 измењених фајлова са 14 додато и 8 уклоњено
  1. 5
    1
      models/git_diff.go
  2. 9
    7
      templates/repo/diff_box.tmpl

+ 5
- 1
models/git_diff.go Прегледај датотеку

IsDeleted bool IsDeleted bool
IsBin bool IsBin bool
IsRenamed bool IsRenamed bool
IsSubmodule bool
Sections []*DiffSection Sections []*DiffSection
IsIncomplete bool IsIncomplete bool
} }
} }
curFileLinesCount = 0 curFileLinesCount = 0


// Check file diff type.
// Check file diff type and is submodule.
for { for {
line, err := input.ReadString('\n') line, err := input.ReadString('\n')
if err != nil { if err != nil {
curFile.Name = b curFile.Name = b
} }
if curFile.Type > 0 { if curFile.Type > 0 {
if strings.HasSuffix(line, " 160000\n") {
curFile.IsSubmodule = true
}
break break
} }
} }

+ 9
- 7
templates/repo/diff_box.tmpl Прегледај датотеку

{{end}} {{end}}
</div> </div>
<span class="file">{{if $file.IsRenamed}}{{$file.OldName}} &rarr; {{end}}{{$file.Name}}</span> <span class="file">{{if $file.IsRenamed}}{{$file.OldName}} &rarr; {{end}}{{$file.Name}}</span>
<div class="ui right">
{{if $file.IsDeleted}}
<a class="ui basic tiny button" rel="nofollow" href="{{EscapePound $.BeforeSourcePath}}/{{EscapePound .Name}}">{{$.i18n.Tr "repo.diff.view_file"}}</a>
{{else}}
<a class="ui basic tiny button" rel="nofollow" href="{{EscapePound $.SourcePath}}/{{EscapePound .Name}}">{{$.i18n.Tr "repo.diff.view_file"}}</a>
{{end}}
</div>
{{if not $file.IsSubmodule}}
<div class="ui right">
{{if $file.IsDeleted}}
<a class="ui basic tiny button" rel="nofollow" href="{{EscapePound $.BeforeSourcePath}}/{{EscapePound .Name}}">{{$.i18n.Tr "repo.diff.view_file"}}</a>
{{else}}
<a class="ui basic tiny button" rel="nofollow" href="{{EscapePound $.SourcePath}}/{{EscapePound .Name}}">{{$.i18n.Tr "repo.diff.view_file"}}</a>
{{end}}
</div>
{{end}}
</h4> </h4>
<div class="ui attached table segment"> <div class="ui attached table segment">
{{if not $file.IsRenamed}} {{if not $file.IsRenamed}}

Loading…
Откажи
Сачувај