Skip to content

Commit

Permalink
Merge pull request #1138 from mumoshu/hide-unlocked-phase
Browse files Browse the repository at this point in the history
Hide unlocked phases on describe-locks
  • Loading branch information
pirlodog1125 authored Sep 10, 2024
2 parents 168a8df + 25b8893 commit 27713fc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
22 changes: 11 additions & 11 deletions slack.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,21 +319,21 @@ func (s *SlackListener) describeLocks() slack.MsgOption {
buf.WriteString(project)
buf.WriteString("\n")
for _, lock := range envs {
if !lock.Locked {
continue
}

env := lock.Name
buf.WriteString(" ")
buf.WriteString(env)
buf.WriteString(": ")
if lock.Locked {
buf.WriteString("Locked")
if len(lock.LockHistory) > 0 {
buf.WriteString(" (by ")
buf.WriteString(lock.LockHistory[len(lock.LockHistory)-1].User)
buf.WriteString(", for ")
buf.WriteString(lock.LockHistory[len(lock.LockHistory)-1].Reason)
buf.WriteString(")")
}
} else {
buf.WriteString("Unlocked")
buf.WriteString("Locked")
if len(lock.LockHistory) > 0 {
buf.WriteString(" (by ")
buf.WriteString(lock.LockHistory[len(lock.LockHistory)-1].User)
buf.WriteString(", for ")
buf.WriteString(lock.LockHistory[len(lock.LockHistory)-1].Reason)
buf.WriteString(")")
}
buf.WriteString("\n")
}
Expand Down
3 changes: 0 additions & 3 deletions slack_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,6 @@ myproject2
Text: "describe locks",
}))
require.Equal(t, `myproject1
production: Unlocked
staging: Locked (by user2, for deployment of revision b)
myproject2
staging: Locked (by user2, for deployment of revision c)
Expand All @@ -379,10 +378,8 @@ myproject2
Text: "describe locks",
}))
require.Equal(t, `myproject1
production: Unlocked
staging: Locked (by user2, for deployment of revision b)
myproject2
staging: Unlocked
`, nextMessage().Text())
}

Expand Down

0 comments on commit 27713fc

Please sign in to comment.