Monorepo for Tangled
0

Configure Feed

Select the types of activity you want to include in your feed.

appview/pulls,appview/repo: deduplicate pipeline runs per commit

Signed-off-by: dawn <dawn@tangled.org>

dawn (Jul 7, 2026, 8:56 PM +0300) 54e2d3c2 3fc289e5

+48 -19
+1 -7
appview/pulls/list.go
··· 282 282 return m 283 283 } 284 284 285 - for _, pipeline := range out.Pipelines { 286 - if pipeline == nil { 287 - continue 288 - } 289 - m[pipeline.Commit] = types.Pipeline{CiPipeline: pipeline} 290 - } 291 - return m 285 + return types.PipelinesByCommit(out.Pipelines) 292 286 }(r.Context(), shas) 293 287 294 288 labelDefs, err := db.GetLabelDefinitions(
+1 -7
appview/pulls/single.go
··· 178 178 return m 179 179 } 180 180 181 - for _, pipeline := range out.Pipelines { 182 - if pipeline == nil { 183 - continue 184 - } 185 - m[pipeline.Commit] = types.Pipeline{CiPipeline: pipeline} 186 - } 187 - return m 181 + return types.PipelinesByCommit(out.Pipelines) 188 182 }(r.Context()) 189 183 190 184 var workflowsChanged bool
+1 -5
appview/repo/repo_util.go
··· 115 115 return nil, err 116 116 } 117 117 118 - for _, p := range out.Pipelines { 119 - m[p.Commit] = types.Pipeline{CiPipeline: p} 120 - } 121 - 122 - return m, nil 118 + return types.PipelinesByCommit(out.Pipelines), nil 123 119 }
+15
types/pipeline.go
··· 189 189 return m 190 190 } 191 191 192 + // PipelinesByCommit keeps the first run per commit from newest-first input. 193 + func PipelinesByCommit(pipelines []*tangled.CiPipeline) map[string]Pipeline { 194 + m := make(map[string]Pipeline, len(pipelines)) 195 + for _, pipeline := range pipelines { 196 + if pipeline == nil { 197 + continue 198 + } 199 + if _, ok := m[pipeline.Commit]; ok { 200 + continue 201 + } 202 + m[pipeline.Commit] = Pipeline{CiPipeline: pipeline} 203 + } 204 + return m 205 + } 206 + 192 207 func (p Pipeline) Counts() map[string]int { 193 208 m := make(map[string]int) 194 209 if p.CiPipeline != nil {
+30
types/pipeline_test.go
··· 1 + package types 2 + 3 + import ( 4 + "testing" 5 + 6 + "tangled.org/core/api/tangled" 7 + ) 8 + 9 + func TestPipelinesByCommitKeepsNewestFirstPipeline(t *testing.T) { 10 + newest := &tangled.CiPipeline{Id: "newest", Commit: "shared"} 11 + older := &tangled.CiPipeline{Id: "older", Commit: "shared"} 12 + other := &tangled.CiPipeline{Id: "other", Commit: "other"} 13 + 14 + got := PipelinesByCommit([]*tangled.CiPipeline{ 15 + newest, 16 + nil, 17 + other, 18 + older, 19 + }) 20 + 21 + if len(got) != 2 { 22 + t.Fatalf("got %d mapped commits, want 2: %#v", len(got), got) 23 + } 24 + if got["shared"].Id() != "newest" { 25 + t.Fatalf("shared commit mapped to pipeline %q, want newest", got["shared"].Id()) 26 + } 27 + if got["other"].Id() != "other" { 28 + t.Fatalf("other commit mapped to pipeline %q, want other", got["other"].Id()) 29 + } 30 + }