Skip to content

Commit

Permalink
chore(backport release-0.9): fix(directives): do not require `targetB…
Browse files Browse the repository at this point in the history
…ranch` for `git-push` (#2642)

Co-authored-by: Hidde Beydals <[email protected]>
  • Loading branch information
akuitybot and hiddeco authored Oct 3, 2024
1 parent 1791c00 commit 7492143
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 23 deletions.
30 changes: 12 additions & 18 deletions internal/directives/git_pusher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,23 @@ func Test_gitPusher_validate(t *testing.T) {
{
name: "just generateTargetBranch is true",
config: Config{ // Should be completely valid
"generateTargetBranch": true,
"path": "/fake/path",
"generateTargetBranch": true,
},
},
{
name: "generateTargetBranch is true and targetBranch is empty string",
config: Config{ // Should be completely valid
"generateTargetBranch": true,
"path": "/fake/path",
"generateTargetBranch": true,
"targetBranch": "",
},
},
{
name: "generateTargetBranch is true and targetBranch is specified",
// These are meant to be mutually exclusive.
config: Config{
"path": "/fake/path",
"generateTargetBranch": true,
"targetBranch": "fake-branch",
},
Expand All @@ -64,20 +65,17 @@ func Test_gitPusher_validate(t *testing.T) {
},
},
{
name: "generateTargetBranch not specified and targetBranch not specified",
config: Config{},
expectedProblems: []string{
"(root): Must validate one and only one schema",
name: "generateTargetBranch not specified and targetBranch not specified",
config: Config{ // Should be completely valid
"path": "/fake/path",
},
},
{
name: "generateTargetBranch not specified and targetBranch is empty string",
config: Config{
config: Config{ // Should be completely valid
"path": "/fake/path",
"targetBranch": "",
},
expectedProblems: []string{
"(root): Must validate one and only one schema",
},
},
{
name: "generateTargetBranch not specified and targetBranch is specified",
Expand All @@ -88,22 +86,18 @@ func Test_gitPusher_validate(t *testing.T) {
},
{
name: "just generateTargetBranch is false",
config: Config{
config: Config{ // Should be completely valid
"path": "/fake/path",
"generateTargetBranch": false,
},
expectedProblems: []string{
"(root): Must validate one and only one schema",
},
},
{
name: "generateTargetBranch is false and targetBranch is empty string",
config: Config{
config: Config{ // Should be completely valid
"path": "/fake/path",
"generateTargetBranch": false,
"targetBranch": "",
},
expectedProblems: []string{
"(root): Must validate one and only one schema",
},
},
{
name: "generateTargetBranch is false and targetBranch is specified",
Expand Down
16 changes: 11 additions & 5 deletions internal/directives/schemas/git-push-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,23 @@
},
"oneOf": [
{
"required": ["generateTargetBranch"],
"properties": {
"generateTargetBranch": { "const": true },
"targetBranch": { "enum": ["", null] }
}
"targetBranch": { "enum": ["", null] }
},
"required": ["generateTargetBranch"]
},
{
"required": ["targetBranch"],
"properties": {
"generateTargetBranch": { "enum": [null, false] },
"generateTargetBranch": { "enum": [false, null] },
"targetBranch": { "minLength": 1 }
},
"required": ["targetBranch"]
},
{
"properties": {
"generateTargetBranch": { "enum": [false, null] },
"targetBranch": { "enum": ["", null] }
}
}
]
Expand Down

0 comments on commit 7492143

Please sign in to comment.