MCPcopy Create free account
hub / github.com/dotzero/git-profile / profileUnapply

Function profileUnapply

cmd/unuse.go:55–77  ·  view source on GitHub ↗
(cmd *cobra.Command, cfg storage, v vcs, profile string)

Source from the content-addressed store, hash-verified

53}
54
55func profileUnapply(cmd *cobra.Command, cfg storage, v vcs, profile string) {
56 entries, ok := cfg.Lookup(profile)
57 if !ok {
58 ui.PrintErrln(cmd, ui.ErrorStyle, "There is no profile with `%s` name", profile)
59 os.Exit(0)
60 }
61
62 for _, entry := range entries {
63 err := v.Unset(entry.Key)
64 if err != nil {
65 ui.PrintErrln(cmd, ui.ErrorStyle, "Unable to interact with git to remove current profile: %s", err)
66 os.Exit(1)
67 }
68 }
69
70 err := v.Unset(currentProfileKey)
71 if err != nil {
72 ui.PrintErrln(cmd, ui.ErrorStyle, "Unable to interact with git to remove current profile: %s", err)
73 os.Exit(1)
74 }
75
76 ui.Println(cmd, ui.SuccessStyle, "Successfully removed `%s` profile from current git repository.", profile)
77}

Callers 1

unuseCommandFunction · 0.85

Calls 4

PrintErrlnFunction · 0.92
PrintlnFunction · 0.92
LookupMethod · 0.65
UnsetMethod · 0.65

Tested by

no test coverage detected