-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Ignore trivial errors when updating push data #33864
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ import ( | |
repo_module "code.gitea.io/gitea/modules/repository" | ||
"code.gitea.io/gitea/modules/setting" | ||
"code.gitea.io/gitea/modules/timeutil" | ||
"code.gitea.io/gitea/modules/util" | ||
issue_service "code.gitea.io/gitea/services/issue" | ||
notify_service "code.gitea.io/gitea/services/notify" | ||
pull_service "code.gitea.io/gitea/services/pull" | ||
|
@@ -133,23 +134,26 @@ func pushUpdates(optsList []*repo_module.PushUpdateOptions) error { | |
} else { // is new tag | ||
newCommit, err := gitRepo.GetCommit(opts.NewCommitID) | ||
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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
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 commentThe 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. |
||
} else { | ||
commits := repo_module.NewPushCommits() | ||
commits.HeadCommit = repo_module.CommitToPushCommit(newCommit) | ||
commits.CompareURL = repo.ComposeCompareURL(objectFormat.EmptyObjectID().String(), opts.NewCommitID) | ||
|
||
notify_service.PushCommits( | ||
ctx, pusher, repo, | ||
&repo_module.PushUpdateOptions{ | ||
RefFullName: opts.RefFullName, | ||
OldCommitID: objectFormat.EmptyObjectID().String(), | ||
NewCommitID: opts.NewCommitID, | ||
}, commits) | ||
|
||
addTags = append(addTags, tagName) | ||
notify_service.CreateRef(ctx, pusher, repo, opts.RefFullName, opts.NewCommitID) | ||
} | ||
|
||
commits := repo_module.NewPushCommits() | ||
commits.HeadCommit = repo_module.CommitToPushCommit(newCommit) | ||
commits.CompareURL = repo.ComposeCompareURL(objectFormat.EmptyObjectID().String(), opts.NewCommitID) | ||
|
||
notify_service.PushCommits( | ||
ctx, pusher, repo, | ||
&repo_module.PushUpdateOptions{ | ||
RefFullName: opts.RefFullName, | ||
OldCommitID: objectFormat.EmptyObjectID().String(), | ||
NewCommitID: opts.NewCommitID, | ||
}, commits) | ||
|
||
addTags = append(addTags, tagName) | ||
notify_service.CreateRef(ctx, pusher, repo, opts.RefFullName, opts.NewCommitID) | ||
} | ||
} else if opts.RefFullName.IsBranch() { | ||
if pusher == nil || pusher.ID != opts.PusherID { | ||
|
Uh oh!
There was an error while loading. Please reload this page.