File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3737 flagBranch = flag .Bool ("branch" , false , "print the current branch name" )
3838)
3939
40+ var exitFn func (int ) = os .Exit
41+ var testMode bool
42+
4043func mainfn () int {
4144 repoDir := os .ExpandEnv (flag .Arg (0 ))
4245 if repoDir == "" {
@@ -60,6 +63,9 @@ func mainfn() int {
6063 if vi , err = vs .GetVersion (repoDir ); err == nil {
6164 if * flagIncPatch {
6265 createTag = vi .IncPatch ()
66+ if testMode {
67+ createTag = ""
68+ }
6369 }
6470 content := vi .Version ()
6571 if * flagBranch {
@@ -100,8 +106,6 @@ func mainfn() int {
100106 return retv
101107}
102108
103- var exitFn func (int ) = os .Exit
104-
105109func main () {
106110 flag .Parse ()
107111 exitFn (mainfn ())
Original file line number Diff line number Diff line change @@ -7,6 +7,10 @@ import (
77 "testing"
88)
99
10+ func init () {
11+ testMode = true
12+ }
13+
1014func TestMainFn (t * testing.T ) {
1115 flag .Parse ()
1216 * flagGoPackage = true
@@ -28,6 +32,7 @@ func TestMainFnBranch(t *testing.T) {
2832 flag .Parse ()
2933 * flagBranch = true
3034 * flagOut = "test.out"
35+ * flagIncPatch = true
3136 mainfn ()
3237 b , err := os .ReadFile ("test.out" )
3338 if err == nil {
@@ -53,6 +58,5 @@ func TestMainError(t *testing.T) {
5358 flag .Parse ()
5459 * flagOut = "/proc/.nonexistant"
5560 * flagDebug = true
56- * flagIncPatch = true
5761 main ()
5862}
You can’t perform that action at this time.
0 commit comments