Skip to content

Commit ee13dab

Browse files
gaima8soerenmartiusmariux
committed
feat!: add support for configuring default squash and merge commit title and messages (#3)
* docs: add missing default options to README.md * chore: prepare v0.18.0 release --------- Co-authored-by: Soren Martius <soeren.martius@gmail.com> Co-authored-by: Marius Tolzmann <marius@mineiros.io>
1 parent ee6001a commit ee13dab

File tree

9 files changed

+122
-14
lines changed

9 files changed

+122
-14
lines changed

CHANGELOG.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [0.19.0]
11+
12+
### Changed
13+
14+
- BREAKING: update to provider `>= 4.31` for supporting default squash and merge commit titles and messages
15+
16+
### Added
17+
18+
- Add support for `squash_merge_commit_title`
19+
- Add support for `squash_merge_commit_message`
20+
- Add support for `merge_commit_title`
21+
- Add support for `merge_commit_message`
22+
1023
## [0.18.0]
1124

1225
### Added
@@ -399,7 +412,8 @@ Please review plans and report regressions and issues asap so we can improve doc
399412
- This is the initial release of our GitHub Repository module with support for
400413
creating and managing GitHub Repositories for Organizations.
401414

402-
[unreleased]: https://github.com/mineiros-io/terraform-github-repository/compare/v0.18.0...HEAD
415+
[unreleased]: https://github.com/mineiros-io/terraform-github-repository/compare/v0.19.0...HEAD
416+
[0.19.0]: https://github.com/mineiros-io/terraform-github-repository/compare/v0.18.0...v0.19.0
403417
[0.18.0]: https://github.com/mineiros-io/terraform-github-repository/compare/v0.17.0...v0.18.0
404418
[0.17.0]: https://github.com/mineiros-io/terraform-github-repository/compare/v0.16.2...v0.17.0
405419
[0.16.2]: https://github.com/mineiros-io/terraform-github-repository/compare/v0.16.1...v0.16.2

README.md

Lines changed: 29 additions & 4 deletions
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/slack-@mineiros--community-f32752.svg?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)
@@ -90,7 +90,8 @@ features like Branch Protection or Collaborator Management.
9090
Teams,
9191
Deploy Keys,
9292
Projects,
93-
Repository Webhooks
93+
Repository Webhooks,
94+
GitHub App Installations
9495

9596
- _Features not yet implemented_:
9697
Project Columns support,
@@ -182,6 +183,30 @@ See [variables.tf] and [examples/] for details and use-cases.
182183

183184
Default is `false`.
184185

186+
- [**`squash_merge_commit_title`**](#var-squash_merge_commit_title): *(Optional `string`)*<a name="var-squash_merge_commit_title"></a>
187+
188+
Set to `PR_TITLE` or `COMMIT_OR_PR_TITLE` for a default squash merge commit title.
189+
190+
Default is `"COMMIT_OR_PR_TITLE"`.
191+
192+
- [**`squash_merge_commit_message`**](#var-squash_merge_commit_message): *(Optional `string`)*<a name="var-squash_merge_commit_message"></a>
193+
194+
Set to `PR_BODY`, `COMMIT_MESSAGES`, or `BLANK` for a default squash merge commit message.
195+
196+
Default is `"COMMIT_MESSAGES"`.
197+
198+
- [**`merge_commit_title`**](#var-merge_commit_title): *(Optional `string`)*<a name="var-merge_commit_title"></a>
199+
200+
Set to `PR_TITLE` or `MERGE_MESSAGE` for a default merge commit title.
201+
202+
Default is `"MERGE_MESSAGE"`.
203+
204+
- [**`merge_commit_message`**](#var-merge_commit_message): *(Optional `string`)*<a name="var-merge_commit_message"></a>
205+
206+
Set to `PR_BODY`, `PR_TITLE`, or `BLANK` for a default merge commit message.
207+
208+
Default is `"PR_TITLE"`.
209+
185210
- [**`description`**](#var-description): *(Optional `string`)*<a name="var-description"></a>
186211

187212
A description of the repository.

README.tfdoc.hcl

Lines changed: 37 additions & 4 deletions
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 {
@@ -92,7 +92,8 @@ section {
9292
Teams,
9393
Deploy Keys,
9494
Projects,
95-
Repository Webhooks
95+
Repository Webhooks,
96+
GitHub App Installations
9697
9798
- _Features not yet implemented_:
9899
Project Columns support,
@@ -216,6 +217,38 @@ section {
216217
END
217218
}
218219

220+
variable "squash_merge_commit_title" {
221+
type = string
222+
default = "COMMIT_OR_PR_TITLE"
223+
description = <<-END
224+
Set to `PR_TITLE` or `COMMIT_OR_PR_TITLE` for a default squash merge commit title.
225+
END
226+
}
227+
228+
variable "squash_merge_commit_message" {
229+
type = string
230+
default = "COMMIT_MESSAGES"
231+
description = <<-END
232+
Set to `PR_BODY`, `COMMIT_MESSAGES`, or `BLANK` for a default squash merge commit message.
233+
END
234+
}
235+
236+
variable "merge_commit_title" {
237+
type = string
238+
default = "MERGE_MESSAGE"
239+
description = <<-END
240+
Set to `PR_TITLE` or `MERGE_MESSAGE` for a default merge commit title.
241+
END
242+
}
243+
244+
variable "merge_commit_message" {
245+
type = string
246+
default = "PR_TITLE"
247+
description = <<-END
248+
Set to `PR_BODY`, `PR_TITLE`, or `BLANK` for a default merge commit message.
249+
END
250+
}
251+
219252
variable "description" {
220253
type = string
221254
default = ""

examples/public-repository/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ branch protection.
1515
```hcl
1616
module "repository" {
1717
source = "mineiros-io/repository/github"
18-
version = "~> 0.13.0"
18+
version = "~> 0.18.0"
1919
2020
module_depends_on = [
2121
github_team.team

main.tf

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ locals {
1111
visibility = var.visibility == null ? lookup(var.defaults, "visibility", local.private_visibility) : var.visibility
1212
has_issues = var.has_issues == null ? lookup(var.defaults, "has_issues", false) : var.has_issues
1313
has_projects = var.has_projects == null ? lookup(var.defaults, "has_projects", false) : length(var.projects) > 0 ? true : var.has_projects
14+
has_downloads = var.has_downloads == null ? lookup(var.defaults, "has_downloads", false) : var.has_downloads
1415
has_wiki = var.has_wiki == null ? lookup(var.defaults, "has_wiki", false) : var.has_wiki
1516
allow_merge_commit = var.allow_merge_commit == null ? lookup(var.defaults, "allow_merge_commit", true) : var.allow_merge_commit
1617
allow_rebase_merge = var.allow_rebase_merge == null ? lookup(var.defaults, "allow_rebase_merge", false) : var.allow_rebase_merge
1718
allow_squash_merge = var.allow_squash_merge == null ? lookup(var.defaults, "allow_squash_merge", false) : var.allow_squash_merge
1819
allow_auto_merge = var.allow_auto_merge == null ? lookup(var.defaults, "allow_auto_merge", false) : var.allow_auto_merge
1920
delete_branch_on_merge = var.delete_branch_on_merge == null ? lookup(var.defaults, "delete_branch_on_merge", true) : var.delete_branch_on_merge
2021
is_template = var.is_template == null ? lookup(var.defaults, "is_template", false) : var.is_template
21-
has_downloads = var.has_downloads == null ? lookup(var.defaults, "has_downloads", false) : var.has_downloads
2222
auto_init = var.auto_init == null ? lookup(var.defaults, "auto_init", true) : var.auto_init
2323
gitignore_template = var.gitignore_template == null ? lookup(var.defaults, "gitignore_template", "") : var.gitignore_template
2424
license_template = var.license_template == null ? lookup(var.defaults, "license_template", "") : var.license_template
@@ -28,6 +28,11 @@ locals {
2828
template = var.template == null ? [] : [var.template]
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

31+
squash_merge_commit_title = var.squash_merge_commit_title == null ? try(var.defaults.squash_merge_commit_title, "COMMIT_OR_PR_TITLE") : var.squash_merge_commit_title
32+
squash_merge_commit_message = var.squash_merge_commit_message == null ? try(var.defaults.squash_merge_commit_message, "COMMIT_MESSAGES") : var.squash_merge_commit_message
33+
merge_commit_title = var.merge_commit_title == null ? try(var.defaults.merge_commit_title, "MERGE_MESSAGE") : var.merge_commit_title
34+
merge_commit_message = var.merge_commit_message == null ? try(var.merge_commit_message, "PR_TITLE") : var.merge_commit_message
35+
3136
issue_labels_create_computed = local.has_issues || length(var.issue_labels) > 0
3237

3338
# for readability
@@ -112,6 +117,11 @@ resource "github_repository" "repository" {
112117
archive_on_destroy = var.archive_on_destroy
113118
vulnerability_alerts = local.vulnerability_alerts
114119

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

test/unit-complete/provider.tf

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ terraform {
55

66
required_providers {
77
github = {
8-
source = "integrations/github"
8+
source = "integrations/github"
9+
version = "~> 5.0, !=5.3.0, !=5.4.0, !=5.5.0, !=5.6.0, !=5.7.0"
10+
source = "integrations/github"
911
# mask providers with broken branch protection v3 imlementation
1012
version = "~> 5.0, !=5.3.0, !=5.4.0, !=5.5.0, !=5.6.0, !=5.7.0"
1113
}

test/unit-complete/variables.tf

Lines changed: 1 addition & 1 deletion
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
@@ -156,6 +155,7 @@ variable "repository_defaults" {
156155
homepage_url = "https://github.com/mineiros-io"
157156
visibility = "private"
158157
allow_merge_commit = true
158+
allow_squash_merge = false
159159
gitignore_template = "Terraform"
160160
license_template = "mit"
161161
topics = ["terraform", "integration-test"]

variables.tf

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,30 @@ variable "app_installations" {
556556
default = []
557557
}
558558

559+
variable "squash_merge_commit_title" {
560+
type = string
561+
description = "(Optional) Can be `PR_BODY`, `COMMIT_MESSAGES`, or `BLANK` for a default squash merge commit message."
562+
default = "COMMIT_OR_PR_TITLE"
563+
}
564+
565+
variable "squash_merge_commit_message" {
566+
type = string
567+
description = "(Optional) Can be `PR_BODY`, `COMMIT_MESSAGES`, or `BLANK` for a default squash merge commit message."
568+
default = "COMMIT_MESSAGES"
569+
}
570+
571+
variable "merge_commit_title" {
572+
type = string
573+
description = "(Optional) Can be `PR_TITLE` or `MERGE_MESSAGE` for a default merge commit title."
574+
default = "MERGE_MESSAGE"
575+
}
576+
577+
variable "merge_commit_message" {
578+
type = string
579+
description = "(Optional) Can be `PR_BODY`, `PR_TITLE`, or `BLANK` for a default merge commit message."
580+
default = "PR_TITLE"
581+
}
582+
559583
# ------------------------------------------------------------------------------
560584
# MODULE CONFIGURATION PARAMETERS
561585
# These variables are used to configure the module.

versions.tf

Lines changed: 1 addition & 1 deletion
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)