@@ -37,14 +37,18 @@ 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+ // Omit author/committer fields for GitHub App signed commits (empty signature)
43+ if params .Signature .Name != "" && params .Signature .Email != "" {
44+ in .Committer = & commitAuthor {
4145 Name : params .Signature .Name ,
4246 Email : params .Signature .Email ,
43- },
44- Author : commitAuthor {
47+ }
48+ in . Author = & commitAuthor {
4549 Name : params .Signature .Name ,
4650 Email : params .Signature .Email ,
47- },
51+ }
4852 }
4953
5054 res , err := s .client .do (ctx , "PUT" , endpoint , in , nil )
@@ -59,14 +63,18 @@ func (s *contentService) Update(ctx context.Context, repo, path string, params *
5963 Content : params .Data ,
6064 // NB the sha passed to github rest api is the blob sha, not the commit sha
6165 Sha : params .BlobID ,
62- Committer : commitAuthor {
66+ }
67+
68+ // Omit author/committer fields for GitHub App signed commits (empty signature)
69+ if params .Signature .Name != "" && params .Signature .Email != "" {
70+ in .Committer = & commitAuthor {
6371 Name : params .Signature .Name ,
6472 Email : params .Signature .Email ,
65- },
66- Author : commitAuthor {
73+ }
74+ in . Author = & commitAuthor {
6775 Name : params .Signature .Name ,
6876 Email : params .Signature .Email ,
69- },
77+ }
7078 }
7179 res , err := s .client .do (ctx , "PUT" , endpoint , in , nil )
7280 return res , err
@@ -79,14 +87,18 @@ func (s *contentService) Delete(ctx context.Context, repo, path string, params *
7987 Branch : params .Branch ,
8088 // NB the sha passed to github rest api is the blob sha, not the commit sha
8189 Sha : params .BlobID ,
82- Committer : commitAuthor {
90+ }
91+
92+ // Omit author/committer fields for GitHub App signed commits (empty signature)
93+ if params .Signature .Name != "" && params .Signature .Email != "" {
94+ in .Committer = & commitAuthor {
8395 Name : params .Signature .Name ,
8496 Email : params .Signature .Email ,
85- },
86- Author : commitAuthor {
97+ }
98+ in . Author = & commitAuthor {
8799 Name : params .Signature .Name ,
88100 Email : params .Signature .Email ,
89- },
101+ }
90102 }
91103 res , err := s .client .do (ctx , "DELETE" , endpoint , in , nil )
92104 return res , err
@@ -108,12 +120,12 @@ type content struct {
108120}
109121
110122type 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"`
123+ Branch string `json:"branch"`
124+ Message string `json:"message"`
125+ Content []byte `json:"content"`
126+ Sha string `json:"sha"`
127+ Author * commitAuthor `json:"author,omitempty "`
128+ Committer * commitAuthor `json:"committer,omitempty "`
117129}
118130
119131type commitAuthor struct {
0 commit comments