(fields []string)
| 303 | } |
| 304 | |
| 305 | func (commit Commit) ExportData(fields []string) map[string]interface{} { |
| 306 | v := reflect.ValueOf(commit) |
| 307 | data := map[string]interface{}{} |
| 308 | for _, f := range fields { |
| 309 | switch f { |
| 310 | case "author": |
| 311 | data[f] = commit.Author.ExportData() |
| 312 | case "commit": |
| 313 | info := commit.Info |
| 314 | data[f] = map[string]interface{}{ |
| 315 | "author": map[string]interface{}{ |
| 316 | "date": info.Author.Date, |
| 317 | "email": info.Author.Email, |
| 318 | "name": info.Author.Name, |
| 319 | }, |
| 320 | "committer": map[string]interface{}{ |
| 321 | "date": info.Committer.Date, |
| 322 | "email": info.Committer.Email, |
| 323 | "name": info.Committer.Name, |
| 324 | }, |
| 325 | "comment_count": info.CommentCount, |
| 326 | "message": info.Message, |
| 327 | "tree": map[string]interface{}{"sha": info.Tree.Sha}, |
| 328 | } |
| 329 | case "committer": |
| 330 | data[f] = commit.Committer.ExportData() |
| 331 | case "parents": |
| 332 | parents := make([]interface{}, 0, len(commit.Parents)) |
| 333 | for _, parent := range commit.Parents { |
| 334 | parents = append(parents, map[string]interface{}{ |
| 335 | "sha": parent.Sha, |
| 336 | "url": parent.URL, |
| 337 | }) |
| 338 | } |
| 339 | data[f] = parents |
| 340 | case "repository": |
| 341 | repo := commit.Repo |
| 342 | data[f] = map[string]interface{}{ |
| 343 | "description": repo.Description, |
| 344 | "fullName": repo.FullName, |
| 345 | "name": repo.Name, |
| 346 | "id": repo.ID, |
| 347 | "isFork": repo.IsFork, |
| 348 | "isPrivate": repo.IsPrivate, |
| 349 | "owner": repo.Owner.ExportData(), |
| 350 | "url": repo.URL, |
| 351 | } |
| 352 | default: |
| 353 | sf := fieldByName(v, f) |
| 354 | data[f] = sf.Interface() |
| 355 | } |
| 356 | } |
| 357 | return data |
| 358 | } |
| 359 | |
| 360 | func (repo Repository) ExportData(fields []string) map[string]interface{} { |
| 361 | v := reflect.ValueOf(repo) |
nothing calls this directly
no test coverage detected