package main
import (
)
type stateDiff struct {
Added []packages.Module
Removed []packages.Module
Updated []moduleDiff
}
type moduleDiff struct {
Path string
Old packages.Module
New packages.Module
OldBroken []*packages.Package
NewBroken []*packages.Package
Added []*packages.Package
Removed []*packages.Package
Changed []packageDiff
}
func ( *moduleDiff) () bool {
return len(.Changed) == 0 &&
len(.Removed) == 0 &&
len(.Added) == 0 &&
len(.NewBroken) == 0 &&
len(.OldBroken) == 0
}
type packageDiff struct {
Path string
Old *packages.Package
New *packages.Package
Diff apidiff.Report
}
func ( *packageDiff) () []apidiff.Change {
return .changes(true)
}
func ( *packageDiff) () []apidiff.Change {
return .changes(false)
}
func ( *packageDiff) ( bool) []apidiff.Change {
var []apidiff.Change
for , := range .Diff.Changes {
if .Compatible != {
continue
}
= append(, )
}
return
}
func (, *state) stateDiff {
:= modulesNotInSet(.Modules, .ModuleByPath)
:= modulesNotInSet(.Modules, .ModuleByPath)
:= intersectModuleSets(.ModuleByPath, .ModuleByPath)
var []moduleDiff
for , := range {
:= .ModuleByPath[]
:= .ModuleByPath[]
if .Version == .Version {
continue
}
:= .ByModule[]
:= .ByModule[]
, := splitBrokenPackages()
, := splitBrokenPackages()
:= packagesByImportPath()
:= packagesByImportPath()
:= packagesNotInSet(, )
:= packagesNotInSet(, )
:= intersectPackageSets(, )
var []packageDiff
for , := range {
:= []
:= []
:= apidiff.Changes(.Types, .Types)
if len(.Changes) == 0 {
continue
}
= append(, packageDiff{
Path: ,
Old: ,
New: ,
Diff: ,
})
}
= append(, moduleDiff{
Path: ,
Old: ,
New: ,
OldBroken: ,
NewBroken: ,
Added: ,
Removed: ,
Changed: ,
})
}
return stateDiff{
Added: ,
Removed: ,
Updated: ,
}
}