@@ -37,14 +37,19 @@ func (s *contentService) Create(ctx context.Context, repo, path string, params *
3737 Message : params .Message ,
3838 Branch : params .Branch ,
3939 Content : params .Data ,
40- Committer : commitAuthor {
40+ }
41+
42+ // Only set author/committer if signature has non-empty name and email
43+ // For GitHub App signed commits, omit these fields entirely
44+ if params .Signature .Name != "" && params .Signature .Email != "" {
45+ in .Committer = & commitAuthor {
4146 Name : params .Signature .Name ,
4247 Email : params .Signature .Email ,
43- },
44- Author : commitAuthor {
48+ }
49+ in . Author = & commitAuthor {
4550 Name : params .Signature .Name ,
4651 Email : params .Signature .Email ,
47- },
52+ }
4853 }
4954
5055 res , err := s .client .do (ctx , "PUT" , endpoint , in , nil )
@@ -59,14 +64,19 @@ func (s *contentService) Update(ctx context.Context, repo, path string, params *
5964 Content : params .Data ,
6065 // NB the sha passed to github rest api is the blob sha, not the commit sha
6166 Sha : params .BlobID ,
62- Committer : commitAuthor {
67+ }
68+
69+ // Only set author/committer if signature has non-empty name and email
70+ // For GitHub App signed commits, omit these fields entirely
71+ if params .Signature .Name != "" && params .Signature .Email != "" {
72+ in .Committer = & commitAuthor {
6373 Name : params .Signature .Name ,
6474 Email : params .Signature .Email ,
65- },
66- Author : commitAuthor {
75+ }
76+ in . Author = & commitAuthor {
6777 Name : params .Signature .Name ,
6878 Email : params .Signature .Email ,
69- },
79+ }
7080 }
7181 res , err := s .client .do (ctx , "PUT" , endpoint , in , nil )
7282 return res , err
@@ -79,14 +89,19 @@ func (s *contentService) Delete(ctx context.Context, repo, path string, params *
7989 Branch : params .Branch ,
8090 // NB the sha passed to github rest api is the blob sha, not the commit sha
8191 Sha : params .BlobID ,
82- Committer : commitAuthor {
92+ }
93+
94+ // Only set author/committer if signature has non-empty name and email
95+ // For GitHub App signed commits, omit these fields entirely
96+ if params .Signature .Name != "" && params .Signature .Email != "" {
97+ in .Committer = & commitAuthor {
8398 Name : params .Signature .Name ,
8499 Email : params .Signature .Email ,
85- },
86- Author : commitAuthor {
100+ }
101+ in . Author = & commitAuthor {
87102 Name : params .Signature .Name ,
88103 Email : params .Signature .Email ,
89- },
104+ }
90105 }
91106 res , err := s .client .do (ctx , "DELETE" , endpoint , in , nil )
92107 return res , err
@@ -108,12 +123,12 @@ type content struct {
108123}
109124
110125type contentCreateUpdate struct {
111- Branch string `json:"branch"`
112- Message string `json:"message"`
113- Content []byte `json:"content"`
114- Sha string `json:"sha"`
115- Author commitAuthor `json:"author"`
116- Committer commitAuthor `json:"committer"`
126+ Branch string `json:"branch"`
127+ Message string `json:"message"`
128+ Content []byte `json:"content"`
129+ Sha string `json:"sha"`
130+ Author * commitAuthor `json:"author,omitempty "`
131+ Committer * commitAuthor `json:"committer,omitempty "`
117132}
118133
119134type commitAuthor struct {
0 commit comments