Skip to content

Commit 9510487

Browse files
committed
Warn if default_branch is set, but the repo is empty
1 parent d875e04 commit 9510487

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

gitlab/resource_gitlab_project.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ var resourceGitLabProjectSchema = map[string]*schema.Schema{
3939
Type: schema.TypeString,
4040
Optional: true,
4141
DiffSuppressFunc: func(k, current, planned string, d *schema.ResourceData) bool {
42-
old := current
43-
new := planned
42+
old := current // current value on GitLab side
43+
new := planned // value that Terraform plans to set there
4444

4545
log.Printf("[DEBUG] default_branch DiffSuppressFunc old new")
4646
log.Printf("[DEBUG] (%T) %#v, (%T) %#v", old, old, new, new)
@@ -50,6 +50,9 @@ var resourceGitLabProjectSchema = map[string]*schema.Schema{
5050
// with 400 error. The check will defer the setting of a default branch
5151
// to a time when the repository is no longer empty.
5252
if old == "" {
53+
if new != "" {
54+
log.Printf("[WARN] not setting default_branch %#v on empty repo", new)
55+
}
5356
return true
5457
}
5558

0 commit comments

Comments
 (0)