|
| 1 | +// Copyright 2020 The Gitea Authors. All rights reserved. |
| 2 | +// Use of this source code is governed by a MIT-style |
| 3 | +// license that can be found in the LICENSE file. |
| 4 | + |
| 5 | +package structs |
| 6 | + |
| 7 | +// DiffLineSectionInfo represents diff line section meta data |
| 8 | +type DiffLineSectionInfo struct { |
| 9 | + Path string `json:"path"` |
| 10 | + LastLeftIdx int `json:"last_left_idx"` |
| 11 | + LastRightIdx int `json:"last_right_idx"` |
| 12 | + LeftIdx int `json:"left_idx"` |
| 13 | + RightIdx int `json:"right_idx"` |
| 14 | + LeftHunkSize int `json:"left_hunk_size"` |
| 15 | + RightHunkSize int `json:"right_hunk_size"` |
| 16 | +} |
| 17 | + |
| 18 | +// DiffLine represents a line difference in a DiffSection. |
| 19 | +type DiffLine struct { |
| 20 | + LeftIdx int `json:"left_idx"` |
| 21 | + RightIdx int `json:"right_idx"` |
| 22 | + Type int `json:"type"` |
| 23 | + Content string `json:"content"` |
| 24 | + Comments []*Comment `json:"comments"` |
| 25 | + SectionInfo *DiffLineSectionInfo `json:"section_info"` |
| 26 | +} |
| 27 | + |
| 28 | +// DiffSection represents a section of a DiffFile. |
| 29 | +type DiffSection struct { |
| 30 | + Name string `json:"name"` |
| 31 | + Lines []*DiffLine `json:"lines"` |
| 32 | +} |
| 33 | + |
| 34 | +// DiffFile represents a file diff. |
| 35 | +type DiffFile struct { |
| 36 | + Name string `json:"name"` |
| 37 | + OldName string `json:"old_name"` |
| 38 | + Index int `json:"index"` |
| 39 | + Addition int `json:"addition"` |
| 40 | + Deletion int `json:"deletion"` |
| 41 | + Type int `json:"type"` |
| 42 | + IsCreated bool `json:"is_created"` |
| 43 | + IsDeleted bool `json:"is_deleted"` |
| 44 | + IsBin bool `json:"is_bin"` |
| 45 | + IsLFSFile bool `json:"is_lfs_file"` |
| 46 | + IsRenamed bool `json:"is_renamed"` |
| 47 | + IsSubmodule bool `json:"is_submoudule"` |
| 48 | + Sections []*DiffSection `json:"sections"` |
| 49 | + IsIncomplete bool `json:"is_incomplete"` |
| 50 | +} |
| 51 | + |
| 52 | +// Diff represents a difference between two git trees. |
| 53 | +type Diff struct { |
| 54 | + TotalAddition int `json:"total_addition"` |
| 55 | + TotalDeletion int `json:"total_deletion"` |
| 56 | + Files []*DiffFile `json:"files"` |
| 57 | + IsIncomplete bool `json:"is_incomplete"` |
| 58 | +} |
| 59 | + |
| 60 | +// Compare information. |
| 61 | +type Compare struct { |
| 62 | + Title string `json:"title"` |
| 63 | + Commits []*Commit `json:"commits"` |
| 64 | + CommitCount int `json:"commit_count"` |
| 65 | + Diff *Diff `json:"diff"` |
| 66 | + BaseCommitID string `json:"base_commit_id"` |
| 67 | + HeadCommitID string `json:"head_commit_id"` |
| 68 | +} |
0 commit comments