* Add files affected by a commit to gitea API -- similar to github * Add files affected by a commit to gitea API * Fix stupid error * Fix other stupid typo * Generate swagger tmpl * Comply with convert to git commit refacto * update swagger docs * extend test * format code * Update integrations/api_repo_git_commits_test.go * Update modules/convert/git_commit.go
Showing the changes to modules/convert/git_commit.go (1 of 4 files). Show all
Unified · Split
| @@ -131,6 +131,20 @@ func ToCommit(repo *models.Repository, commit *git.Commit, userCache map[string] · 130 unmodified lines | ||
| 131 | 131 | } |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | + // Retrieve files affected by the commit | |
| 135 | + fileStatus, err := git.GetCommitFileStatus(repo.RepoPath(), commit.ID.String()) | |
| 136 | + if err != nil { | |
| 137 | + return nil, err | |
| 138 | + } | |
| 139 | + affectedFileList := make([]*api.CommitAffectedFiles, 0, len(fileStatus.Added)+len(fileStatus.Removed)+len(fileStatus.Modified)) | |
| 140 | + for _, files := range [][]string{fileStatus.Added, fileStatus.Removed, fileStatus.Modified} { | |
| 141 | + for _, filename := range files { | |
| 142 | + affectedFileList = append(affectedFileList, &api.CommitAffectedFiles{ | |
| 143 | + Filename: filename, | |
| 144 | + }) | |
| 145 | + } | |
| 146 | + } | |
| 147 | + | |
| 134 | 148 | return &api.Commit{ |
| 135 | 149 | CommitMeta: &api.CommitMeta{ |
| 136 | 150 | URL: repo.APIURL() + "/git/commits/" + commit.ID.String(), |
| @@ -162,5 +176,6 @@ func ToCommit(repo *models.Repository, commit *git.Commit, userCache map[string] · 25 unmodified lines | ||
| 162 | 176 | Author: apiAuthor, |
| 163 | 177 | Committer: apiCommitter, |
| 164 | 178 | Parents: apiParents, |
| 179 | + Files: affectedFileList, | |
| 165 | 180 | }, nil |
| 166 | 181 | } |