Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions cabbie.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,10 @@ func enforce() error {
deck.ErrorA(failures).With(eventID(cablib.EvtErrHide)).Go()
}
}
if err := unHideUpdates(updates); err != nil {
failures = fmt.Errorf("error unhiding updates: %v", err)
deck.ErrorA(failures).With(eventID(cablib.EvtErrUnhide)).Go()
}
return failures
}

Expand Down
33 changes: 33 additions & 0 deletions hide.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ import (

"flag"
"github.com/google/cabbie/cablib"
"github.com/google/cabbie/enforcement"
"github.com/google/cabbie/search"
"github.com/google/cabbie/session"
"github.com/google/cabbie/updatecollection"
"github.com/google/deck"
"golang.org/x/exp/slices"
"github.com/google/subcommands"
)

Expand Down Expand Up @@ -129,6 +131,37 @@ func hide(kbs KBSet) error {
return nil
}

func unHideUpdates(upd enforcement.Enforcements) error {
// Find hidden updates.
uc, err := findUpdates("IsHidden=1")
if err != nil {
return err
}
defer uc.Close()
deck.InfofA("Found %d hidden updates.", len(uc.Updates)).With(eventID(cablib.EvtUnhide)).Go()
// Check if currently hidden updates are still in the list of hidden updates.
// If they are, continue. If they are not still in the list, unhide them.
for _, u := range uc.Updates {
var skip bool
if slices.Contains(upd.HiddenUpdateID, u.Identity.UpdateID) {
continue
}
for _, kb := range u.KBArticleIDs {
if slices.Contains(upd.Hidden, kb) {
skip = true
}
}
if skip {
continue
}
deck.InfofA("Unhiding update:\n%s", u.Title).With(eventID(cablib.EvtUnhide)).Go()
if err := u.UnHide(); err != nil {
deck.ErrorfA("Failed to unhide update %s:\n %s", u.Title, err).With(eventID(cablib.EvtErrUnhide)).Go()
}
}
return nil
}

func hideByUpdateID(uuids []string) error {
// Find non-hidden updates that are installed or not installed.
uc, err := findUpdates("IsHidden=0 and IsInstalled=0 or IsHidden=0 and IsInstalled=1")
Expand Down