Skip to content

Commit b2844ac

Browse files
committed
fix: removed triggers logic
1 parent 45210d7 commit b2844ac

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

shared.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6131,6 +6131,9 @@ func diffWorkflows(oldWorkflow Workflow, parentWorkflow Workflow, update bool) {
61316131
// Check if there is a difference in triggers, and what they are
61326132
// Check if there is a difference in branches, and what they are
61336133

6134+
// We create a new ID for each trigger.
6135+
// Older ID is stored in trigger.ReplacementForTrigger
6136+
61346137
nameChanged := false
61356138
descriptionChanged := false
61366139
tagsChanged := false
@@ -6292,9 +6295,6 @@ func diffWorkflows(oldWorkflow Workflow, parentWorkflow Workflow, update bool) {
62926295
continue
62936296
}
62946297

6295-
// cover case: when new trigger is added to a previously distributed workflow
6296-
// instead of distributing it right away, create a new ID for it.
6297-
62986298
found := false
62996299
for _, oldAction := range oldWorkflow.Triggers {
63006300
if !oldAction.ParentControlled {
@@ -6312,6 +6312,8 @@ func diffWorkflows(oldWorkflow Workflow, parentWorkflow Workflow, update bool) {
63126312
}
63136313
}
63146314

6315+
// checks if parentWorkflow removed a trigger
6316+
// that was distributed to child workflow.
63156317
for _, oldAction := range oldWorkflow.Triggers {
63166318
if !oldAction.ParentControlled {
63176319
continue
@@ -6323,7 +6325,7 @@ func diffWorkflows(oldWorkflow Workflow, parentWorkflow Workflow, update bool) {
63236325
continue
63246326
}
63256327

6326-
if oldAction.ID == newAction.ID {
6328+
if oldAction.ReplacementForTrigger == newAction.ID {
63276329
found = true
63286330
break
63296331
}
@@ -6655,11 +6657,11 @@ func diffWorkflows(oldWorkflow Workflow, parentWorkflow Workflow, update bool) {
66556657

66566658
// if a new branch is added to add a trigger,
66576659
// make sure it has the new trigger ID
6658-
for branchIndex, trigger := range childWorkflow.Triggers {
6660+
for _, trigger := range childWorkflow.Triggers {
66596661
if trigger.ReplacementForTrigger == branch.SourceID {
6660-
childWorkflow.Branches[branchIndex].SourceID = trigger.ID
6662+
branch.SourceID = trigger.ID
66616663
} else if trigger.ReplacementForTrigger == branch.DestinationID {
6662-
childWorkflow.Branches[branchIndex].DestinationID = trigger.ID
6664+
branch.DestinationID = trigger.ID
66636665
}
66646666
}
66656667

0 commit comments

Comments
 (0)