-
Notifications
You must be signed in to change notification settings - Fork 271
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
[BUG] Resulting images broken during repo reset #273
Comments
Hey thanks for reporting this! I just forked the project and reproduced the same outcome. Something strange for sure. I wonder if there is a way we can detect this in the code here when it happens or if ImageMagick had any idea it was creating corrupted files. |
Maybe try loosely comparing images? |
I got a chance to debug this further tonight and the result is pretty interesting. The compression of the image is fine, it is the git signature routine that is corrupting the image. I didn't expect that! Here is the relevant code snippet from the source var signature = new Signature(KnownGitHubs.ImgBotLogin, KnownGitHubs.ImgBotEmail, DateTimeOffset.Now);
repo.Commit(commitMessage, signature, signature);
// We just made a normal commit, now we are going to capture all the values generated from that commit
// then rewind and make a signed commit
var commitBuffer = Commit.CreateBuffer(
repo.Head.Tip.Author,
repo.Head.Tip.Committer,
repo.Head.Tip.Message,
repo.Head.Tip.Tree,
repo.Head.Tip.Parents,
true,
null);
var signedCommitData = CommitSignature.Sign(commitBuffer + "\n", parameters.PgpPrivateKeyStream, parameters.PgPPassword);
repo.Reset(ResetMode.Soft, repo.Head.Commits.Skip(1).First().Sha);
var commitToKeep = repo.ObjectDatabase.CreateCommitWithSignature(commitBuffer, signedCommitData);
repo.Refs.UpdateTarget(repo.Refs.Head, commitToKeep);
var branchAgain = Commands.Checkout(repo, KnownGitHubs.BranchName);
repo.Reset(ResetMode.Hard, commitToKeep.Sha); It is the final It's kind of a coincidence that this reset is causing the images to be corrupt. So it is actually any reading from the git database that is corrupting the images. |
opened #297 as a workaround so at least we don't get bad PRs. |
verify images are not corrupt after reset (fixes #273)
@webknjaz thanks for reporting this issue here. Turns out the git compression was the culprit. And while we couldn't find a way to retain the compression without corrupting the images, we do have a safeguard now to stop ImgBot from pushing commits with corrupted images. Please feel free to open more issues for any problems or questions you have. |
I don't know what exactly happened but the resulting images got completely broken in ansible/ansible-lint repo.
Context:
Maybe you could figure out what was that from logs or so.
The text was updated successfully, but these errors were encountered: