Skip to content

Add UpdateTypes field to Allowed struct#605

Open
kbukum1 wants to merge 1 commit intomainfrom
kbukum1/allow-update-types
Open

Add UpdateTypes field to Allowed struct#605
kbukum1 wants to merge 1 commit intomainfrom
kbukum1/allow-update-types

Conversation

@kbukum1
Copy link
Contributor

@kbukum1 kbukum1 commented Mar 25, 2026

Summary

Add UpdateTypes []string field to the Allowed struct, enabling update-types support in the allow block of dependabot.yml.

This matches the existing pattern in the Condition (ignore) struct which already has UpdateTypes []string at line 221.

Changes

  • internal/model/job.go: Add UpdateTypes []string field to Allowed struct with json:"update-types,omitempty" yaml:"update-types,omitempty" tags
  • internal/model/job_test.go: Add update-types to exampleJob fixture, add TestAllowedUpdateTypes (YAML unmarshal) and TestAllowedUpdateTypesJSON (JSON round-trip) tests

Related PRs

Relates to dependabot/dependabot-core#12668.

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>
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 []string to model.Allowed with json/yaml:"update-types,omitempty" tags.
  • Extend the exampleJob YAML fixture with an allowed-updates entry that uses update-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.

Comment on lines +61 to +75
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)
}
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copilot generated this review using guidance from repository custom instructions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants