@@ -17,6 +17,7 @@ package githubfile
17
17
import (
18
18
"context"
19
19
"fmt"
20
+ "strings"
20
21
"time"
21
22
22
23
"github.com/form3tech-oss/go-github-utils/pkg/branch"
@@ -98,7 +99,7 @@ func resourceFileCreateOrUpdate(s string, d *schema.ResourceData, m interface{})
98
99
if err := commit .CreateCommit (context .Background (), c .githubClient , & commit.CommitOptions {
99
100
RepoOwner : f .repositoryOwner ,
100
101
RepoName : f .repositoryName ,
101
- CommitMessage : fmt . Sprintf ( s , f .path ),
102
+ CommitMessage : formatCommitMessage ( c . commitMessagePrefix , s , f .path ),
102
103
GpgPassphrase : c .gpgPassphrase ,
103
104
GpgPrivateKey : c .gpgSecretKey ,
104
105
Username : c .githubUsername ,
@@ -150,7 +151,7 @@ func resourceFileDelete(d *schema.ResourceData, m interface{}) error {
150
151
if err := commit .CreateCommit (context .Background (), c .githubClient , & commit.CommitOptions {
151
152
RepoOwner : f .repositoryOwner ,
152
153
RepoName : f .repositoryName ,
153
- CommitMessage : fmt . Sprintf ( "Delete %q." , f .path ),
154
+ CommitMessage : formatCommitMessage ( c . commitMessagePrefix , "Delete %q." , f .path ),
154
155
GpgPassphrase : c .gpgPassphrase ,
155
156
GpgPrivateKey : c .gpgSecretKey ,
156
157
Username : c .githubUsername ,
@@ -194,3 +195,10 @@ func resourceFileRead(d *schema.ResourceData, m interface{}) error {
194
195
func resourceFileUpdate (d * schema.ResourceData , m interface {}) error {
195
196
return resourceFileCreateOrUpdate ("Update %q." , d , m )
196
197
}
198
+
199
+ func formatCommitMessage (p , m string , args ... interface {}) string {
200
+ if p == "" {
201
+ return fmt .Sprintf (m , args ... )
202
+ }
203
+ return fmt .Sprintf (strings .TrimSpace (p )+ " " + m , args ... )
204
+ }
0 commit comments