Debian Codegraph @

commands/command_uninstall.go

raw symbols SCIP
1 package commands
2
3 import (
4 "github.com/git-lfs/git-lfs/v3/git"
5 "github.com/git-lfs/git-lfs/v3/tr"
6 "github.com/spf13/cobra"
7 )
8
9 // uninstallCommand removes any configuration and hooks set by Git LFS.
10 func uninstallCommand(cmd *cobra.Command, args []string) {
11 if err := cmdInstallOptions().Uninstall(); err != nil {
12 Print(tr.Tr.Get("warning: %s", err.Error()))
13 }
14
15 if !skipRepoInstall && (localInstall || worktreeInstall || cfg.InRepo()) {
16 uninstallHooksCommand(cmd, args)
17 }
18
19 if systemInstall {
20 Print(tr.Tr.Get("System Git LFS configuration has been removed."))
21 } else if !(localInstall || worktreeInstall) {
22 Print(tr.Tr.Get("Global Git LFS configuration has been removed."))
23 }
24 }
25
26 // uninstallHooksCommand removes any hooks created by Git LFS.
27 func uninstallHooksCommand(cmd *cobra.Command, args []string) {
28 if err := uninstallHooks(); err != nil {
29 Error(err.Error())
30 }
31
32 Print(tr.Tr.Get("Hooks for this repository have been removed."))
33 }
34
35 func init() {
36 RegisterCommand("uninstall", uninstallCommand, func(cmd *cobra.Command) {
37 cmd.Flags().BoolVarP(&localInstall, "local", "l", false, "Remove the Git LFS config for the local Git repository only.")
38 cmd.Flags().StringVarP(&fileInstall, "file", "", "", "Remove the Git LFS config for the given configuration file only.")
39 if git.IsGitVersionAtLeast("2.20.0") {
40 cmd.Flags().BoolVarP(&worktreeInstall, "worktree", "w", false, "Remove the Git LFS config for the current Git working tree, if multiple working trees are configured; otherwise, the same as --local.")
41 }
42 cmd.Flags().BoolVarP(&systemInstall, "system", "", false, "Remove the Git LFS config in system-wide scope.")
43 cmd.Flags().BoolVarP(&skipRepoInstall, "skip-repo", "", false, "Skip repo setup, just uninstall global filters.")
44 cmd.AddCommand(NewCommand("hooks", uninstallHooksCommand))
45 })
46 }