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

Function profileApply

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

Source from the content-addressed store, hash-verified

64}
65
66func profileApply(cmd *cobra.Command, cfg storage, v vcs, profile string) {
67 entries, ok := cfg.Lookup(profile)
68 if !ok {
69 ui.PrintErrln(cmd, ui.ErrorStyle, "There is no profile with `%s` name", profile)
70 os.Exit(0)
71 }
72
73 err := v.Set(currentProfileKey, profile)
74 if err != nil {
75 ui.PrintErrln(cmd, ui.ErrorStyle, "Unable to interact with git to store current profile: %s", err)
76 os.Exit(1)
77 }
78
79 for _, entry := range entries {
80 err := v.Set(entry.Key, entry.Value)
81 if err != nil {
82 ui.PrintErrln(cmd, ui.ErrorStyle, "Unable to interact with git to store current profile: %s", err)
83 os.Exit(1)
84 }
85 }
86
87 ui.Println(cmd, ui.SuccessStyle, "Successfully applied `%s` profile to current git repository.", profile)
88}

Callers 1

useCommandFunction · 0.85

Calls 4

PrintErrlnFunction · 0.92
PrintlnFunction · 0.92
LookupMethod · 0.65
SetMethod · 0.65

Tested by

no test coverage detected