@@ -21,10 +21,12 @@ import (
2121
2222 "flag"
2323 "github.com/google/cabbie/cablib"
24+ "github.com/google/cabbie/enforcement"
2425 "github.com/google/cabbie/search"
2526 "github.com/google/cabbie/session"
2627 "github.com/google/cabbie/updatecollection"
2728 "github.com/google/deck"
29+ "golang.org/x/exp/slices"
2830 "github.com/google/subcommands"
2931)
3032
@@ -129,6 +131,37 @@ func hide(kbs KBSet) error {
129131 return nil
130132}
131133
134+ func unHideUpdates (upd enforcement.Enforcements ) error {
135+ // Find hidden updates.
136+ uc , err := findUpdates ("IsHidden=1" )
137+ if err != nil {
138+ return err
139+ }
140+ defer uc .Close ()
141+ deck .InfofA ("Found %d hidden updates." , len (uc .Updates )).With (eventID (cablib .EvtUnhide )).Go ()
142+ // Check if currently hidden updates are still in the list of hidden updates.
143+ // If they are, continue. If they are not still in the list, unhide them.
144+ for _ , u := range uc .Updates {
145+ var skip bool
146+ if slices .Contains (upd .HiddenUpdateID , u .Identity .UpdateID ) {
147+ continue
148+ }
149+ for _ , kb := range u .KBArticleIDs {
150+ if slices .Contains (upd .Hidden , kb ) {
151+ skip = true
152+ }
153+ }
154+ if skip {
155+ continue
156+ }
157+ deck .InfofA ("Unhiding update:\n %s" , u .Title ).With (eventID (cablib .EvtUnhide )).Go ()
158+ if err := u .UnHide (); err != nil {
159+ deck .ErrorfA ("Failed to unhide update %s:\n %s" , u .Title , err ).With (eventID (cablib .EvtErrUnhide )).Go ()
160+ }
161+ }
162+ return nil
163+ }
164+
132165func hideByUpdateID (uuids []string ) error {
133166 // Find non-hidden updates that are installed or not installed.
134167 uc , err := findUpdates ("IsHidden=0 and IsInstalled=0 or IsHidden=0 and IsInstalled=1" )
0 commit comments