MCPcopy Create free account
hub / github.com/cli/cli / checkTagProtection

Function checkTagProtection

pkg/cmd/skills/publish/publish.go:758–781  ·  view source on GitHub ↗

checkTagProtection checks whether tag protection rulesets are enabled.

(client *api.Client, host, owner, repo string)

Source from the content-addressed store, hash-verified

756
757// checkTagProtection checks whether tag protection rulesets are enabled.
758func checkTagProtection(client *api.Client, host, owner, repo string) []publishDiagnostic {
759 if client == nil {
760 return nil
761 }
762 apiPath, err := safeurl.JoinPath("repos", owner, repo, "rulesets")
763 if err != nil {
764 return nil
765 }
766 var rulesets []rulesetsResponse
767 if err := client.REST(host, "GET", apiPath.String(), nil, &rulesets); err != nil {
768 return nil
769 }
770
771 for _, rs := range rulesets {
772 if rs.Target == "tag" && rs.Enforcement == "active" {
773 return nil
774 }
775 }
776
777 return []publishDiagnostic{{
778 severity: "warning",
779 message: "no active tag protection rulesets found. Consider protecting tags to ensure immutable releases (Settings > Rules > Rulesets)",
780 }}
781}
782
783// checkSecuritySettings checks whether recommended security features are enabled.
784func checkSecuritySettings(client *api.Client, host, owner, repo string, skillDirs []string) []publishDiagnostic {

Callers 1

publishRunFunction · 0.85

Calls 3

JoinPathFunction · 0.92
RESTMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected