Mirror of @tangled.org/core. Running on a Raspberry Pi Zero 2
at master 140 lines 3.9 kB view raw
1package types 2 3import ( 4 "encoding/json" 5 6 "github.com/bluekeyes/go-gitdiff/gitdiff" 7 "github.com/go-git/go-git/v5/plumbing/object" 8) 9 10type RepoIndexResponse struct { 11 IsEmpty bool `json:"is_empty"` 12 Ref string `json:"ref,omitempty"` 13 Readme string `json:"readme,omitempty"` 14 ReadmeFileName string `json:"readme_file_name,omitempty"` 15 Commits []Commit `json:"commits,omitempty"` 16 Description string `json:"description,omitempty"` 17 Files []NiceTree `json:"files,omitempty"` 18 Branches []Branch `json:"branches,omitempty"` 19 Tags []*TagReference `json:"tags,omitempty"` 20 TotalCommits int `json:"total_commits,omitempty"` 21} 22 23type RepoLogResponse struct { 24 Commits []Commit `json:"commits,omitempty"` 25 Ref string `json:"ref,omitempty"` 26 Description string `json:"description,omitempty"` 27 Log bool `json:"log,omitempty"` 28 Total int `json:"total,omitempty"` 29 Page int `json:"page,omitempty"` 30 PerPage int `json:"per_page,omitempty"` 31} 32 33type RepoCommitResponse struct { 34 Ref string `json:"ref,omitempty"` 35 Diff *NiceDiff `json:"diff,omitempty"` 36} 37 38type RepoFormatPatchResponse struct { 39 Rev1 string `json:"rev1,omitempty"` 40 Rev2 string `json:"rev2,omitempty"` 41 FormatPatch []FormatPatch `json:"format_patch,omitempty"` 42 FormatPatchRaw string `json:"patch,omitempty"` 43 CombinedPatch []*gitdiff.File `json:"combined_patch,omitempty"` 44 CombinedPatchRaw string `json:"combined_patch_raw,omitempty"` 45} 46 47type RepoTreeResponse struct { 48 Ref string `json:"ref,omitempty"` 49 Parent string `json:"parent,omitempty"` 50 Description string `json:"description,omitempty"` 51 DotDot string `json:"dotdot,omitempty"` 52 Files []NiceTree `json:"files,omitempty"` 53 ReadmeFileName string `json:"readme_filename,omitempty"` 54 Readme string `json:"readme_contents,omitempty"` 55} 56 57type TagReference struct { 58 Reference 59 Tag *object.Tag `json:"tag,omitempty"` 60 Message string `json:"message,omitempty"` 61} 62 63type Reference struct { 64 Name string `json:"name"` 65 Hash string `json:"hash"` 66} 67 68type Branch struct { 69 Reference `json:"reference"` 70 Commit *object.Commit `json:"commit,omitempty"` 71 IsDefault bool `json:"is_default,omitempty"` 72} 73 74func (b *Branch) UnmarshalJSON(data []byte) error { 75 aux := &struct { 76 Reference `json:"reference"` 77 Commit *object.Commit `json:"commit,omitempty"` 78 IsDefault bool `json:"is_default,omitempty"` 79 MispelledIsDefault bool `json:"is_deafult,omitempty"` // mispelled name 80 }{} 81 82 if err := json.Unmarshal(data, aux); err != nil { 83 return err 84 } 85 86 b.Reference = aux.Reference 87 b.Commit = aux.Commit 88 b.IsDefault = aux.IsDefault || aux.MispelledIsDefault // whichever was set 89 90 return nil 91} 92 93type RepoTagsResponse struct { 94 Tags []*TagReference `json:"tags,omitempty"` 95} 96 97type RepoTagResponse struct { 98 Tag *TagReference `json:"tag,omitempty"` 99} 100 101type RepoBranchesResponse struct { 102 Branches []Branch `json:"branches,omitempty"` 103} 104 105type RepoBranchResponse struct { 106 Branch Branch 107} 108 109type RepoDefaultBranchResponse struct { 110 Branch string `json:"branch,omitempty"` 111} 112 113type ForkStatus int 114 115const ( 116 UpToDate ForkStatus = 0 117 FastForwardable = 1 118 Conflict = 2 119 MissingBranch = 3 120) 121 122type ForkInfo struct { 123 IsFork bool 124 Status ForkStatus 125} 126 127type AncestorCheckResponse struct { 128 Status ForkStatus `json:"status"` 129} 130 131type RepoLanguageDetails struct { 132 Name string 133 Percentage float32 134 Color string 135} 136 137type RepoLanguageResponse struct { 138 // Language: File count 139 Languages map[string]int64 `json:"languages"` 140}