mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-28 16:02:01 +03:00
fix: Make tag operation use GPG helper to run signing in sub-process
This commit is contained in:
committed by
Stefan Haller
parent
f779a5878d
commit
c06d4e7b18
@ -80,6 +80,10 @@ func (self *ConfigCommands) NeedsGpgSubprocessForCommit() bool {
|
||||
return self.NeedsGpgSubprocess(CommitGpgSign)
|
||||
}
|
||||
|
||||
func (self *ConfigCommands) GetGpgTagSign() bool {
|
||||
return self.gitConfig.GetBool(string(TagGpgSign))
|
||||
}
|
||||
|
||||
func (self *ConfigCommands) GetCoreEditor() string {
|
||||
return self.gitConfig.Get("core.editor")
|
||||
}
|
||||
|
@ -1,6 +1,9 @@
|
||||
package git_commands
|
||||
|
||||
import "github.com/jesseduffield/gocui"
|
||||
import (
|
||||
"github.com/jesseduffield/gocui"
|
||||
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
|
||||
)
|
||||
|
||||
type TagCommands struct {
|
||||
*GitCommon
|
||||
@ -12,24 +15,24 @@ func NewTagCommands(gitCommon *GitCommon) *TagCommands {
|
||||
}
|
||||
}
|
||||
|
||||
func (self *TagCommands) CreateLightweight(tagName string, ref string, force bool) error {
|
||||
func (self *TagCommands) CreateLightweightObj(tagName string, ref string, force bool) oscommands.ICmdObj {
|
||||
cmdArgs := NewGitCmd("tag").
|
||||
ArgIf(force, "--force").
|
||||
Arg("--", tagName).
|
||||
ArgIf(len(ref) > 0, ref).
|
||||
ToArgv()
|
||||
|
||||
return self.cmd.New(cmdArgs).Run()
|
||||
return self.cmd.New(cmdArgs)
|
||||
}
|
||||
|
||||
func (self *TagCommands) CreateAnnotated(tagName, ref, msg string, force bool) error {
|
||||
func (self *TagCommands) CreateAnnotatedObj(tagName, ref, msg string, force bool) oscommands.ICmdObj {
|
||||
cmdArgs := NewGitCmd("tag").Arg(tagName).
|
||||
ArgIf(force, "--force").
|
||||
ArgIf(len(ref) > 0, ref).
|
||||
Arg("-m", msg).
|
||||
ToArgv()
|
||||
|
||||
return self.cmd.New(cmdArgs).Run()
|
||||
return self.cmd.New(cmdArgs)
|
||||
}
|
||||
|
||||
func (self *TagCommands) HasTag(tagName string) bool {
|
||||
|
@ -106,7 +106,7 @@ func (gui *Gui) resetHelpersAndControllers() {
|
||||
Suggestions: suggestionsHelper,
|
||||
Files: helpers.NewFilesHelper(helperCommon),
|
||||
WorkingTree: helpers.NewWorkingTreeHelper(helperCommon, refsHelper, commitsHelper, gpgHelper),
|
||||
Tags: helpers.NewTagsHelper(helperCommon, commitsHelper),
|
||||
Tags: helpers.NewTagsHelper(helperCommon, commitsHelper, gpgHelper),
|
||||
BranchesHelper: helpers.NewBranchesHelper(helperCommon, worktreeHelper),
|
||||
GPG: helpers.NewGpgHelper(helperCommon),
|
||||
MergeAndRebase: rebaseHelper,
|
||||
|
@ -1,7 +1,8 @@
|
||||
package helpers
|
||||
|
||||
import (
|
||||
"github.com/jesseduffield/gocui"
|
||||
"github.com/jesseduffield/lazygit/pkg/commands/git_commands"
|
||||
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
|
||||
"github.com/jesseduffield/lazygit/pkg/gui/context"
|
||||
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
||||
"github.com/jesseduffield/lazygit/pkg/utils"
|
||||
@ -10,35 +11,31 @@ import (
|
||||
type TagsHelper struct {
|
||||
c *HelperCommon
|
||||
commitsHelper *CommitsHelper
|
||||
gpg *GpgHelper
|
||||
}
|
||||
|
||||
func NewTagsHelper(c *HelperCommon, commitsHelper *CommitsHelper) *TagsHelper {
|
||||
func NewTagsHelper(c *HelperCommon, commitsHelper *CommitsHelper, gpg *GpgHelper) *TagsHelper {
|
||||
return &TagsHelper{
|
||||
c: c,
|
||||
commitsHelper: commitsHelper,
|
||||
gpg: gpg,
|
||||
}
|
||||
}
|
||||
|
||||
func (self *TagsHelper) OpenCreateTagPrompt(ref string, onCreate func()) error {
|
||||
doCreateTag := func(tagName string, description string, force bool) error {
|
||||
return self.c.WithWaitingStatus(self.c.Tr.CreatingTag, func(gocui.Task) error {
|
||||
if description != "" {
|
||||
var command oscommands.ICmdObj
|
||||
if description != "" || self.c.Git().Config.GetGpgTagSign() {
|
||||
self.c.LogAction(self.c.Tr.Actions.CreateAnnotatedTag)
|
||||
if err := self.c.Git().Tag.CreateAnnotated(tagName, ref, description, force); err != nil {
|
||||
return err
|
||||
}
|
||||
command = self.c.Git().Tag.CreateAnnotatedObj(tagName, ref, description, force)
|
||||
} else {
|
||||
self.c.LogAction(self.c.Tr.Actions.CreateLightweightTag)
|
||||
if err := self.c.Git().Tag.CreateLightweight(tagName, ref, force); err != nil {
|
||||
return err
|
||||
}
|
||||
command = self.c.Git().Tag.CreateLightweightObj(tagName, ref, force)
|
||||
}
|
||||
|
||||
return self.gpg.WithGpgHandling(command, git_commands.TagGpgSign, self.c.Tr.CreatingTag, func() error {
|
||||
self.commitsHelper.OnCommitSuccess()
|
||||
|
||||
return self.c.Refresh(types.RefreshOptions{
|
||||
Mode: types.ASYNC, Scope: []types.RefreshableView{types.COMMITS, types.TAGS},
|
||||
})
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user