(cmd *cobra.Command, cfg storage, v vcs, profile string)
| 64 | } |
| 65 | |
| 66 | func 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 | } |
no test coverage detected