|
4 | 4 | package repository
|
5 | 5 |
|
6 | 6 | import (
|
| 7 | + "code.gitea.io/gitea/modules/util" |
7 | 8 | "context"
|
8 | 9 | "errors"
|
9 | 10 | "fmt"
|
@@ -133,23 +134,26 @@ func pushUpdates(optsList []*repo_module.PushUpdateOptions) error {
|
133 | 134 | } else { // is new tag
|
134 | 135 | newCommit, err := gitRepo.GetCommit(opts.NewCommitID)
|
135 | 136 | if err != nil {
|
136 |
| - return fmt.Errorf("gitRepo.GetCommit(%s) in %s/%s[%d]: %w", opts.NewCommitID, repo.OwnerName, repo.Name, repo.ID, err) |
| 137 | + // in case there is dirty data, for example, the "github.com/git/git" repository has tags points to non-existing commits |
| 138 | + if !errors.Is(err, util.ErrNotExist) { |
| 139 | + log.Error("Unable to get tag commit: gitRepo.GetCommit(%s) in %s/%s[%d]: %v", opts.NewCommitID, repo.OwnerName, repo.Name, repo.ID, err) |
| 140 | + } |
| 141 | + } else { |
| 142 | + commits := repo_module.NewPushCommits() |
| 143 | + commits.HeadCommit = repo_module.CommitToPushCommit(newCommit) |
| 144 | + commits.CompareURL = repo.ComposeCompareURL(objectFormat.EmptyObjectID().String(), opts.NewCommitID) |
| 145 | + |
| 146 | + notify_service.PushCommits( |
| 147 | + ctx, pusher, repo, |
| 148 | + &repo_module.PushUpdateOptions{ |
| 149 | + RefFullName: opts.RefFullName, |
| 150 | + OldCommitID: objectFormat.EmptyObjectID().String(), |
| 151 | + NewCommitID: opts.NewCommitID, |
| 152 | + }, commits) |
| 153 | + |
| 154 | + addTags = append(addTags, tagName) |
| 155 | + notify_service.CreateRef(ctx, pusher, repo, opts.RefFullName, opts.NewCommitID) |
137 | 156 | }
|
138 |
| - |
139 |
| - commits := repo_module.NewPushCommits() |
140 |
| - commits.HeadCommit = repo_module.CommitToPushCommit(newCommit) |
141 |
| - commits.CompareURL = repo.ComposeCompareURL(objectFormat.EmptyObjectID().String(), opts.NewCommitID) |
142 |
| - |
143 |
| - notify_service.PushCommits( |
144 |
| - ctx, pusher, repo, |
145 |
| - &repo_module.PushUpdateOptions{ |
146 |
| - RefFullName: opts.RefFullName, |
147 |
| - OldCommitID: objectFormat.EmptyObjectID().String(), |
148 |
| - NewCommitID: opts.NewCommitID, |
149 |
| - }, commits) |
150 |
| - |
151 |
| - addTags = append(addTags, tagName) |
152 |
| - notify_service.CreateRef(ctx, pusher, repo, opts.RefFullName, opts.NewCommitID) |
153 | 157 | }
|
154 | 158 | } else if opts.RefFullName.IsBranch() {
|
155 | 159 | if pusher == nil || pusher.ID != opts.PusherID {
|
|
0 commit comments