Skip to content

Commit 57b8d63

Browse files
committed
fix
1 parent 403775e commit 57b8d63

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

services/repository/push.go

+17-16
Original file line numberDiff line numberDiff line change
@@ -133,23 +133,24 @@ func pushUpdates(optsList []*repo_module.PushUpdateOptions) error {
133133
} else { // is new tag
134134
newCommit, err := gitRepo.GetCommit(opts.NewCommitID)
135135
if err != nil {
136-
return fmt.Errorf("gitRepo.GetCommit(%s) in %s/%s[%d]: %w", opts.NewCommitID, repo.OwnerName, repo.Name, repo.ID, err)
136+
// in case there is dirty data, for example, the "github.com/git/git" repository has tags points to non-existing commits
137+
log.Error("Unable to get tag commit: gitRepo.GetCommit(%s) in %s/%s[%d]: %v", opts.NewCommitID, repo.OwnerName, repo.Name, repo.ID, err)
138+
} else {
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)
137153
}
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)
153154
}
154155
} else if opts.RefFullName.IsBranch() {
155156
if pusher == nil || pusher.ID != opts.PusherID {

0 commit comments

Comments
 (0)