@@ -16,6 +16,9 @@ import (
1616 "github.com/spf13/pflag"
1717)
1818
19+ var ReleaseVersion string
20+ var BuildVersion string
21+
1922type NegatedBoolValue struct {
2023 value * bool
2124}
@@ -59,6 +62,7 @@ func mainImplementation() error {
5962 var jsonOutput bool
6063 var threshold sizes.Threshold = 1
6164 var progress bool
65+ var version bool
6266
6367 pflag .BoolVar (& processBranches , "branches" , false , "process all branches" )
6468 pflag .BoolVar (& processTags , "tags" , false , "process all tags" )
@@ -97,6 +101,7 @@ func mainImplementation() error {
97101 atty = false
98102 }
99103 pflag .BoolVar (& progress , "progress" , atty , "report progress to stderr" )
104+ pflag .BoolVar (& version , "version" , false , "report the git-sizer version number" )
100105 pflag .Var (& NegatedBoolValue {& progress }, "no-progress" , "suppress progress output" )
101106 pflag .Lookup ("no-progress" ).NoOptDefVal = "true"
102107
@@ -116,6 +121,15 @@ func mainImplementation() error {
116121 defer pprof .StopCPUProfile ()
117122 }
118123
124+ if version {
125+ if ReleaseVersion != "" {
126+ fmt .Printf ("git-sizer release %s\n " , ReleaseVersion )
127+ } else {
128+ fmt .Printf ("git-sizer build %s\n " , BuildVersion )
129+ }
130+ return nil
131+ }
132+
119133 args := pflag .Args ()
120134
121135 if len (args ) != 0 {
0 commit comments