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

Ignore trivial errors when updating push data #33864

Merged
merged 4 commits into from
Mar 14, 2025

Conversation

wxiaoguang
Copy link
Contributor

@wxiaoguang wxiaoguang commented Mar 13, 2025

Fix #23213

This block is only used for sending notifications, and it is executed after the git repo has been successfully pushed. So we could safely ignore the error.

By the way, remove another useless warning: unknown whitespace behavior: %q, default to 'show-all'. That parameter is provided by the end user, no need to warn that.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Mar 13, 2025
@pull-request-size pull-request-size bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Mar 13, 2025
@github-actions github-actions bot added the modifies/go Pull requests that update Go code label Mar 13, 2025
@wxiaoguang
Copy link
Contributor Author

@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Mar 13, 2025
@wxiaoguang
Copy link
Contributor Author

By the way, remove another useless warning: unknown whitespace behavior: %q, default to 'show-all'. That parameter is provided by the end user, no need to warn that.

Comment on lines 136 to 140
if err != nil {
return fmt.Errorf("gitRepo.GetCommit(%s) in %s/%s[%d]: %w", opts.NewCommitID, repo.OwnerName, repo.Name, repo.ID, err)
// in case there is dirty data, for example, the "github.com/git/git" repository has tags points to non-existing commits
if !errors.Is(err, util.ErrNotExist) {
log.Error("Unable to get tag commit: gitRepo.GetCommit(%s) in %s/%s[%d]: %v", opts.NewCommitID, repo.OwnerName, repo.Name, repo.ID, err)
}

Choose a reason for hiding this comment

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

Firstly, in this context, git/git does not refer to a tag pointing to a non-existent commit, but rather to a blob. Additionally, why not log all error conditions here?

Copy link
Contributor Author

@wxiaoguang wxiaoguang Mar 13, 2025

Choose a reason for hiding this comment

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

  1. The "tag" could point to anything. It just happened to point to a blob, and in this case GetCommit considers it as the commit doesn't exist (it is right). I do not see a bad case for this approach.
  2. Why log all errors?

Choose a reason for hiding this comment

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

  1. Alright, I think your explanation makes sense.
  2. Do we not need to record errors: there is a tag pointing to a non-existent commit?

Copy link
Contributor Author

@wxiaoguang wxiaoguang Mar 14, 2025

Choose a reason for hiding this comment

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

Do we not need to record errors: there is a tag pointing to a non-existent commit?

Suppose the error is recorded, then what it would help in real world? Would end user be able to see that error message, or site admin would really regularly check the error message, or site admin could take any action to that error message?

Choose a reason for hiding this comment

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

I think this is generally intended for Gitea administrators. This kind of error message can inform the administrators that a push webhook may be missing here.

@wxiaoguang wxiaoguang added this to the 1.24.0 milestone Mar 13, 2025
@wxiaoguang wxiaoguang added the backport/v1.23 This PR should be backported to Gitea 1.23 label Mar 14, 2025
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Mar 14, 2025
@wxiaoguang wxiaoguang enabled auto-merge (squash) March 14, 2025 07:56
@wxiaoguang wxiaoguang merged commit cb6b33c into go-gitea:main Mar 14, 2025
26 checks passed
@wxiaoguang wxiaoguang deleted the fix-push-tag-err branch March 14, 2025 10:18
GiteaBot pushed a commit to GiteaBot/gitea that referenced this pull request Mar 14, 2025
@GiteaBot GiteaBot added the backport/done All backports for this PR have been created label Mar 14, 2025
wxiaoguang added a commit that referenced this pull request Mar 14, 2025
Backport #33864 by wxiaoguang

Fix #23213

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
project-mirrors-bot-tu bot pushed a commit to project-mirrors/forgejo-as-gitea-fork that referenced this pull request Mar 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/done All backports for this PR have been created backport/v1.23 This PR should be backported to Gitea 1.23 lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. modifies/go Pull requests that update Go code size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Push update failed when git tag reference to a blob
5 participants