Skip to content

Conversation

@atorrescogollo
Copy link

When terraform changes any field related to how commits are done (email, commit message, etc), it pushes an unexpected empty commit to the repo.

This is specially relevant when importing an existing file into terraform, where the commit message you put in terraform will likely be different from the commit that pushed the file originally. In that sense, importing a file will always mean eventually doing empty commits for each file you imported.

The expected behaviour is just updating the state and avoid doing those empty commits. Otherwise, each empty commit can run any CI that might be configured, notifications, etc.

Resolves #689
Recreated from #2638


Before the change?

  • When any of commit_sha, commit_author, commit_email or commit_message changed, it did a empty commit

After the change?

  • Now, it checks which fields have changes and only commits if there are changes in any other field

Pull request checklist

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed (for bug fixes / features)

Does this introduce a breaking change?

Please see our docs on breaking changes to help!

  • Yes
  • No

@nickfloyd nickfloyd moved this from 🆕 Triage to 👀 In review in 🧰 Octokit Active Jun 3, 2025
…e__fix-empty-commits

# Conflicts:
#	github/resource_github_repository_file.go
The Update and Delete functions were dereferencing opts.Message without
checking for nil, which could cause a panic when users don't specify a
commit_message in their configuration.

Added nil checks before dereferencing to use default messages when no
custom message is provided.
@atorrescogollo
Copy link
Author

@nickfloyd Hey, this PR was outdated due to being open for several months, so I just updated it with the latest main and resolved all conflicts.

Could you review it when you get a chance? Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

github_repository_file keeps sending empty commits with the same commit message despite no changes to file content

1 participant