mirror of
				https://github.com/go-gitea/gitea
				synced 2025-11-04 05:18:25 +00:00 
			
		
		
		
	add IsSubmodule field to DiffFile and hide view file button on diff page for submodules (#3097)
This commit is contained in:
		@@ -160,6 +160,7 @@ type DiffFile struct {
 | 
				
			|||||||
	IsDeleted          bool
 | 
						IsDeleted          bool
 | 
				
			||||||
	IsBin              bool
 | 
						IsBin              bool
 | 
				
			||||||
	IsRenamed          bool
 | 
						IsRenamed          bool
 | 
				
			||||||
 | 
						IsSubmodule        bool
 | 
				
			||||||
	Sections           []*DiffSection
 | 
						Sections           []*DiffSection
 | 
				
			||||||
	IsIncomplete       bool
 | 
						IsIncomplete       bool
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -306,7 +307,7 @@ func ParsePatch(maxLines, maxLineCharacteres, maxFiles int, reader io.Reader) (*
 | 
				
			|||||||
			}
 | 
								}
 | 
				
			||||||
			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 {
 | 
				
			||||||
@@ -333,6 +334,9 @@ func ParsePatch(maxLines, maxLineCharacteres, maxFiles int, reader io.Reader) (*
 | 
				
			|||||||
					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
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -68,6 +68,7 @@
 | 
				
			|||||||
						{{end}}
 | 
											{{end}}
 | 
				
			||||||
					</div>
 | 
										</div>
 | 
				
			||||||
					<span class="file">{{if $file.IsRenamed}}{{$file.OldName}} → {{end}}{{$file.Name}}</span>
 | 
										<span class="file">{{if $file.IsRenamed}}{{$file.OldName}} → {{end}}{{$file.Name}}</span>
 | 
				
			||||||
 | 
										{{if not $file.IsSubmodule}}
 | 
				
			||||||
						<div class="ui right">
 | 
											<div class="ui right">
 | 
				
			||||||
							{{if $file.IsDeleted}}
 | 
												{{if $file.IsDeleted}}
 | 
				
			||||||
								<a class="ui basic tiny button" rel="nofollow" href="{{EscapePound $.BeforeSourcePath}}/{{EscapePound .Name}}">{{$.i18n.Tr "repo.diff.view_file"}}</a>
 | 
													<a class="ui basic tiny button" rel="nofollow" href="{{EscapePound $.BeforeSourcePath}}/{{EscapePound .Name}}">{{$.i18n.Tr "repo.diff.view_file"}}</a>
 | 
				
			||||||
@@ -75,6 +76,7 @@
 | 
				
			|||||||
								<a class="ui basic tiny button" rel="nofollow" href="{{EscapePound $.SourcePath}}/{{EscapePound .Name}}">{{$.i18n.Tr "repo.diff.view_file"}}</a>
 | 
													<a class="ui basic tiny button" rel="nofollow" href="{{EscapePound $.SourcePath}}/{{EscapePound .Name}}">{{$.i18n.Tr "repo.diff.view_file"}}</a>
 | 
				
			||||||
							{{end}}
 | 
												{{end}}
 | 
				
			||||||
						</div>
 | 
											</div>
 | 
				
			||||||
 | 
										{{end}}
 | 
				
			||||||
				</h4>
 | 
									</h4>
 | 
				
			||||||
				<div class="ui attached table segment">
 | 
									<div class="ui attached table segment">
 | 
				
			||||||
					{{if not $file.IsRenamed}}
 | 
										{{if not $file.IsRenamed}}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user