Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Block the creation of empty commits #470

Merged
merged 1 commit into from Dec 20, 2022
Merged

Block the creation of empty commits #470

merged 1 commit into from Dec 20, 2022

Conversation

pjbgf
Copy link
Member

@pjbgf pjbgf commented Dec 20, 2022

In specific cases, the update mechanism may lead to no files being changed. The changes short-circuit the process to exit early when 0 files have been modified.

go-git has been changed to return an error when an empty commit is detected, which is used as a last resort.

When the push branch is different than the clone branch, the controller will now download all branch references from the Git server, in order to enable a single fetch operation.

Fixes #466.

In specific cases, the update mechanism may lead to no files being
changed. The changes short-circuit the process to exit early when
0 files have been modified.

go-git has been changed to return an error when an empty commit
is detected, which is used as a last resort.

When the push branch is different than the clone branch, the controller
will now download all branch references from the Git server, in order
to enable a single fetch operation.

Signed-off-by: Paulo Gomes <paulo.gomes@weave.works>
@pjbgf pjbgf added the area/git Git related issues and pull requests label Dec 20, 2022
@pjbgf pjbgf requested a review from aryan9600 December 20, 2022 10:58
Comment on lines +385 to +387
} else {
err = extgogit.ErrEmptyCommit
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are we creating an error here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is to be able to reuse the existing logic for handling empty commits.

Given that this controller will be refactored as part of the GA process, I found this was the easiest way to resolve the problem without duplicating code.

Copy link
Member

@aryan9600 aryan9600 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm! 🚀

Copy link
Member

@hiddeco hiddeco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @pjbgf 💯

@pjbgf pjbgf merged commit ed0c8a2 into main Dec 20, 2022
@pjbgf pjbgf deleted the empty-commits branch December 20, 2022 11:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/git Git related issues and pull requests
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Multiple empty commits since flux2 v0.37
4 participants