File tree Expand file tree Collapse file tree 5 files changed +28
-13
lines changed Expand file tree Collapse file tree 5 files changed +28
-13
lines changed Original file line number Diff line number Diff line change
1
+ v0.0.6
Original file line number Diff line number Diff line change 5
5
"fmt"
6
6
"os"
7
7
"sort"
8
+ "strings"
8
9
"time"
9
10
10
11
"github.com/briandowns/spinner"
@@ -82,6 +83,14 @@ func New(params Params) *Command {
82
83
83
84
cmdutils .LoadConfigAndBranch ()
84
85
86
+ allTags := utils .GetAllGitTags ()
87
+ tagName := "v0.0.1"
88
+ if len (allTags ) > 0 {
89
+ ver := utils .GetNextReleaseTag (allTags )
90
+ tagName = "v" + strings .TrimPrefix (ver .Original (), "v" )
91
+ }
92
+ assert .Exit (os .WriteFile (".version" , []byte (tagName ), 0644 ))
93
+
85
94
generatePrompt := utils .GeneratePrompt ("en" , 50 , utils .ConventionalCommitType )
86
95
87
96
repoPath := assert .Must1 (utils .AssertGitRepo ())
Original file line number Diff line number Diff line change @@ -25,14 +25,7 @@ func New() *cli.Command {
25
25
defer recovery .Exit ()
26
26
27
27
cmdutils .LoadConfigAndBranch ()
28
-
29
- s := spinner .New (spinner .CharSets [35 ], 100 * time .Millisecond , func (s * spinner.Spinner ) {
30
- s .Prefix = "fetch git tag: "
31
- })
32
- s .Start ()
33
- utils .GitFetchAll ()
34
- s .Stop ()
35
-
28
+
36
29
var p = tea .NewProgram (initialModel ())
37
30
m := assert .Must1 (p .Run ()).(model )
38
31
selected := strings .TrimSpace (m .selected )
@@ -59,7 +52,15 @@ func New() *cli.Command {
59
52
return errors .Errorf ("tag name is not valid: %s" , tagName )
60
53
}
61
54
62
- utils .GitPushTag (tagName )
55
+ output := utils .GitPushTag (tagName )
56
+ if utils .IsRemoteTagExist (output ) {
57
+ s := spinner .New (spinner .CharSets [35 ], 100 * time .Millisecond , func (s * spinner.Spinner ) {
58
+ s .Prefix = "fetch git tag: "
59
+ })
60
+ s .Start ()
61
+ utils .GitFetchAll ()
62
+ s .Stop ()
63
+ }
63
64
64
65
return nil
65
66
},
Original file line number Diff line number Diff line change @@ -78,18 +78,18 @@ func GetDetectedMessage(files []string) string {
78
78
return fmt .Sprintf ("detected %d staged file%s" , fileCount , pluralSuffix )
79
79
}
80
80
81
- func GitPushTag (ver string ) {
81
+ func GitPushTag (ver string ) string {
82
82
if ver == "" {
83
- return
83
+ return ""
84
84
}
85
85
86
86
log .Info ().Msg ("git push tag " + ver )
87
87
assert .Must (RunShell ("git" , "tag" , ver ))
88
- assert .Must ( RunShell ("git" , "push" , "origin" , ver ))
88
+ return assert .Exit1 ( RunOutput ("git" , "push" , "origin" , ver ))
89
89
}
90
90
91
91
func GitFetchAll () {
92
- assert .Must (RunShell ("git" , "fetch" , "--tags" ))
92
+ assert .Must (RunShell ("git" , "fetch" , "--prune" , "-- tags" ))
93
93
}
94
94
95
95
func IsDirty () (r result.Result [bool ]) {
Original file line number Diff line number Diff line change @@ -168,3 +168,7 @@ func RunOutput(args ...string) (string, error) {
168
168
log .Info ().Msg ("shell: " + strings .TrimSpace (shell ))
169
169
return script .Exec (shell ).String ()
170
170
}
171
+
172
+ func IsRemoteTagExist (err string ) bool {
173
+ return strings .Contains (err , "[rejected]" ) && strings .Contains (err , "tag already exists" )
174
+ }
You can’t perform that action at this time.
0 commit comments