// ModifyStatus adds packages to the context by status.

ModifyStatus adds packages to the context by status.
// ModifyStatus adds packages to the context by status .
func (ctx *Context) ModifyStatus(sg StatusGroup, mod Modify, mops ...ModifyOption) error {
	if ctx.added == nil {
		ctx.added = make(map[string]bool, 10)
	}
	list, err := ctx.Status()
	if err != nil {
		return err
	}
statusLoop:
	for _, item := range list {
		if !item.Status.MatchGroup(sg) {
			continue
		}
		if ctx.added[item.Pkg.PathOrigin()] {
			continue
		}
		if item.Status.Presence == PresenceExcluded {
			continue
		}
		if mod == Add {
			if ctx.VendorFilePackagePath(item.Pkg.Path) != nil {
				continue
			}
			for _, pkg := range ctx.Package {
				if pkg.Status.Location == LocationVendor && item.Pkg.Path == pkg.Path {
					continue statusLoop
				}
			}
		}
		err = ctx.modify(item.Pkg, mod, mops)
		if err != nil {
			if _, is := err.(ErrTreeChildren); is {
				continue
			}
			if _, is := err.(ErrTreeParents); is {
				continue
			}
			return err
		}
	}
	return nil
}
func ( ctx * Context ) ModifyStatus ( sg StatusGroup , mod Modify , mops ... ModifyOption ) error { if ctx . added == nil { ctx . added = make ( map [ string ] bool , 10 ) } list , err := ctx . Status ( ) if err != nil { return err } statusLoop : for _ , item := range list { if ! item . Status . MatchGroup ( sg ) { continue } if ctx . added [ item . Pkg . PathOrigin ( ) ] { continue } if item . Status . Presence == PresenceExcluded { continue } if mod == Add { if ctx . VendorFilePackagePath ( item . Pkg . Path ) != nil { continue } for _ , pkg := range ctx . Package { if pkg . Status . Location == LocationVendor && item . Pkg . Path == pkg . Path { continue statusLoop } } } err = ctx . modify ( item . Pkg , mod , mops ) if err != nil { if _ , is := err . ( ErrTreeChildren ) ; is { continue } if _ , is := err . ( ErrTreeParents ) ; is { continue } return err } } return nil }
ModifyStatus adds packages to the context by status.
ModifyStatus adds packages to the context by status .
// Add packages from status.
 // Do not add excluded packages
 // Do not attempt to add any existing status items that are
 // already present in vendor folder.
 // Skip these errors if from status.
