(adminRepo *git.Repository)
| 105 | } |
| 106 | |
| 107 | func (c *Config) ensureConfig(adminRepo *git.Repository) error { |
| 108 | // Ensure config |
| 109 | err := c.ensureAdminConfig(adminRepo) |
| 110 | if err != nil { |
| 111 | return err |
| 112 | } |
| 113 | |
| 114 | // Load config |
| 115 | err = c.loadConfig(adminRepo) |
| 116 | if err != nil { |
| 117 | return err |
| 118 | } |
| 119 | |
| 120 | // We only commit at the very end, after everything has been loaded. This |
| 121 | // ensures we have a valid config. |
| 122 | status, err := adminRepo.Worktree.Status() |
| 123 | if err != nil { |
| 124 | return err |
| 125 | } |
| 126 | |
| 127 | if !status.IsClean() { |
| 128 | err = adminRepo.Commit("Updated config", nil) |
| 129 | if err != nil { |
| 130 | return err |
| 131 | } |
| 132 | } |
| 133 | |
| 134 | return nil |
| 135 | } |
| 136 | |
| 137 | // EnsureUser will load the current admin config and ensure the given user |
| 138 | // exists. |
no test coverage detected