File: issue.go

package info (click to toggle)
golang-code.forgejo-f3-gof3 3.11.0-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 1,952 kB
  • sloc: sh: 100; makefile: 65
file content (60 lines) | stat: -rw-r--r-- 1,655 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Copyright Earl Warren <contact@earl-warren.org>
// Copyright Loïc Dachary <loic@dachary.org>
// SPDX-License-Identifier: MIT

package f3

import "time"

const (
	IssueStateOpen   = "open"
	IssueStateClosed = "closed"
)

type Issue struct {
	Common
	PosterID    *Reference    `json:"poster_id"`
	Assignees   []*Reference  `json:"assignees"`
	Labels      []*Reference  `json:"labels"`
	Title       string        `json:"title"`
	Content     string        `json:"content"`
	Attachments []*Attachment `json:"attachments"`
	Milestone   *Reference    `json:"milestone"`
	State       string        `json:"state"` // open, closed
	IsLocked    bool          `json:"is_locked"`
	Created     time.Time     `json:"created"`
	Updated     time.Time     `json:"updated"`
	Closed      *time.Time    `json:"closed"`
}

func (o *Issue) GetReferences() References {
	references := o.Common.GetReferences()
	for _, assignee := range o.Assignees {
		references = append(references, assignee)
	}
	for _, label := range o.Labels {
		references = append(references, label)
	}
	if !o.Milestone.IsNil() {
		references = append(references, o.Milestone)
	}
	return append(references, o.PosterID)
}

func (o Issue) Equal(other Issue) bool {
	return o.Common.Equal(other.Common) &&
		nilOrEqual(o.PosterID, other.PosterID) &&
		arrayEqual(o.Assignees, other.Assignees) &&
		arrayEqual(o.Labels, other.Labels) &&
		o.Title == other.Title &&
		arrayEqual(o.Attachments, other.Attachments) &&
		nilOrEqual(o.Milestone, other.Milestone) &&
		o.State == other.State &&
		o.IsLocked == other.IsLocked
}

func (o *Issue) Clone() Interface {
	clone := &Issue{}
	*clone = *o
	return clone
}