Only fail if the repository URLs are different

Signed-off-by: Dominik Braun <mail@dominikbraun.io>
pull/9095/head
Dominik Braun 5 years ago
parent f234d15730
commit 2ed0081b92

@ -161,11 +161,14 @@ func (o *repoAddOptions) run(out io.Writer) error {
if !o.forceUpdate && f.Has(o.name) { if !o.forceUpdate && f.Has(o.name) {
existing := f.Get(o.name) existing := f.Get(o.name)
if c != *existing { if c != *existing {
// In case of of the repo URLs ends with a trailing slash and the other
// The input coming in for the name is different from what is already // one doesn't, the config is considered to be different even though they
// configured. Return an error. // refer to the same repository.
// Only fail with an error if the configs actually are different.
if c.URLWithTrailingSlash() != existing.URLWithTrailingSlash() {
return errors.Errorf("repository name (%s) already exists, please specify a different name", o.name) return errors.Errorf("repository name (%s) already exists, please specify a different name", o.name)
} }
}
// The add is idempotent so do nothing // The add is idempotent so do nothing
fmt.Fprintf(out, "%q already exists with the same configuration, skipping\n", o.name) fmt.Fprintf(out, "%q already exists with the same configuration, skipping\n", o.name)

Loading…
Cancel
Save