CommitOptions: AllowEmptyCommits, return error instead of creating empty commits#623
Merged
mcuadros merged 1 commit intogo-git:masterfrom Dec 11, 2022
Merged
CommitOptions: AllowEmptyCommits, return error instead of creating empty commits#623mcuadros merged 1 commit intogo-git:masterfrom
mcuadros merged 1 commit intogo-git:masterfrom
Conversation
Member
|
Ok, but make a way to opt out of this feature by adding |
BuildTree now returns an ErrEmptyCommit error, when there are no changes to be committed. This can be opted-out via CommitOptions.AllowEmptyCommits. This is a breaking change which enables applications to detect when empty commits are to be created. Some instances in which this can occur is when the fs (e.g. `billy/osfs`) make changes to the underlying files, causing a conflict between what the previous Git worktree state was, and the current state. Changes to the fs implementations are orthogonal to this, and will be dealt with separately. The new behaviour aligns with the Git CLI, in which empty commits returns the error message: 'nothing to commit, working tree clean'. Signed-off-by: Paulo Gomes <pjbgf@linux.com>
andrewpollock
referenced
this pull request
in google/osv.dev
Jan 5, 2023
[](https://renovatebot.com) This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [cloud.google.com/go/pubsub](https://togithub.com/googleapis/google-cloud-go) | require | minor | `v1.27.1` -> `v1.28.0` | | [github.com/go-git/go-git/v5](https://togithub.com/go-git/go-git) | require | patch | `v5.5.0` -> `v5.5.1` | | [google.golang.org/api](https://togithub.com/googleapis/google-api-go-client) | require | minor | `v0.103.0` -> `v0.106.0` | --- ### Release Notes <details> <summary>go-git/go-git</summary> ### [`v5.5.1`](https://togithub.com/go-git/go-git/releases/tag/v5.5.1) [Compare Source](https://togithub.com/go-git/go-git/compare/v5.5.0...v5.5.1) #### What's Changed - \*: fix error when building with `CGO_ENABLED=0` by [@​pjbgf](https://togithub.com/pjbgf) in [https://github.com/go-git/go-git/pull/625](https://togithub.com/go-git/go-git/pull/625) - plumbing: transport/ssh: fix panic on Windows 10 with paegent as ssh-agent by [@​doxsch](https://togithub.com/doxsch) in [https://github.com/go-git/go-git/pull/617](https://togithub.com/go-git/go-git/pull/617) - CommitOptions: AllowEmptyCommits, return an error instead of creating empty commits by [@​pjbgf](https://togithub.com/pjbgf) in [https://github.com/go-git/go-git/pull/623](https://togithub.com/go-git/go-git/pull/623) **Full Changelog**: go-git/go-git@v5.5.0...v5.5.1 </details> <details> <summary>googleapis/google-api-go-client</summary> ### [`v0.106.0`](https://togithub.com/googleapis/google-api-go-client/releases/tag/v0.106.0) [Compare Source](https://togithub.com/googleapis/google-api-go-client/compare/v0.105.0...v0.106.0) ##### Features - **all:** Auto-regenerate discovery clients ([#​1784](https://togithub.com/googleapis/google-api-go-client/issues/1784)) ([a7f08e2](https://togithub.com/googleapis/google-api-go-client/commit/a7f08e2d1f5d4590ae0c6d66077f012bd18b5464)) - **all:** Auto-regenerate discovery clients ([#​1788](https://togithub.com/googleapis/google-api-go-client/issues/1788)) ([9fb35f5](https://togithub.com/googleapis/google-api-go-client/commit/9fb35f5f5db837dc8aba5b742b63e1a837621f75)) - **all:** Auto-regenerate discovery clients ([#​1790](https://togithub.com/googleapis/google-api-go-client/issues/1790)) ([7bd17b3](https://togithub.com/googleapis/google-api-go-client/commit/7bd17b38d39db0700ee20e5078cd4b7c8c3d3acb)) - **all:** Auto-regenerate discovery clients ([#​1794](https://togithub.com/googleapis/google-api-go-client/issues/1794)) ([3944e86](https://togithub.com/googleapis/google-api-go-client/commit/3944e86684b39e05e27a17e66ed54873433c6ad4)) - **idtoken:** Add support for impersonated_service_account creds type ([#​1792](https://togithub.com/googleapis/google-api-go-client/issues/1792)) ([f6dec99](https://togithub.com/googleapis/google-api-go-client/commit/f6dec99d014cc508d0374b666f2c325534a30bea)), refs [#​873](https://togithub.com/googleapis/google-api-go-client/issues/873) - **option/internaloption:** Add new EmbeddableAdapter option ([#​1787](https://togithub.com/googleapis/google-api-go-client/issues/1787)) ([1569e5b](https://togithub.com/googleapis/google-api-go-client/commit/1569e5b294ad150050319c108bfbcade2180351b)) ##### Bug Fixes - **idtoken:** Configure validator constructor to use no authentication ([#​1789](https://togithub.com/googleapis/google-api-go-client/issues/1789)) ([b35900a](https://togithub.com/googleapis/google-api-go-client/commit/b35900aff148bb8446ca7e15ed0beb50d749d6c7)), refs [#​1682](https://togithub.com/googleapis/google-api-go-client/issues/1682) ### [`v0.105.0`](https://togithub.com/googleapis/google-api-go-client/releases/tag/v0.105.0) [Compare Source](https://togithub.com/googleapis/google-api-go-client/compare/v0.104.0...v0.105.0) ##### Features - **all:** Auto-regenerate discovery clients ([#​1773](https://togithub.com/googleapis/google-api-go-client/issues/1773)) ([37a2e41](https://togithub.com/googleapis/google-api-go-client/commit/37a2e41e92933254a8432f3b74ad1a16eae2c5ac)) - **all:** Auto-regenerate discovery clients ([#​1777](https://togithub.com/googleapis/google-api-go-client/issues/1777)) ([5b02761](https://togithub.com/googleapis/google-api-go-client/commit/5b02761e99fbb41602d107af92a8dec393250321)) - **googleapi:** Add response headers to Error reported by CheckMediaResponse ([#​1781](https://togithub.com/googleapis/google-api-go-client/issues/1781)) ([e4271df](https://togithub.com/googleapis/google-api-go-client/commit/e4271dfa222fea0fcf61fc5133c66e2e8d8f08b1)) - Support set null map entries for non-simple map values ([#​1782](https://togithub.com/googleapis/google-api-go-client/issues/1782)) ([c58bf4c](https://togithub.com/googleapis/google-api-go-client/commit/c58bf4cfef76fcd9a377452b5c3cb84d5f20ce98)) ### [`v0.104.0`](https://togithub.com/googleapis/google-api-go-client/releases/tag/v0.104.0) [Compare Source](https://togithub.com/googleapis/google-api-go-client/compare/v0.103.0...v0.104.0) ##### Features - **all:** Auto-regenerate discovery clients ([#​1746](https://togithub.com/googleapis/google-api-go-client/issues/1746)) ([292129c](https://togithub.com/googleapis/google-api-go-client/commit/292129c681cb5e8f7dc66e499e477be5aec4a26e)) - **all:** Auto-regenerate discovery clients ([#​1751](https://togithub.com/googleapis/google-api-go-client/issues/1751)) ([a657f19](https://togithub.com/googleapis/google-api-go-client/commit/a657f191681814da2c048118f02e5a85e9c9436b)) - **all:** Auto-regenerate discovery clients ([#​1752](https://togithub.com/googleapis/google-api-go-client/issues/1752)) ([dd565a4](https://togithub.com/googleapis/google-api-go-client/commit/dd565a4a1b3867b4a1fe86ff9d8a633a6f3ba032)) - **all:** Auto-regenerate discovery clients ([#​1753](https://togithub.com/googleapis/google-api-go-client/issues/1753)) ([e18b504](https://togithub.com/googleapis/google-api-go-client/commit/e18b5044ca349e4d5b4a3b1cd807fed7e1e0fd39)) - **all:** Auto-regenerate discovery clients ([#​1755](https://togithub.com/googleapis/google-api-go-client/issues/1755)) ([caf7af0](https://togithub.com/googleapis/google-api-go-client/commit/caf7af030c55a39723c92c3d9ee66b7c6c1e5a04)) - **all:** Auto-regenerate discovery clients ([#​1760](https://togithub.com/googleapis/google-api-go-client/issues/1760)) ([97a9846](https://togithub.com/googleapis/google-api-go-client/commit/97a98461099acaeccf04f64531ef7f06696e64fd)) - **all:** Auto-regenerate discovery clients ([#​1766](https://togithub.com/googleapis/google-api-go-client/issues/1766)) ([3195ce1](https://togithub.com/googleapis/google-api-go-client/commit/3195ce1ad12642c558d76353328a0ad05173e608)) - **all:** Auto-regenerate discovery clients ([#​1767](https://togithub.com/googleapis/google-api-go-client/issues/1767)) ([2b596d9](https://togithub.com/googleapis/google-api-go-client/commit/2b596d9f5bf651ba950d60378880ef98bf9f439f)) - **all:** Auto-regenerate discovery clients ([#​1771](https://togithub.com/googleapis/google-api-go-client/issues/1771)) ([f819644](https://togithub.com/googleapis/google-api-go-client/commit/f8196440cbf05306c6f25dfe490e1a9069d44952)) - **transport:** De-experiment google-c2p resolver ([#​1757](https://togithub.com/googleapis/google-api-go-client/issues/1757)) ([8d8f0a7](https://togithub.com/googleapis/google-api-go-client/commit/8d8f0a70d0bd6ba4daaa08370d1420f759ff7f9d)) ##### Bug Fixes - **idtoken:** Increase MaxIdleConnsPerHost to 100 in NewClient ([#​1754](https://togithub.com/googleapis/google-api-go-client/issues/1754)) ([629e217](https://togithub.com/googleapis/google-api-go-client/commit/629e217f768c719d047c87c7389fbf757a45d0b9)), refs [#​1744](https://togithub.com/googleapis/google-api-go-client/issues/1744) - **transport/grpc:** Separate resolution of creds and certs ([#​1759](https://togithub.com/googleapis/google-api-go-client/issues/1759)) ([c213153](https://togithub.com/googleapis/google-api-go-client/commit/c213153d17a87e76a4f721076ddaed3ac8cb26c7)) ##### Documentation - Document limitation of WithUserAgent ([#​1747](https://togithub.com/googleapis/google-api-go-client/issues/1747)) ([567070f](https://togithub.com/googleapis/google-api-go-client/commit/567070f3835f9f4039ed121de7319f9cf5a5af6b)) </details> --- ### Configuration 📅 **Schedule**: Branch creation - "before 6am on monday" in timezone Australia/Sydney, Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 👻 **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://togithub.com/renovatebot/renovate/discussions) if that's undesired. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/google/osv.dev). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNC4yNC4wIiwidXBkYXRlZEluVmVyIjoiMzQuNzMuMyJ9-->
makkes
pushed a commit
to fluxcd/go-git-providers
that referenced
this pull request
May 4, 2023
go-git 5.5.1 shipped a breaking change (go-git/go-git#623) that we need to take into account here in setting `AllowEmptyCommits: true` when initializing a bitbucket repository. Signed-off-by: Max Jonas Werner <mail@makk.es>
makkes
pushed a commit
to fluxcd/go-git-providers
that referenced
this pull request
May 4, 2023
go-git 5.5.1 shipped a breaking change (go-git/go-git#623) that we need to take into account here in setting `AllowEmptyCommits: true` when initializing a bitbucket repository. Signed-off-by: Max Jonas Werner <mail@makk.es>
epmd-edp
pushed a commit
to epam/edp-codebase-operator
that referenced
this pull request
Mar 1, 2024
After updating go-git v5.4.3 -> v5.11.0, an empty commit returns an error. It is due to change go-git/go-git#623 Added property to commit to allowing empty commit. Change-Id: I8bd83e42e282dff78976276039159f1f1e647ad5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
BuildTree now returns an
ErrEmptyCommiterror, when there are no changes to be committed, which can be opted-out viaCommitOptions.AllowEmptyCommits.This is a breaking change which enables applications to detect when empty commits are to be created.
Some instances in which this can occur is when the fs (e.g.
billy/osfs) make changes to the underlying files, causing a conflict between what the previous Git worktree state was, and the current state. Changes to the fs implementations are orthogonal to this, and will be dealt with separately.The new behaviour aligns with the Git CLI, in which empty commits returns the error message:
nothing to commit, working tree clean.