Skip to content

Commit 1c2e361

Browse files
Fix committer details lifecycle issues
1 parent 1ed3507 commit 1c2e361

1 file changed

Lines changed: 22 additions & 11 deletions

File tree

github/resource_github_repository_file.go

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -367,23 +367,34 @@ func resourceGithubRepositoryFileRead(d *schema.ResourceData, meta interface{})
367367
return err
368368
}
369369

370-
commit_author := commit.Commit.GetCommitter().GetName()
371-
commit_email := commit.Commit.GetCommitter().GetEmail()
372-
373-
_, hasCommitAuthor := d.GetOk("commit_author")
374-
_, hasCommitEmail := d.GetOk("commit_email")
370+
if commit_author_st, hasCommitAuthor := d.GetOk("commit_author"); hasCommitAuthor {
371+
if err = d.Set("commit_author", commit_author_st.(string)); err != nil {
372+
return err
373+
}
374+
} else {
375+
if err = d.Set("commit_author", nil); err != nil {
376+
return err
377+
}
378+
}
375379

376-
//read from state if author+email is set explicitly, and if it was not github signing it for you previously
377-
if commit_author != "GitHub" && commit_email != "[email protected]" && hasCommitAuthor && hasCommitEmail {
378-
if err = d.Set("commit_author", commit_author); err != nil {
380+
if commit_email_st, hasCommitEmail := d.GetOk("commit_email"); hasCommitEmail {
381+
if err = d.Set("commit_email", commit_email_st.(string)); err != nil {
379382
return err
380383
}
381-
if err = d.Set("commit_email", commit_email); err != nil {
384+
} else {
385+
if err = d.Set("commit_email", nil); err != nil {
382386
return err
383387
}
384388
}
385-
if err = d.Set("commit_message", commit.GetCommit().GetMessage()); err != nil {
386-
return err
389+
390+
if commit_message_st, hasCommitMessage := d.GetOk("commit_message"); hasCommitMessage {
391+
if err = d.Set("commit_message", commit_message_st.(string)); err != nil {
392+
return err
393+
}
394+
} else {
395+
if err = d.Set("commit_message", nil); err != nil {
396+
return err
397+
}
387398
}
388399

389400
return nil

0 commit comments

Comments
 (0)