mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-11-03 07:20:07 -05:00 
			
		
		
		
	Backport #35046 by lunny * Fix missing the first char when parsing diff hunk header * Fix #35040 * Fix #35049 --------- Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
		@@ -179,7 +179,7 @@ func (d *DiffLine) GetExpandDirection() DiffLineExpandDirection {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func getDiffLineSectionInfo(treePath, line string, lastLeftIdx, lastRightIdx int) *DiffLineSectionInfo {
 | 
			
		||||
	leftLine, leftHunk, rightLine, righHunk := git.ParseDiffHunkString(line)
 | 
			
		||||
	leftLine, leftHunk, rightLine, rightHunk := git.ParseDiffHunkString(line)
 | 
			
		||||
 | 
			
		||||
	return &DiffLineSectionInfo{
 | 
			
		||||
		Path:          treePath,
 | 
			
		||||
@@ -188,7 +188,7 @@ func getDiffLineSectionInfo(treePath, line string, lastLeftIdx, lastRightIdx int
 | 
			
		||||
		LeftIdx:       leftLine,
 | 
			
		||||
		RightIdx:      rightLine,
 | 
			
		||||
		LeftHunkSize:  leftHunk,
 | 
			
		||||
		RightHunkSize: righHunk,
 | 
			
		||||
		RightHunkSize: rightHunk,
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -335,7 +335,7 @@ func (diffSection *DiffSection) GetComputedInlineDiffFor(diffLine *DiffLine, loc
 | 
			
		||||
	// try to find equivalent diff line. ignore, otherwise
 | 
			
		||||
	switch diffLine.Type {
 | 
			
		||||
	case DiffLineSection:
 | 
			
		||||
		return getLineContent(diffLine.Content[1:], locale)
 | 
			
		||||
		return getLineContent(diffLine.Content, locale)
 | 
			
		||||
	case DiffLineAdd:
 | 
			
		||||
		compareDiffLine := diffSection.GetLine(diffLine.Match)
 | 
			
		||||
		return diffSection.getDiffLineForRender(DiffLineAdd, compareDiffLine, diffLine, locale)
 | 
			
		||||
@@ -904,6 +904,7 @@ func parseHunks(ctx context.Context, curFile *DiffFile, maxLines, maxLineCharact
 | 
			
		||||
			lastLeftIdx = -1
 | 
			
		||||
			curFile.Sections = append(curFile.Sections, curSection)
 | 
			
		||||
 | 
			
		||||
			// FIXME: the "-1" can't be right, these "line idx" are all 1-based, maybe there are other bugs that covers this bug.
 | 
			
		||||
			lineSectionInfo := getDiffLineSectionInfo(curFile.Name, line, leftLine-1, rightLine-1)
 | 
			
		||||
			diffLine := &DiffLine{
 | 
			
		||||
				Type:        DiffLineSection,
 | 
			
		||||
 
 | 
			
		||||
@@ -322,7 +322,10 @@ func (g *GithubDownloaderV3) convertGithubRelease(ctx context.Context, rel *gith
 | 
			
		||||
	httpClient := NewMigrationHTTPClient()
 | 
			
		||||
 | 
			
		||||
	for _, asset := range rel.Assets {
 | 
			
		||||
		assetID := *asset.ID // Don't optimize this, for closure we need a local variable
 | 
			
		||||
		assetID := asset.GetID() // Don't optimize this, for closure we need a local variable TODO: no need to do so in new Golang
 | 
			
		||||
		if assetID == 0 {
 | 
			
		||||
			continue
 | 
			
		||||
		}
 | 
			
		||||
		r.Assets = append(r.Assets, &base.ReleaseAsset{
 | 
			
		||||
			ID:            asset.GetID(),
 | 
			
		||||
			Name:          asset.GetName(),
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user