Skip to content

Commit

Permalink
Merge pull request #1368 from aptly-dev/fix/repo-add-errmsg
Browse files Browse the repository at this point in the history
repo add: improve error message
  • Loading branch information
neolynx authored Oct 22, 2024
2 parents 0e6f9c3 + 75ca51b commit 8ddb81e
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion deb/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ func ImportPackageFiles(list *PackageList, packageFiles []string, forceReplace b

err = list.Add(p)
if err != nil {
reporter.Warning("Unable to add package to repo %s: %s", p, err)
reporter.Warning("Unable to add package: %s", err)
failedFiles = append(failedFiles, file)
continue
}
Expand Down
4 changes: 2 additions & 2 deletions deb/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func (l *PackageList) Add(p *Package) error {
existing, ok := l.packages[key]
if ok {
if !existing.Equals(p) {
return &PackageConflictError{fmt.Errorf("conflict in package %s", p)}
return &PackageConflictError{fmt.Errorf("package already exists and is different: %s", p)}
}
return nil
}
Expand Down Expand Up @@ -201,7 +201,7 @@ func (l *PackageList) Append(pl *PackageList) error {
existing, ok := l.packages[k]
if ok {
if !existing.Equals(p) {
return fmt.Errorf("conflict in package %s", p)
return fmt.Errorf("package already exists and is different: %s", p)
}
} else {
l.packages[k] = p
Expand Down
4 changes: 2 additions & 2 deletions deb/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func (s *PackageListSuite) TestAddLen(c *C) {
c.Check(s.list.Len(), Equals, 1)
c.Check(s.list.Add(s.p3), IsNil)
c.Check(s.list.Len(), Equals, 2)
c.Check(s.list.Add(s.p4), ErrorMatches, "conflict in package.*")
c.Check(s.list.Add(s.p4), ErrorMatches, "package already exists and is different: .*")
}

func (s *PackageListSuite) TestRemove(c *C) {
Expand Down Expand Up @@ -243,7 +243,7 @@ func (s *PackageListSuite) TestAppend(c *C) {
list.Add(s.p4)

err = s.list.Append(list)
c.Check(err, ErrorMatches, "conflict.*")
c.Check(err, ErrorMatches, "package already exists and is different: .*")

s.list.PrepareIndex()
c.Check(func() { s.list.Append(s.il) }, Panics, "Append not supported when indexed")
Expand Down
2 changes: 1 addition & 1 deletion deb/reflist_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func (s *PackageRefListSuite) TestNewPackageListFromRefList(c *C) {
list, err := NewPackageListFromRefList(reflist, coll, nil)
c.Assert(err, IsNil)
c.Check(list.Len(), Equals, 4)
c.Check(list.Add(s.p4), ErrorMatches, "conflict in package.*")
c.Check(list.Add(s.p4), ErrorMatches, "package already exists and is different: .*")

list, err = NewPackageListFromRefList(nil, coll, nil)
c.Assert(err, IsNil)
Expand Down
2 changes: 1 addition & 1 deletion system/t09_repo/AddRepo8Test_gold
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Loading packages...
[!] Unable to add package to repo pyspi_0.6.1-1.3_source: conflict in package pyspi_0.6.1-1.3_source
[!] Unable to add package: package already exists and is different: pyspi_0.6.1-1.3_source
[!] Some files were skipped due to errors:
/pyspi_0.6.1-1.3.conflict.dsc
ERROR: some files failed to be added

0 comments on commit 8ddb81e

Please sign in to comment.