Repository: google/go-github
File: github/repos_tags.go (Go)

Code before:
// Copyright 2022 The go-github AUTHORS. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package github

import (
	"context"
	"fmt"
)

// TagProtection represents a repository tag protection.
type TagProtection struct {
	ID      *int64  `json:"id"`
	Pattern *string `json:"pattern"`
}

// tagProtectionRequest represents a request to create tag protection.
type tagProtectionRequest struct {
	// An optional glob pattern to match against when enforcing tag protection.
	Pattern string `json:"pattern"`
}

// ListTagProtection lists tag protection of the specified repository.
// Deprecated: This operation is deprecated and will be removed after August 30, 2024. Use the "Repository Rulesets" endpoint instead: https://docs.github.com/rest/repos/rules#get-all-repository-rulesets
//
// GitHub API docs: https://docs.github.com/rest/repos/tags#closing-down---list-tag-protection-states-for-a-repository
//
//meta:operation GET /repos/{owner}/{repo}/tags/protection
func (s *RepositoriesService) ListTagProtection(ctx context.Context, owner, repo string) ([]*TagProtection, *Response, error) {
	u := fmt.Sprintf("repos/%v/%v/tags/protection", owner, repo)

	req, err := s.client.NewRequest("GET", u, nil)
	if err != nil {
		return nil, nil, err
	}

	var tagProtections []*TagProtection
	resp, err := s.client.Do(ctx, req, &tagProtections)
	if err != nil {
		return nil, resp, err
	}

	return tagProtections, resp, nil
}

// CreateTagProtection creates the tag protection of the specified repository.
// Deprecated: This operation is deprecated and will be removed after August 30, 2024. Use the "Repository Rulesets" endpoint instead: https://docs.github.com/rest/repos/rules#create-a-repository-ruleset
//
// GitHub API docs: https://docs.github.com/rest/repos/tags#closing-down---create-a-tag-protection-state-for-a-repository

Review comment (suggestion):

```suggestion
// ListTagProtection lists tag protection of the specified repository.
//
// Deprecated: This operation is deprecated and will be removed after August 30, 2024. Use the "Repository Rulesets" endpoint instead: https://docs.github.com/rest/repos/rules#get-all-repository-rulesets

```

There must be an empty line before `Deprecated:` to be properly recognized with pkg.go.dev.

Without empty line:

<img width="1146" height="208" alt="image" src="https://github.com/user-attachments/assets/1e7d31f0-9e8d-4d58-a10d-a5f492a6c19d" />

With empty line:

<img width="1157" height="270" alt="image" src="https://github.com/user-attachments/assets/eac389dc-eb9d-4f32-9913-4d9f9963b477" />


Code after:
// Copyright 2022 The go-github AUTHORS. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package github

import (
	"context"
	"fmt"
)

// TagProtection represents a repository tag protection.
type TagProtection struct {
	ID      *int64  `json:"id"`
	Pattern *string `json:"pattern"`
}

// tagProtectionRequest represents a request to create tag protection.
type tagProtectionRequest struct {
	// An optional glob pattern to match against when enforcing tag protection.
	Pattern string `json:"pattern"`
}

// ListTagProtection lists tag protection of the specified repository.
//
// Deprecated: This operation is deprecated and will be removed after August 30, 2024. Use the "Repository Rulesets" endpoint instead: https://docs.github.com/rest/repos/rules#get-all-repository-rulesets
//
// GitHub API docs: https://docs.github.com/rest/repos/tags#closing-down---list-tag-protection-states-for-a-repository
//
//meta:operation GET /repos/{owner}/{repo}/tags/protection
func (s *RepositoriesService) ListTagProtection(ctx context.Context, owner, repo string) ([]*TagProtection, *Response, error) {
	u := fmt.Sprintf("repos/%v/%v/tags/protection", owner, repo)

	req, err := s.client.NewRequest("GET", u, nil)
	if err != nil {
		return nil, nil, err
	}

	var tagProtections []*TagProtection
	resp, err := s.client.Do(ctx, req, &tagProtections)
	if err != nil {
		return nil, resp, err
	}

	return tagProtections, resp, nil
}

// CreateTagProtection creates the tag protection of the specified repository.
//
// Deprecated: This operation is deprecated and will be removed after August 30, 2024. Use the "Repository Rulesets" endpoint instead: https://docs.github.com/rest/repos/rules#create-a-repository-ruleset