mirror of
				https://github.com/go-gitea/gitea
				synced 2025-11-03 21:08:25 +00:00 
			
		
		
		
	Fix diff of renamed and modified file (#1967)
This commit is contained in:
		@@ -365,10 +365,12 @@ func ParsePatch(maxLines, maxLineCharacters, maxFiles int, reader io.Reader) (*D
 | 
				
			|||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			curFile = &DiffFile{
 | 
								curFile = &DiffFile{
 | 
				
			||||||
				Name:     a,
 | 
									Name:      b,
 | 
				
			||||||
				Index:    len(diff.Files) + 1,
 | 
									OldName:   a,
 | 
				
			||||||
				Type:     DiffFileChange,
 | 
									Index:     len(diff.Files) + 1,
 | 
				
			||||||
				Sections: make([]*DiffSection, 0, 10),
 | 
									Type:      DiffFileChange,
 | 
				
			||||||
 | 
									Sections:  make([]*DiffSection, 0, 10),
 | 
				
			||||||
 | 
									IsRenamed: a != b,
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			diff.Files = append(diff.Files, curFile)
 | 
								diff.Files = append(diff.Files, curFile)
 | 
				
			||||||
			if len(diff.Files) >= maxFiles {
 | 
								if len(diff.Files) >= maxFiles {
 | 
				
			||||||
@@ -401,9 +403,6 @@ func ParsePatch(maxLines, maxLineCharacters, maxFiles int, reader io.Reader) (*D
 | 
				
			|||||||
					curFile.Type = DiffFileChange
 | 
										curFile.Type = DiffFileChange
 | 
				
			||||||
				case strings.HasPrefix(line, "similarity index 100%"):
 | 
									case strings.HasPrefix(line, "similarity index 100%"):
 | 
				
			||||||
					curFile.Type = DiffFileRename
 | 
										curFile.Type = DiffFileRename
 | 
				
			||||||
					curFile.IsRenamed = true
 | 
					 | 
				
			||||||
					curFile.OldName = curFile.Name
 | 
					 | 
				
			||||||
					curFile.Name = b
 | 
					 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
				if curFile.Type > 0 {
 | 
									if curFile.Type > 0 {
 | 
				
			||||||
					if strings.HasSuffix(line, " 160000\n") {
 | 
										if strings.HasSuffix(line, " 160000\n") {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -78,7 +78,7 @@
 | 
				
			|||||||
					{{end}}
 | 
										{{end}}
 | 
				
			||||||
				</h4>
 | 
									</h4>
 | 
				
			||||||
				<div class="ui attached table segment">
 | 
									<div class="ui attached table segment">
 | 
				
			||||||
					{{if not $file.IsRenamed}}
 | 
										{{if ne $file.Type 4}}
 | 
				
			||||||
						{{$isImage := (call $.IsImageFile $file.Name)}}
 | 
											{{$isImage := (call $.IsImageFile $file.Name)}}
 | 
				
			||||||
						{{if and $isImage}}
 | 
											{{if and $isImage}}
 | 
				
			||||||
							<div class="center">
 | 
												<div class="center">
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user