mirror of
				https://codeberg.org/forgejo/forgejo.git
				synced 2025-10-31 06:21:11 +00:00 
			
		
		
		
	Fix numbr of files, total additions, and deletions (#11614)
Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
This commit is contained in:
		
					parent
					
						
							
								b97917a6e7
							
						
					
				
			
			
				commit
				
					
						5cb201dc93
					
				
			
		
					 8 changed files with 106 additions and 15 deletions
				
			
		|  | @ -367,9 +367,9 @@ func getCommitFileLineCount(commit *git.Commit, filePath string) int { | |||
| 
 | ||||
| // Diff represents a difference between two git trees. | ||||
| type Diff struct { | ||||
| 	TotalAddition, TotalDeletion int | ||||
| 	Files                        []*DiffFile | ||||
| 	IsIncomplete                 bool | ||||
| 	NumFiles, TotalAddition, TotalDeletion int | ||||
| 	Files                                  []*DiffFile | ||||
| 	IsIncomplete                           bool | ||||
| } | ||||
| 
 | ||||
| // LoadComments loads comments into each line | ||||
|  | @ -398,11 +398,6 @@ func (diff *Diff) LoadComments(issue *models.Issue, currentUser *models.User) er | |||
| 	return nil | ||||
| } | ||||
| 
 | ||||
| // NumFiles returns number of files changes in a diff. | ||||
| func (diff *Diff) NumFiles() int { | ||||
| 	return len(diff.Files) | ||||
| } | ||||
| 
 | ||||
| const cmdDiffHead = "diff --git " | ||||
| 
 | ||||
| // ParsePatch builds a Diff object from a io.Reader and some | ||||
|  | @ -639,7 +634,7 @@ func ParsePatch(maxLines, maxLineCharacters, maxFiles int, reader io.Reader) (*D | |||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	diff.NumFiles = len(diff.Files) | ||||
| 	return diff, nil | ||||
| } | ||||
| 
 | ||||
|  | @ -716,6 +711,11 @@ func GetDiffRangeWithWhitespaceBehavior(repoPath, beforeCommitID, afterCommitID | |||
| 		return nil, fmt.Errorf("Wait: %v", err) | ||||
| 	} | ||||
| 
 | ||||
| 	diff.NumFiles, diff.TotalAddition, diff.TotalDeletion, err = git.GetDiffShortStat(repoPath, beforeCommitID+"..."+afterCommitID) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 
 | ||||
| 	return diff, nil | ||||
| } | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue