Skip to content

Commit

Permalink
Andrey hura/export statuses as arr of maps (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrey-hura authored Dec 10, 2024
1 parent f4aec26 commit f34ba6c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions statusChecks.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,21 @@ func listStatusChecks(client *github.Client, ctx *context.Context, repositoryNam
statuses, _, err := client.Repositories.ListStatuses(*ctx, repositoryOwner, repositoryName, sha, nil)
failOnErr(err)
allStatuses := ""
allStatusesMap := map[string]string{}
var allStatusesArray []map[string]string
for i, status := range statuses {
prefix := ""
if i > 0 {
prefix = ", "
}
if !strings.Contains(allStatuses, *status.Context) {
allStatuses += prefix + *status.Context + " " + *status.State
allStatusesMap[*status.Context] = *status.State
allStatusesArray = append(allStatusesArray, map[string]string{
"context": *status.Context,
"status": *status.State,
})
}
}
statusesJson, err := json.Marshal(allStatusesMap)
statusesJson, err := json.Marshal(allStatusesArray)
fields := map[string]string{
"STATUSES": allStatuses,
"STATUSES_JSON": string(statusesJson),
Expand Down

0 comments on commit f34ba6c

Please sign in to comment.