MCPcopy Create free account
hub / github.com/github/gh-aw / mergeExtensions

Function mergeExtensions

pkg/cli/devcontainer.go:287–311  ·  view source on GitHub ↗

mergeExtensions adds new extensions to existing list, avoiding duplicates

(existing, toAdd []string)

Source from the content-addressed store, hash-verified

285
286// mergeExtensions adds new extensions to existing list, avoiding duplicates
287func mergeExtensions(existing, toAdd []string) []string {
288 extensionSet := make(map[string]struct {
289 })
290 result := make([]string, 0, len(existing)+len(toAdd))
291
292 // Add existing extensions
293 for _, ext := range existing {
294 if !setutil.Contains(extensionSet, ext) {
295 extensionSet[ext] = struct {
296 }{}
297 result = append(result, ext)
298 }
299 }
300
301 // Add new extensions if not already present
302 for _, ext := range toAdd {
303 if !setutil.Contains(extensionSet, ext) {
304 extensionSet[ext] = struct {
305 }{}
306 result = append(result, ext)
307 }
308 }
309
310 return result
311}
312
313// mergeFeatures adds new features to existing features map, updating old copilot-cli versions
314func mergeFeatures(existing DevcontainerFeatures, toAdd map[string]any) {

Callers 1

ensureDevcontainerConfigFunction · 0.85

Calls 1

ContainsFunction · 0.92

Tested by

no test coverage detected