fix:after compliance applied,the relationship concerning the original one should be omitted (#4419)

---------
Signed-off-by: Yuntao Hu <victorhu493@gmail.com>
This commit is contained in:
VictorHuu
2025-12-04 15:30:16 -05:00
committed by GitHub
parent 155738aba7
commit baca32f04a
3 changed files with 109 additions and 1 deletions
+8
View File
@@ -79,6 +79,10 @@ func (i *Index) Remove(id artifact.ID) {
func (i *Index) Replace(ogID artifact.ID, replacement artifact.Identifiable) {
for _, mapped := range fromMappedByID(i.fromID, ogID) {
// the stale relationship(i.e. if there's an elder ID in either side) should be discarded
if len(fromMappedByID(i.toID, mapped.relationship.To.ID())) == 0 {
continue
}
i.Add(artifact.Relationship{
From: replacement,
To: mapped.relationship.To,
@@ -87,6 +91,10 @@ func (i *Index) Replace(ogID artifact.ID, replacement artifact.Identifiable) {
}
for _, mapped := range fromMappedByID(i.toID, ogID) {
// same as the above
if len(fromMappedByID(i.fromID, mapped.relationship.To.ID())) == 0 {
continue
}
i.Add(artifact.Relationship{
From: mapped.relationship.From,
To: replacement,