🚧 发布项目:获取 Git 版本号
This commit is contained in:
parent
5e9fb77aef
commit
05ed527a3e
|
@ -0,0 +1,21 @@
|
|||
package api
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os/exec"
|
||||
)
|
||||
|
||||
// GitVersion 获取 Git 版本号
|
||||
func GitVersion() (string, error) {
|
||||
cmd := exec.Command("git1", "--version")
|
||||
output, err := cmd.Output()
|
||||
if err != nil {
|
||||
log.Fatal("无法获取 Git 版本号")
|
||||
return "", err
|
||||
}
|
||||
|
||||
version := string(output)
|
||||
fmt.Println("Git 版本:", version)
|
||||
return version, nil
|
||||
}
|
|
@ -11,6 +11,11 @@ func PreReleaseCommand() *cli.Command {
|
|||
Name: "pre-release",
|
||||
Usage: "预发布",
|
||||
Flags: flag.CommonFlag(),
|
||||
Before: func(context *cli.Context) error {
|
||||
_, err := api.GitVersion()
|
||||
|
||||
return err
|
||||
},
|
||||
Subcommands: []*cli.Command{
|
||||
{
|
||||
Name: "gitee",
|
||||
|
|
|
@ -11,6 +11,11 @@ func ReleaseCommand() *cli.Command {
|
|||
Name: "release",
|
||||
Usage: "发布",
|
||||
Flags: flag.CommonFlag(),
|
||||
Before: func(context *cli.Context) error {
|
||||
_, err := api.GitVersion()
|
||||
|
||||
return err
|
||||
},
|
||||
Subcommands: []*cli.Command{
|
||||
{
|
||||
Name: "gitee",
|
||||
|
|
Loading…
Reference in New Issue