mirror of
				https://codeberg.org/forgejo/forgejo.git
				synced 2025-10-31 06:21:11 +00:00 
			
		
		
		
	feat: add files to compare (#6461)
Add the changed files between two commits to the response of the compare API, part of forgejo/forgejo#6460 Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/6461 Reviewed-by: Gusted <gusted@noreply.codeberg.org> Co-authored-by: Angel Nunez Mencias <git@angelnu.com> Co-committed-by: Angel Nunez Mencias <git@angelnu.com>
This commit is contained in:
		
					parent
					
						
							
								339814f3bc
							
						
					
				
			
			
				commit
				
					
						a2eb249766
					
				
			
		
					 4 changed files with 15 additions and 2 deletions
				
			
		|  | @ -77,6 +77,7 @@ func CompareDiff(ctx *context.APIContext) { | |||
| 	files := ctx.FormString("files") == "" || ctx.FormBool("files") | ||||
| 
 | ||||
| 	apiCommits := make([]*api.Commit, 0, len(ci.Commits)) | ||||
| 	apiFiles := []*api.CommitAffectedFiles{} | ||||
| 	userCache := make(map[string]*user_model.User) | ||||
| 	for i := 0; i < len(ci.Commits); i++ { | ||||
| 		apiCommit, err := convert.ToCommit(ctx, ctx.Repo.Repository, ctx.Repo.GitRepo, ci.Commits[i], userCache, | ||||
|  | @ -90,10 +91,12 @@ func CompareDiff(ctx *context.APIContext) { | |||
| 			return | ||||
| 		} | ||||
| 		apiCommits = append(apiCommits, apiCommit) | ||||
| 		apiFiles = append(apiFiles, apiCommit.Files...) | ||||
| 	} | ||||
| 
 | ||||
| 	ctx.JSON(http.StatusOK, &api.Compare{ | ||||
| 		TotalCommits: len(ci.Commits), | ||||
| 		Commits:      apiCommits, | ||||
| 		Files:        apiFiles, | ||||
| 	}) | ||||
| } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue