()
| 181 | } |
| 182 | |
| 183 | func (co *ConvertOptions) Commit() error { |
| 184 | co.GitBranch.Value = check(co.GitBranch.Value, DefaultBranch) |
| 185 | if isDefaultBranchProtected(co) { |
| 186 | co.GitInitialCommitBranch.Value = check(co.GitInitialCommitBranch.Value, DefaultInitialCommitBranch) |
| 187 | } |
| 188 | |
| 189 | co.GitBasePath.Value = check(co.GitBasePath.Value, DefaultBasePath) |
| 190 | co.GitInitialCommitMessage.Value = check(co.GitInitialCommitMessage.Value, DefaultGitCommitMessage) |
| 191 | |
| 192 | gitPersistenceSettings, err := co.buildGitPersistenceSettings() |
| 193 | if err != nil { |
| 194 | return err |
| 195 | } |
| 196 | |
| 197 | project, err := co.GetProjectCallback(co.Project.Value) |
| 198 | if err != nil { |
| 199 | return err |
| 200 | } |
| 201 | |
| 202 | _, err = co.Client.Projects.ConvertToVcs(project, co.GitInitialCommitMessage.Value, co.GitInitialCommitBranch.Value, gitPersistenceSettings) |
| 203 | if err != nil { |
| 204 | return err |
| 205 | } |
| 206 | _, err = fmt.Fprintf(co.Out, "Successfully configured Config as Code on '%s'\n", project.GetName()) |
| 207 | if err != nil { |
| 208 | return err |
| 209 | } |
| 210 | |
| 211 | return nil |
| 212 | } |
| 213 | |
| 214 | func check(value string, defaultValue string) string { |
| 215 | if value == "" { |
nothing calls this directly
no test coverage detected