(args []string)
| 98 | } |
| 99 | |
| 100 | func (u *updateCmd) doUpdate(args []string) error { |
| 101 | // Initialize celer configuration. |
| 102 | if err := u.celer.Init(); err != nil { |
| 103 | return color.PrintError(err, "failed to initialize celer.") |
| 104 | } |
| 105 | |
| 106 | // Make sure git is available. |
| 107 | if err := buildtools.CheckTools(u.celer, "git"); err != nil { |
| 108 | return color.PrintError(err, "failed to check if git is available") |
| 109 | } |
| 110 | |
| 111 | // Repo update can not be done in offline mode. |
| 112 | if u.celer.Offline() { |
| 113 | return color.PrintError( |
| 114 | fmt.Errorf("celer update requires network access to fetch remote refs - disable offline mode (celer configure --offline=false) to update"), |
| 115 | "failed to execute update command", |
| 116 | ) |
| 117 | } |
| 118 | |
| 119 | // Perform update based on flags. |
| 120 | if u.confRepo { |
| 121 | if err := u.updateConfRepo(); err != nil { |
| 122 | return color.PrintError(err, "failed to update conf repository.") |
| 123 | } |
| 124 | color.PrintSuccess("successfully updated conf repository.") |
| 125 | } else if u.portsRepo { |
| 126 | if err := u.updatePortsRepo(); err != nil { |
| 127 | return color.PrintError(err, "failed to update ports repository.") |
| 128 | } |
| 129 | color.PrintSuccess("successfully updated ports repository.") |
| 130 | } else { |
| 131 | if err := u.updateProjectRepos(args); err != nil { |
| 132 | return color.PrintError(err, "failed to update port repository.") |
| 133 | } |
| 134 | if len(args) == 1 { |
| 135 | color.PrintSuccess("successfully updated %s", args[0]) |
| 136 | } else { |
| 137 | color.PrintSuccess("successfully updated %d ports", len(args)) |
| 138 | } |
| 139 | } |
| 140 | |
| 141 | return nil |
| 142 | } |
| 143 | |
| 144 | func (u *updateCmd) updateConfRepo() error { |
| 145 | repoDir := filepath.Join(dirs.WorkspaceDir, "conf") |
no test coverage detected