-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
Conversation
Diff with ignoring spaces: https://github.com/go-gitea/gitea/pull/33864/files?diff=unified&w=1 |
57b8d63
to
9b0b45b
Compare
9b0b45b
to
d4655b0
Compare
By the way, remove another useless warning: |
services/repository/push.go
Outdated
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) | ||
} |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 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. - Why log all errors?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Alright, I think your explanation makes sense.
- Do we not need to record errors: there is a tag pointing to a non-existent commit?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
Fix go-gitea#23213 (cherry picked from commit cb6b33c)
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.