@@ -18,13 +18,14 @@ package cmd
1818
1919import (
2020 "fmt"
21- "github.com/spf13/cobra"
2221 "os"
2322 "path/filepath"
2423 "sort"
2524 "strings"
2625 "time"
2726
27+ "github.com/spf13/cobra"
28+
2829 "k8s.io/apimachinery/pkg/util/sets"
2930
3031 "github.com/dims/maintainers/pkg/utils"
@@ -54,16 +55,16 @@ var pruneCmd = &cobra.Command{
5455 Use : "prune" ,
5556 Short : "Remove stale github ids from OWNERS and OWNERS_ALIASES" ,
5657 Long : `` ,
57- Run : func (cmd * cobra.Command , args []string ) {
58+ RunE : func (cmd * cobra.Command , args []string ) error {
5859 fmt .Printf ("Running script : %s\n " , time .Now ().Format ("01-02-2006 15:04:05" ))
5960 pwd , err := os .Getwd ()
6061 if err != nil {
61- panic ( err )
62+ return err
6263 }
6364
6465 userIDs , repoAliases , files , err := getOwnersAndAliases (pwd )
6566 if err != nil {
66- panic ( err )
67+ return err
6768 }
6869 for _ , file := range files {
6970 fmt .Printf ("Processed %s\n " , file )
@@ -77,7 +78,7 @@ var pruneCmd = &cobra.Command{
7778 if ! skipDS {
7879 err , contribs := utils .GetContributionsForAYear (repositoryDS , periodDS )
7980 if err != nil {
80- panic ( err )
81+ return err
8182 }
8283 if contribs == nil || len (contribs ) == 0 {
8384 panic ("unable to find any contributions in repository : " + repositoryDS )
@@ -139,11 +140,12 @@ var pruneCmd = &cobra.Command{
139140 if ! dryRun {
140141 err = fixupOwnersFiles (files , missingIDs , lowPRComments )
141142 if err != nil {
142- panic ( err )
143+ return err
143144 }
144145 } else {
145146 fmt .Printf ("--dryrun is set to true, will skip updating OWNERS and OWNER_ALIASES" )
146147 }
148+ return nil
147149 },
148150}
149151
0 commit comments