MCPcopy Create free account
hub / github.com/gogs/gogs / PushTag

Method PushTag

internal/database/actions.go:610–680  ·  view source on GitHub ↗

PushTag creates an action for pushing tags to the repository. An action with the type ActionDeleteTag is created if the push deletes a tag. Otherwise, an action with the type ActionPushTag is created for a regular push.

(ctx context.Context, opts PushTagOptions)

Source from the content-addressed store, hash-verified

608// the type ActionDeleteTag is created if the push deletes a tag. Otherwise, an
609// action with the type ActionPushTag is created for a regular push.
610func (s *ActionsStore) PushTag(ctx context.Context, opts PushTagOptions) error {
611 err := newReposStore(s.db).Touch(ctx, opts.Repo.ID)
612 if err != nil {
613 return errors.Wrap(err, "touch repository")
614 }
615
616 pusher, err := newUsersStore(s.db).GetByUsername(ctx, opts.PusherName)
617 if err != nil {
618 return errors.Wrapf(err, "get pusher [name: %s]", opts.PusherName)
619 }
620
621 refName := git.RefShortName(opts.RefFullName)
622 action := &Action{
623 ActUserID: pusher.ID,
624 ActUserName: pusher.Name,
625 RepoID: opts.Repo.ID,
626 RepoUserName: opts.Owner.Name,
627 RepoName: opts.Repo.Name,
628 RefName: refName,
629 IsPrivate: opts.Repo.IsPrivate || opts.Repo.IsUnlisted,
630 }
631
632 apiRepo := opts.Repo.APIFormat(opts.Owner)
633 apiPusher := pusher.APIFormat()
634 if opts.NewCommitID == git.EmptyID {
635 err = PrepareWebhooks(
636 opts.Repo,
637 HookEventTypeDelete,
638 &api.DeletePayload{
639 Ref: refName,
640 RefType: "tag",
641 PusherType: api.PUSHER_TYPE_USER,
642 Repo: apiRepo,
643 Sender: apiPusher,
644 },
645 )
646 if err != nil {
647 return errors.Wrap(err, "prepare webhooks for delete tag")
648 }
649
650 action.OpType = ActionDeleteTag
651 err = s.notifyWatchers(ctx, action)
652 if err != nil {
653 return errors.Wrap(err, "notify watchers")
654 }
655 return nil
656 }
657
658 err = PrepareWebhooks(
659 opts.Repo,
660 HookEventTypeCreate,
661 &api.CreatePayload{
662 Ref: refName,
663 RefType: "tag",
664 Sha: opts.NewCommitID,
665 DefaultBranch: opts.Repo.DefaultBranch,
666 Repo: apiRepo,
667 Sender: apiPusher,

Callers 2

actionsPushTagFunction · 0.80
PushUpdateFunction · 0.80

Calls 7

notifyWatchersMethod · 0.95
newReposStoreFunction · 0.85
newUsersStoreFunction · 0.85
PrepareWebhooksFunction · 0.85
GetByUsernameMethod · 0.80
TouchMethod · 0.45
APIFormatMethod · 0.45

Tested by 1

actionsPushTagFunction · 0.64