Skip to content

Commit 8bc98fa

Browse files
committed
feat! add support for configuring default squash and merge commit title and messages
1 parent f94103f commit 8bc98fa

File tree

8 files changed

+147
-31
lines changed

8 files changed

+147
-31
lines changed

Diff for: CHANGELOG.md

+11
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Changed
11+
12+
- BREAKING: update to provider `~> 4.31` for supporting default squash and merge commit titles and messages
13+
14+
### Added
15+
- Add support for `squash_merge_commit_title`
16+
- Add support for `squash_merge_commit_message`
17+
- Add support for `merge_commit_title`
18+
- Add support for `merge_commit_message`
19+
20+
1021
## [0.17.0]
1122

1223
### Added

Diff for: README.md

+23-3
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@
33
[![Build Status](https://github.com/mineiros-io/terraform-github-repository/workflows/CI/CD%20Pipeline/badge.svg)](https://github.com/mineiros-io/terraform-github-repository/actions)
44
[![GitHub tag (latest SemVer)](https://img.shields.io/github/v/tag/mineiros-io/terraform-github-repository.svg?label=latest&sort=semver)](https://github.com/mineiros-io/terraform-github-repository/releases)
55
[![Terraform Version](https://img.shields.io/badge/terraform-1.x-623CE4.svg?logo=terraform)](https://github.com/hashicorp/terraform/releases)
6-
[![Github Provider Version](https://img.shields.io/badge/GH-4.10+-F8991D.svg?logo=terraform)](https://github.com/terraform-providers/terraform-provider-github/releases)
6+
[![Github Provider Version](https://img.shields.io/badge/GH-4.31+-F8991D.svg?logo=terraform)](https://github.com/terraform-providers/terraform-provider-github/releases)
77
[![Join Slack](https://img.shields.io/badge/[email protected]?logo=slack)](https://join.slack.com/t/mineiros-community/shared_invite/zt-ehidestg-aLGoIENLVs6tvwJ11w9WGg)
88

99
# terraform-github-repository
1010

1111
A [Terraform] module for creating a public or private repository on [Github].
1212

13-
**_This module supports Terraform v1.x and is compatible with the Official Terraform GitHub Provider v4.20 and above from `integrations/github`._**
13+
**_This module supports Terraform v1.x and is compatible with the Official Terraform GitHub Provider v4.31 and above from `integrations/github`._**
1414

1515
**Attention: This module is incompatible with the Hashicorp GitHub Provider! The latest version of this module supporting `hashicorp/github` provider is `~> 0.10.0`**
1616

17-
** Note: Versions 5.3.0, 5.4.0, and 5.5.0 of the Terraform Github Provider have broken branch protections support and should not be used.**
17+
** Note: Versions 5.3.0, 5.4.0, 5.5.0, and 5.6.0 of the Terraform Github Provider have broken branch protections support and should not be used.**
1818

1919

2020
- [GitHub as Code](#github-as-code)
@@ -151,6 +151,10 @@ See [variables.tf] and [examples/] for details and use-cases.
151151
`allow_rebase_merge`,
152152
`allow_squash_merge`,
153153
`allow_auto_merge`,
154+
`squash_merge_commit_title`,
155+
`squash_merge_commit_message`,
156+
`merge_commit_title`,
157+
`merge_commit_message`,
154158
`has_downloads`,
155159
`auto_init`,
156160
`gitignore_template`,
@@ -216,6 +220,22 @@ See [variables.tf] and [examples/] for details and use-cases.
216220

217221
Default is `false`.
218222

223+
- [**`squash_merge_commit_title`**](#var-squash_merge_commit_title): *(Optional `string`)*<a name="var-squash_merge_commit_title"></a>
224+
225+
Set to `PR_TITLE` or `COMMIT_OR_PR_TITLE` for a default squash merge commit title.
226+
227+
- [**`squash_merge_commit_message`**](#var-squash_merge_commit_message): *(Optional `string`)*<a name="var-squash_merge_commit_message"></a>
228+
229+
Set to `PR_BODY`, `COMMIT_MESSAGES`, or `BLANK` for a default squash merge commit message.
230+
231+
- [**`merge_commit_title`**](#var-merge_commit_title): *(Optional `string`)*<a name="var-merge_commit_title"></a>
232+
233+
Set to `PR_TITLE` or `MERGE_MESSAGE` for a default merge commit title.
234+
235+
- [**`merge_commit_message`**](#var-merge_commit_message): *(Optional `string`)*<a name="var-merge_commit_message"></a>
236+
237+
Set to `PR_BODY`, `PR_TITLE`, or `BLANK` for a default merge commit message.
238+
219239
- [**`description`**](#var-description): *(Optional `string`)*<a name="var-description"></a>
220240

221241
A description of the repository.

Diff for: README.tfdoc.hcl

+35-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ header {
2121
}
2222

2323
badge "tf-gh" {
24-
image = "https://img.shields.io/badge/GH-4.10+-F8991D.svg?logo=terraform"
24+
image = "https://img.shields.io/badge/GH-4.31+-F8991D.svg?logo=terraform"
2525
url = "https://github.com/terraform-providers/terraform-provider-github/releases"
2626
text = "Github Provider Version"
2727
}
@@ -39,11 +39,11 @@ section {
3939
content = <<-END
4040
A [Terraform] module for creating a public or private repository on [Github].
4141
42-
**_This module supports Terraform v1.x and is compatible with the Official Terraform GitHub Provider v4.20 and above from `integrations/github`._**
42+
**_This module supports Terraform v1.x and is compatible with the Official Terraform GitHub Provider v4.31 and above from `integrations/github`._**
4343
4444
**Attention: This module is incompatible with the Hashicorp GitHub Provider! The latest version of this module supporting `hashicorp/github` provider is `~> 0.10.0`**
4545
46-
** Note: Versions 5.3.0, 5.4.0, and 5.5.0 of the Terraform Github Provider have broken branch protections support and should not be used.**
46+
** Note: Versions 5.3.0, 5.4.0, 5.5.0, and 5.6.0 of the Terraform Github Provider have broken branch protections support and should not be used.**
4747
END
4848

4949
section {
@@ -168,6 +168,10 @@ section {
168168
`allow_rebase_merge`,
169169
`allow_squash_merge`,
170170
`allow_auto_merge`,
171+
`squash_merge_commit_title`,
172+
`squash_merge_commit_message`,
173+
`merge_commit_title`,
174+
`merge_commit_message`,
171175
`has_downloads`,
172176
`auto_init`,
173177
`gitignore_template`,
@@ -251,6 +255,34 @@ section {
251255
END
252256
}
253257

258+
variable "squash_merge_commit_title" {
259+
type = string
260+
description = <<-END
261+
Set to `PR_TITLE` or `COMMIT_OR_PR_TITLE` for a default squash merge commit title.
262+
END
263+
}
264+
265+
variable "squash_merge_commit_message" {
266+
type = string
267+
description = <<-END
268+
Set to `PR_BODY`, `COMMIT_MESSAGES`, or `BLANK` for a default squash merge commit message.
269+
END
270+
}
271+
272+
variable "merge_commit_title" {
273+
type = string
274+
description = <<-END
275+
Set to `PR_TITLE` or `MERGE_MESSAGE` for a default merge commit title.
276+
END
277+
}
278+
279+
variable "merge_commit_message" {
280+
type = string
281+
description = <<-END
282+
Set to `PR_BODY`, `PR_TITLE`, or `BLANK` for a default merge commit message.
283+
END
284+
}
285+
254286
variable "description" {
255287
type = string
256288
default = ""

Diff for: main.tf

+10
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ locals {
2929
issue_labels_create = var.issue_labels_create == null ? lookup(var.defaults, "issue_labels_create", local.issue_labels_create_computed) : var.issue_labels_create
3030
branch_protections_v3 = var.branch_protections_v3 == null ? var.branch_protections : var.branch_protections_v3
3131

32+
squash_merge_commit_title = var.squash_merge_commit_title == null ? try(var.defaults.squash_merge_commit_title, null) : var.squash_merge_commit_title
33+
squash_merge_commit_message = var.squash_merge_commit_title == null ? try(var.defaults.squash_merge_commit_title, null) : var.squash_merge_commit_title
34+
merge_commit_title = var.merge_commit_title == null ? try(var.defaults.merge_commit_title, null) : var.merge_commit_title
35+
merge_commit_message = var.var.merge_commit_message == null ? try(var.merge_commit_message, null) : var.var.merge_commit_message
36+
3237
issue_labels_create_computed = local.has_issues || length(var.issue_labels) > 0
3338

3439
# for readability
@@ -113,6 +118,11 @@ resource "github_repository" "repository" {
113118
archive_on_destroy = var.archive_on_destroy
114119
vulnerability_alerts = local.vulnerability_alerts
115120

121+
squash_merge_commit_title = local.squash_merge_commit_title
122+
squash_merge_commit_message = local.squash_merge_commit_message
123+
merge_commit_title = local.merge_commit_title
124+
merge_commit_message = local.merge_commit_message
125+
116126
dynamic "template" {
117127
for_each = local.template
118128

Diff for: test/unit-complete/provider.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ terraform {
66
required_providers {
77
github = {
88
source = "integrations/github"
9-
version = "~> 5.0, !=5.3.0, !=5.4.0, !=5.5.0"
9+
version = "~> 5.0, !=5.3.0, !=5.4.0, !=5.5.0, !=5.6.0"
1010
}
1111
tls = {
1212
source = "hashicorp/tls"

Diff for: test/unit-complete/variables.tf

+10-7
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ variable "allow_auto_merge" {
7070
default = true
7171
}
7272

73-
7473
variable "has_downloads" {
7574
description = "Set to true to enable the (deprecated) downloads features on the repository."
7675
type = bool
@@ -153,12 +152,16 @@ variable "repository_defaults" {
153152
description = "A map of default settings that can be applied to a repository."
154153
type = any
155154
default = {
156-
homepage_url = "https://github.com/mineiros-io"
157-
visibility = "private"
158-
allow_merge_commit = true
159-
gitignore_template = "Terraform"
160-
license_template = "mit"
161-
topics = ["terraform", "integration-test"]
155+
homepage_url = "https://github.com/mineiros-io"
156+
visibility = "private"
157+
allow_merge_commit = true
158+
gitignore_template = "Terraform"
159+
license_template = "mit"
160+
topics = ["terraform", "integration-test"]
161+
squash_merge_commit_title = "COMMIT_OR_PR_TITLE"
162+
squash_merge_commit_message = "COMMIT_MESSAGES"
163+
merge_commit_title = "MERGE_MESSAGE"
164+
merge_commit_message = "PR_TITLE"
162165
}
163166
}
164167

Diff for: variables.tf

+56-16
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,32 @@ variable "defaults" {
3030

3131
# Example:
3232
# defaults = {
33-
# homepage_url = "https://mineiros.io/"
34-
# visibility = "private"
35-
# has_issues = false
36-
# has_projects = false
37-
# has_wiki = false
38-
# delete_branch_on_merge = true
39-
# allow_merge_commit = true
40-
# allow_rebase_merge = false
41-
# allow_squash_merge = false
42-
# allow_auto_merge = false
43-
# has_downloads = false
44-
# auto_init = true
45-
# gitignore_template = "terraform"
46-
# license_template = "mit"
47-
# default_branch = "main"
48-
# topics = ["topic-1", "topic-2"]
33+
# homepage_url = "https://mineiros.io/"
34+
# visibility = "private"
35+
# has_issues = false
36+
# has_projects = false
37+
# has_wiki = false
38+
# has_downloads = false
39+
# delete_branch_on_merge = true
40+
# is_template = true
41+
# allow_merge_commit = true
42+
# allow_rebase_merge = false
43+
# allow_squash_merge = false
44+
# allow_auto_merge = false
45+
# auto_init = true
46+
# gitignore_template = "terraform"
47+
# license_template = "mit"
48+
# default_branch = "main"
49+
# branch_protections_v3 = []
50+
# topics = ["topic-1", "topic-2"]
51+
# template = "terraform-module-template"
52+
# vulnerability_alerts = true
53+
# ignore_vulnerability_alerts_during_read = true
54+
# issue_labels_create = false
55+
# squash_merge_commit_title = "PR_TITLE"
56+
# squash_merge_commit_message = "COMMIT_MESSAGES"
57+
# merge_commit_title = "PR_TITLE"
58+
# merge_commit_message = "PR_BODY"
4959
# }
5060

5161
default = {}
@@ -522,6 +532,12 @@ variable "vulnerability_alerts" {
522532
default = null
523533
}
524534

535+
variable "ignore_vulnerability_alerts_during_read" {
536+
type = bool
537+
description = "(Optional) Set to `true` to not call the vulnerability alerts endpoint so the resource can also be used without admin permissions during read."
538+
default = null
539+
}
540+
525541
variable "archive_on_destroy" {
526542
type = string
527543
description = "(Optional) Set to `false` to not archive the repository instead of deleting on destroy."
@@ -534,6 +550,30 @@ variable "app_installations" {
534550
default = []
535551
}
536552

553+
variable "squash_merge_commit_title" {
554+
type = string
555+
description = "(Optional) Can be `PR_BODY`, `COMMIT_MESSAGES`, or `BLANK` for a default squash merge commit message."
556+
default = null
557+
}
558+
559+
variable "squash_merge_commit_message" {
560+
type = string
561+
description = "(Optional) Can be `PR_BODY`, `COMMIT_MESSAGES`, or `BLANK` for a default squash merge commit message."
562+
default = null
563+
}
564+
565+
variable "merge_commit_title" {
566+
type = string
567+
description = "(Optional) Can be `PR_TITLE` or `MERGE_MESSAGE` for a default merge commit title."
568+
default = null
569+
}
570+
571+
variable "merge_commit_message" {
572+
type = string
573+
description = "(Optional) Can be `PR_BODY`, `PR_TITLE`, or `BLANK` for a default merge commit message."
574+
default = null
575+
}
576+
537577
# ------------------------------------------------------------------------------
538578
# MODULE CONFIGURATION PARAMETERS
539579
# These variables are used to configure the module.

Diff for: versions.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ terraform {
99
required_providers {
1010
github = {
1111
source = "integrations/github"
12-
version = ">= 4.20, < 6.0"
12+
version = ">= 4.31, < 6.0"
1313
}
1414
}
1515
}

0 commit comments

Comments
 (0)