Skip to content

Commit 3eac203

Browse files
authored
Merge pull request #14 from Jeffrey-Zutt/feat/introduce_production_branch_for_git_repository
feat: introduce production_branch for git_repository
2 parents 5f5e1f3 + b8dae37 commit 3eac203

File tree

6 files changed

+21
-6
lines changed

6 files changed

+21
-6
lines changed

internal/config.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,9 @@ func (c *ProjectConfig) extendConfig(o *ProjectConfig) *ProjectConfig {
144144
}
145145

146146
type GitRepository struct {
147-
Type string `mapstructure:"type"`
148-
Repo string `mapstructure:"repo"`
147+
ProductionBranch string `mapstructure:"production_branch"`
148+
Type string `mapstructure:"type"`
149+
Repo string `mapstructure:"repo"`
149150
}
150151

151152
type PasswordProtection struct {

internal/plugin.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ func (p *VercelPlugin) RenderTerraformComponent(site string, component string) (
194194
{{ renderProperty "protect_production" .ProjectConfig.PasswordProtection.ProtectProduction }}
195195
}
196196
vercel_project_git_repository = {
197+
{{ renderProperty "production_branch" .ProjectConfig.GitRepository.ProductionBranch }}
197198
{{ renderProperty "type" .ProjectConfig.GitRepository.Type }}
198199
{{ renderProperty "repo" .ProjectConfig.GitRepository.Repo }}
199200
}

internal/plugin_test.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ func TestSetVercelConfig(t *testing.T) {
4242
"root_directory": "./my-project",
4343
"manual_production_deployment": true,
4444
"git_repository": map[string]any{
45-
"type": "github",
46-
"repo": "mach-composer/my-project",
45+
"production_branch": "main",
46+
"type": "github",
47+
"repo": "mach-composer/my-project",
4748
},
4849
"environment_variables": variables,
4950
"domains": domains,
@@ -81,6 +82,7 @@ func TestSetVercelConfig(t *testing.T) {
8182
assert.Contains(t, component.Variables, "root_directory = \"./my-project\"")
8283
assert.Contains(t, component.Variables, "vercel_team_id = \"test-team\"")
8384
assert.Contains(t, component.Variables, "manual_production_deployment = true")
85+
assert.Contains(t, component.Variables, "production_branch = \"main\"")
8486
assert.Contains(t, component.Variables, "type = \"github\"")
8587
assert.Contains(t, component.Variables, "repo = \"mach-composer/my-project\"")
8688
assert.Contains(t, component.Variables, "protection_bypass_for_automation = true")
@@ -298,8 +300,9 @@ func TestCompleteInheritance(t *testing.T) {
298300
siteConfig := map[string]any{
299301
"project_config": map[string]any{
300302
"git_repository": map[string]any{
301-
"type": "github",
302-
"repo": "owner/test-repo",
303+
"production_branch": "main",
304+
"type": "github",
305+
"repo": "owner/test-repo",
303306
},
304307
},
305308
}
@@ -320,5 +323,6 @@ func TestCompleteInheritance(t *testing.T) {
320323

321324
assert.Contains(t, component.Variables, "vercel_project_serverless_function_region = \"fra1\"")
322325
assert.Contains(t, component.Variables, "type = \"github\"")
326+
assert.Contains(t, component.Variables, "production_branch = \"main\"")
323327
assert.Contains(t, component.Variables, "vercel_project_manual_production_deployment = true")
324328
}

internal/schemas/component-config.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@
4747
"git_repository": {
4848
"type": "object",
4949
"properties": {
50+
"production_branch": {
51+
"type": "string"
52+
},
5053
"type": {
5154
"type": "string"
5255
},

internal/schemas/global-config.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@
4747
"git_repository": {
4848
"type": "object",
4949
"properties": {
50+
"production_branch": {
51+
"type": "string"
52+
},
5053
"type": {
5154
"type": "string"
5255
},

internal/schemas/site-config.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@
4646
"git_repository": {
4747
"type": "object",
4848
"properties": {
49+
"production_branch": {
50+
"type": "string"
51+
},
4952
"type": {
5053
"type": "string"
5154
},

0 commit comments

Comments
 (0)