Conversation
Add update-types support to the Allowed struct, matching the existing pattern in the Condition (ignore) struct. This enables semver-level filtering (major/minor/patch) in allow blocks of dependabot.yml. Changes: - Add UpdateTypes []string field to Allowed struct in model/job.go - Add update-types entry to exampleJob YAML fixture - Add TestAllowedUpdateTypes: verifies YAML unmarshal of update-types - Add TestAllowedUpdateTypesJSON: verifies JSON round-trip serialization Relates to dependabot/dependabot-core#12668. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds update-types support to the allow block of dependabot.yml by extending the CLI job model, aligning it with the existing ignore-conditions (Condition.UpdateTypes) pattern used elsewhere in the Dependabot CLI.
Changes:
- Add
UpdateTypes []stringtomodel.Allowedwithjson/yaml:"update-types,omitempty"tags. - Extend the
exampleJobYAML fixture with anallowed-updatesentry that usesupdate-types. - Add YAML unmarshal and JSON-focused tests for
Allowed.UpdateTypes.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| internal/model/job.go | Extends the job model (Allowed) to carry update-types through to the updater payload. |
| internal/model/job_test.go | Updates fixtures and adds tests to cover YAML parsing and JSON handling for the new field. |
| func TestAllowedUpdateTypesJSON(t *testing.T) { | ||
| original := Allowed{ | ||
| DependencyName: "rails", | ||
| UpdateTypes: []string{"version-update:semver-minor", "version-update:semver-patch"}, | ||
| } | ||
|
|
||
| data, err := json.Marshal(original) | ||
| if err != nil { | ||
| t.Fatal(err) | ||
| } | ||
|
|
||
| var decoded Allowed | ||
| if err := json.Unmarshal(data, &decoded); err != nil { | ||
| t.Fatal(err) | ||
| } |
There was a problem hiding this comment.
TestAllowedUpdateTypesJSON only checks a marshal→unmarshal round-trip into the same Allowed type. That will still pass even if the JSON tag name is wrong (because marshal and unmarshal would both use the same incorrect tag). To actually validate json:"update-types,omitempty", assert on the encoded JSON (e.g., unmarshal into map[string]any / json.RawMessage and check the presence of the "update-types" key, and optionally that it is omitted when UpdateTypes is nil/empty).
Summary
Add
UpdateTypes []stringfield to theAllowedstruct, enablingupdate-typessupport in theallowblock ofdependabot.yml.This matches the existing pattern in the
Condition(ignore) struct which already hasUpdateTypes []stringat line 221.Changes
internal/model/job.go: AddUpdateTypes []stringfield toAllowedstruct withjson:"update-types,omitempty" yaml:"update-types,omitempty"tagsinternal/model/job_test.go: Addupdate-typestoexampleJobfixture, addTestAllowedUpdateTypes(YAML unmarshal) andTestAllowedUpdateTypesJSON(JSON round-trip) testsRelated PRs
update-typesinallowblock dependabot-core#12925 (updater logic)Relates to dependabot/dependabot-core#12668.