Skip to content

Commit 0ad4f36

Browse files
committed
Hide Snapshot::Status from public access
1 parent 31d915c commit 0ad4f36

8 files changed

Lines changed: 22 additions & 12 deletions

File tree

api/graphql/models/lazy_bug.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ func (l *loadedBug) LastEdit() time.Time {
167167
}
168168

169169
func (l *loadedBug) Status() bug.Status {
170-
return l.Snapshot.Status
170+
return l.Snapshot.Status()
171171
}
172172

173173
func (l *loadedBug) Title() string {

bug/bug.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ func (bug *Bug) Operations() []Operation {
147147
func (bug *Bug) Compile() Snapshot {
148148
snap := Snapshot{
149149
id: bug.Id(),
150-
Status: OpenStatus,
150+
status: OpenStatus,
151151
}
152152

153153
for _, op := range bug.Operations() {

bug/op_set_status.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func (op *SetStatusOperation) Id() entity.Id {
2323
}
2424

2525
func (op *SetStatusOperation) Apply(snapshot *Snapshot) {
26-
snapshot.Status = op.Status
26+
snapshot.setStatusTo(op.Status)
2727
snapshot.addActor(op.Author_)
2828

2929
item := &SetStatusTimelineItem{

bug/snapshot.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
type Snapshot struct {
1313
id entity.Id
1414

15-
Status Status
15+
status Status
1616
title string
1717
Comments []Comment
1818
Labels []Label
@@ -35,6 +35,11 @@ func (snap *Snapshot) Id() entity.Id {
3535
return snap.id
3636
}
3737

38+
// Return the bugs status
39+
func (snap *Snapshot) Status() Status {
40+
return snap.status
41+
}
42+
3843
// Return the bugs title
3944
func (snap *Snapshot) Title() string {
4045
return snap.title
@@ -76,6 +81,11 @@ func (snap *Snapshot) SearchComment(id entity.Id) (*Comment, error) {
7681
return nil, fmt.Errorf("comment item not found")
7782
}
7883

84+
// Change current status to the new status
85+
func (snap *Snapshot) setStatusTo(newStatus Status) {
86+
snap.status = newStatus
87+
}
88+
7989
// Change current title to the new title
8090
func (snap *Snapshot) changeTitleTo(newTitle string) {
8191
snap.title = newTitle

cache/bug_excerpt.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ func NewBugExcerpt(b bug.Interface, snap *bug.Snapshot) *BugExcerpt {
7373
EditLamportTime: b.EditLamportTime(),
7474
CreateUnixTime: b.FirstOp().Time().Unix(),
7575
EditUnixTime: snap.EditTime().Unix(),
76-
Status: snap.Status,
76+
Status: snap.Status(),
7777
Labels: snap.Labels,
7878
Actors: actorsIds,
7979
Participants: participantsIds,

commands/show.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ func runShow(env *Env, opts showOptions, args []string) error {
8383
case "shortId":
8484
env.out.Printf("%s\n", snap.Id().Human())
8585
case "status":
86-
env.out.Printf("%s\n", snap.Status)
86+
env.out.Printf("%s\n", snap.Status())
8787
case "title":
8888
env.out.Printf("%s\n", snap.Title())
8989
default:
@@ -109,7 +109,7 @@ func showDefaultFormatter(env *Env, snapshot *bug.Snapshot) error {
109109
// Header
110110
env.out.Printf("%s [%s] %s\n\n",
111111
colors.Cyan(snapshot.Id().Human()),
112-
colors.Yellow(snapshot.Status),
112+
colors.Yellow(snapshot.Status()),
113113
snapshot.Title(),
114114
)
115115

@@ -216,7 +216,7 @@ func showJsonFormatter(env *Env, snapshot *bug.Snapshot) error {
216216
HumanId: snapshot.Id().Human(),
217217
CreateTime: NewJSONTime(snapshot.CreateTime, 0),
218218
EditTime: NewJSONTime(snapshot.EditTime(), 0),
219-
Status: snapshot.Status.String(),
219+
Status: snapshot.Status().String(),
220220
Labels: snapshot.Labels,
221221
Title: snapshot.Title(),
222222
Author: NewJSONIdentity(snapshot.Author),
@@ -247,7 +247,7 @@ func showOrgModeFormatter(env *Env, snapshot *bug.Snapshot) error {
247247
// Header
248248
env.out.Printf("%s [%s] %s\n",
249249
snapshot.Id().Human(),
250-
snapshot.Status,
250+
snapshot.Status(),
251251
snapshot.Title(),
252252
)
253253

commands/status.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func runStatus(env *Env, args []string) error {
3131

3232
snap := b.Snapshot()
3333

34-
env.out.Println(snap.Status)
34+
env.out.Println(snap.Status())
3535

3636
return nil
3737
}

termui/show_bug.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ func (sb *showBug) renderMain(g *gocui.Gui, mainView *gocui.View) error {
226226
bugHeader := fmt.Sprintf("[%s] %s\n\n[%s] %s opened this bug on %s%s",
227227
colors.Cyan(snap.Id().Human()),
228228
colors.Bold(snap.Title()),
229-
colors.Yellow(snap.Status),
229+
colors.Yellow(snap.Status()),
230230
colors.Magenta(snap.Author.DisplayName()),
231231
snap.CreateTime.Format(timeLayout),
232232
edited,
@@ -622,7 +622,7 @@ func (sb *showBug) setTitle(g *gocui.Gui, v *gocui.View) error {
622622
}
623623

624624
func (sb *showBug) toggleOpenClose(g *gocui.Gui, v *gocui.View) error {
625-
switch sb.bug.Snapshot().Status {
625+
switch sb.bug.Snapshot().Status() {
626626
case bug.OpenStatus:
627627
_, err := sb.bug.Close()
628628
return err

0 commit comments

Comments
 (0)