Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions cmd/commit.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ func init() {
commitCmd.Flags().BoolVarP(&all, "all", "a", false, "stage all tracked modified and deleted files before committing")
commitCmd.Flags().BoolVar(&amend, "amend", false, "amend the last commit")
commitCmd.Flags().BoolVar(&noEdit, "no-edit", false, "use the existing commit message when amending")

commitCmd.MarkFlagRequired("message") //nolint:errcheck
}

var commitCmd = &cobra.Command{
Expand All @@ -35,10 +37,6 @@ var commitCmd = &cobra.Command{
}

func commitFunc(cmd *cobra.Command, args []string) error {
if !amend && message == "" {
return fmt.Errorf("commit message required: use -m \"message\" or --amend")
}

verbose := viper.GetBool("verbose")
ctx := client.WithVerbose(context.Background(), verbose)

Expand All @@ -57,9 +55,7 @@ func commitFunc(cmd *cobra.Command, args []string) error {
args = append(args, "--all")
}

if message != "" {
args = append(args, "-m", message)
}
args = append(args, "-m", message)

if amend {
args = append(args, "--amend")
Expand Down
35 changes: 34 additions & 1 deletion cmd/tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package cmd
import (
"context"
"fmt"
"os/exec"
"strings"

"github.com/gomicro/align/client"
"github.com/gosuri/uiprogress"
Expand All @@ -11,16 +13,22 @@ import (
)

var (
list bool
list bool
sign bool
noSign bool
)

func init() {
RootCmd.AddCommand(tagCmd)

tagCmd.Flags().BoolVarP(&list, "list", "l", false, "list tags in repositories with optional pattern")
tagCmd.Flags().BoolVarP(&del, "delete", "d", false, "delete tags in repositories")
tagCmd.Flags().StringVarP(&message, "message", "m", "", "message for an annotated tag")
tagCmd.Flags().BoolVarP(&sign, "sign", "s", false, "create a GPG-signed tag (requires --message)")
tagCmd.Flags().BoolVar(&noSign, "no-sign", false, "do not GPG-sign the tag, overriding tag.gpgSign config")

tagCmd.MarkFlagsMutuallyExclusive("list", "delete")
tagCmd.MarkFlagsMutuallyExclusive("sign", "no-sign")
}

var tagCmd = &cobra.Command{
Expand Down Expand Up @@ -93,6 +101,31 @@ func tagFunc(cmd *cobra.Command, args []string) error {
}

args = append([]string{"--delete"}, args[0])
} else {
if sign && message == "" {
cmd.SilenceUsage = true
return fmt.Errorf("--message is required when creating a signed tag")
}

if !noSign && message == "" {
out, _ := exec.Command("git", "config", "--get", "tag.gpgSign").Output()
if strings.TrimSpace(string(out)) == "true" {
cmd.SilenceUsage = true
return fmt.Errorf("tag.gpgSign is enabled in git config; provide --message (-m) or use --no-sign to override")
}
}

if sign {
args = append(args, "--sign")
}

if noSign {
args = append(args, "--no-sign")
}

if message != "" {
args = append(args, "--message", message)
}
}

err = clt.TagRepos(ctx, repoDirs, args...)
Expand Down
Loading