MCPcopy Create free account
hub / github.com/atripati/ark / simplifyPRList

Function simplifyPRList

pkg/tools/github.go:954–987  ·  view source on GitHub ↗
(raw string)

Source from the content-addressed store, hash-verified

952}
953
954func simplifyPRList(raw string) (string, error) {
955 var prs []map[string]interface{}
956 if err := json.Unmarshal([]byte(raw), &prs); err != nil {
957 return raw, nil
958 }
959
960 if len(prs) > maxListItems {
961 prs = prs[:maxListItems]
962 }
963
964 simple := make([]map[string]interface{}, 0, len(prs))
965 for _, p := range prs {
966 entry := map[string]interface{}{
967 "number": p["number"],
968 "title": p["title"],
969 "state": p["state"],
970 "created_at": p["created_at"],
971 "url": p["html_url"],
972 }
973 if user, ok := p["user"].(map[string]interface{}); ok {
974 entry["author"] = user["login"]
975 }
976 if base, ok := p["base"].(map[string]interface{}); ok {
977 entry["base"] = base["ref"]
978 }
979 if head, ok := p["head"].(map[string]interface{}); ok {
980 entry["head"] = head["ref"]
981 }
982 simple = append(simple, stripNulls(entry))
983 }
984
985 out, _ := json.Marshal(simple)
986 return string(out), nil
987}
988
989func simplifyUser(raw string) (string, error) {
990 var u map[string]interface{}

Callers 1

listPullsMethod · 0.85

Calls 1

stripNullsFunction · 0.85

Tested by

no test coverage detected