Skip to content

Commit

Permalink
enhancement: ask user if they want to delete origin tag as well
Browse files Browse the repository at this point in the history
- fixes #16
  • Loading branch information
chriswalz committed Nov 2, 2020
1 parent 3ec370a commit 684f9b2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
19 changes: 19 additions & 0 deletions cmd/rootShell.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package cmd
import (
"fmt"
"github.com/rs/zerolog/log"
"github.com/thoas/go-funk"
"os"
"strings"
"time"
Expand Down Expand Up @@ -38,6 +39,11 @@ var ShellCmd = &cobra.Command{
return
}
RunGitCommandWithArgs(parsedArgs)

// post hijack
_ = PostGitCommandHijackOccurred(parsedArgs, completerSuggestionMap, cmd.Version)
// end post hijack

return
}

Expand Down Expand Up @@ -205,6 +211,19 @@ func HijackGitCommandOccurred(args []string, suggestionMap map[string]func() []p
return false
}

func PostGitCommandHijackOccurred(args []string, suggestionMap map[string]func() []prompt.Suggest, version string) bool {
sub := args[0]
deleteFlagUsed := funk.Contains(args, "--delete") || funk.Contains(args, "d")
if sub == "tag" && deleteFlagUsed {
yes := AskConfirm("Delete origin tag as well")
if yes {
// delete origin tag
execCommand("git", "push", "--delete", "origin", tagname)
}
}
return false
}

func GetVersion() string {
return ShellCmd.Version
}
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ func main() {
return
}
bitcmd.RunGitCommandWithArgs(argsWithoutProg)
_ = bitcmd.PostGitCommandHijackOccurred(argsWithoutProg, completerSuggestionMap, version)
}
}

Expand Down

0 comments on commit 684f9b2

Please sign in to comment.