File tree Expand file tree Collapse file tree 1 file changed +26
-9
lines changed Expand file tree Collapse file tree 1 file changed +26
-9
lines changed Original file line number Diff line number Diff line change @@ -63,18 +63,19 @@ func main() {
6363 os .Exit (1 )
6464 }
6565 }
66-
66+ typeValues := []string {"enhancement" ,
67+ "feature" ,
68+ "bug" ,
69+ "note" ,
70+ "new-resource" ,
71+ "new-datasource" ,
72+ "deprecation" ,
73+ "breaking-change" ,
74+ }
6775 if Type == "" {
6876 prompt := promptui.Select {
6977 Label : "Select a change type" ,
70- Items : []string {"enhancement" ,
71- "bug" ,
72- "note" ,
73- "new-resource" ,
74- "new-datasource" ,
75- "deprecation" ,
76- "breaking-change" ,
77- "none" },
78+ Items : typeValues ,
7879 }
7980
8081 _ , Type , err = prompt .Run ()
@@ -85,6 +86,13 @@ func main() {
8586 flag .Usage ()
8687 os .Exit (1 )
8788 }
89+ } else {
90+ if ! TypeValid (typeValues , Type ) {
91+ fmt .Fprintln (os .Stderr , "Must specify a valid type" )
92+ fmt .Fprintln (os .Stderr , "" )
93+ flag .Usage ()
94+ os .Exit (1 )
95+ }
8896 }
8997
9098 if Description == "" {
@@ -131,6 +139,15 @@ func main() {
131139 }
132140}
133141
142+ func TypeValid (elements []string , Type string ) bool {
143+ for _ , a := range elements {
144+ if a == Type {
145+ return true
146+ }
147+ }
148+ return false
149+ }
150+
134151func OpenGit (path string ) (* git.Repository , error ) {
135152 r , err := git .PlainOpen (path )
136153 if err != nil {
You can’t perform that action at this time.
0 commit comments