| 65 | } |
| 66 | |
| 67 | func BumpIterative(ctx context.Context, mod string, level Level, repo RepoData, i FS) error { |
| 68 | data, ok := repo[mod] |
| 69 | if !ok { |
| 70 | return fmt.Errorf("module %s not found", mod) |
| 71 | } |
| 72 | if err := BumpModule(ctx, mod, level, data, i); err != nil { |
| 73 | return err |
| 74 | } |
| 75 | queue := data.downstreams |
| 76 | |
| 77 | // reduce the repo data to only the downstream modules of 'mod' |
| 78 | for k := range repo { |
| 79 | if _, ok := queue[k]; ok { |
| 80 | continue |
| 81 | } |
| 82 | repo.RemoveModule(k) |
| 83 | } |
| 84 | |
| 85 | for len(queue) > 0 { |
| 86 | var nextMod string |
| 87 | for item := range queue { |
| 88 | if repo.GetDependencyCount(item) == 0 { |
| 89 | nextMod = item |
| 90 | break |
| 91 | } |
| 92 | } |
| 93 | if nextMod == "" { |
| 94 | return fmt.Errorf("could not determine next module") |
| 95 | } |
| 96 | data, ok := repo[nextMod] |
| 97 | if !ok { |
| 98 | return fmt.Errorf("module %s not found", mod) |
| 99 | } |
| 100 | // We always propagate as patch release. The alternative is to not propagate at all and manually |
| 101 | // re-run the release automation with the desired type of version bump on the specific sub module. |
| 102 | if err := BumpModule(ctx, nextMod, Patch, data, i); err != nil { |
| 103 | return err |
| 104 | } |
| 105 | repo.RemoveModule(nextMod) |
| 106 | delete(queue, nextMod) |
| 107 | } |
| 108 | return nil |
| 109 | } |
| 110 | |
| 111 | type FS interface { |
| 112 | GitTag(ctx context.Context, tag string) error |