mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
Add tag protection manage via rest API. --------- Co-authored-by: Alexander Kogay <kogay.a@citilink.ru> Co-authored-by: Giteabot <teabot@gitea.io>
This commit is contained in:
@@ -408,6 +408,32 @@ func ToAnnotatedTagObject(repo *repo_model.Repository, commit *git.Commit) *api.
|
||||
}
|
||||
}
|
||||
|
||||
// ToTagProtection convert a git.ProtectedTag to an api.TagProtection
|
||||
func ToTagProtection(ctx context.Context, pt *git_model.ProtectedTag, repo *repo_model.Repository) *api.TagProtection {
|
||||
readers, err := access_model.GetRepoReaders(ctx, repo)
|
||||
if err != nil {
|
||||
log.Error("GetRepoReaders: %v", err)
|
||||
}
|
||||
|
||||
whitelistUsernames := getWhitelistEntities(readers, pt.AllowlistUserIDs)
|
||||
|
||||
teamReaders, err := organization.OrgFromUser(repo.Owner).TeamsWithAccessToRepo(ctx, repo.ID, perm.AccessModeRead)
|
||||
if err != nil {
|
||||
log.Error("Repo.Owner.TeamsWithAccessToRepo: %v", err)
|
||||
}
|
||||
|
||||
whitelistTeams := getWhitelistEntities(teamReaders, pt.AllowlistTeamIDs)
|
||||
|
||||
return &api.TagProtection{
|
||||
ID: pt.ID,
|
||||
NamePattern: pt.NamePattern,
|
||||
WhitelistUsernames: whitelistUsernames,
|
||||
WhitelistTeams: whitelistTeams,
|
||||
Created: pt.CreatedUnix.AsTime(),
|
||||
Updated: pt.UpdatedUnix.AsTime(),
|
||||
}
|
||||
}
|
||||
|
||||
// ToTopicResponse convert from models.Topic to api.TopicResponse
|
||||
func ToTopicResponse(topic *repo_model.Topic) *api.TopicResponse {
|
||||
return &api.TopicResponse{
|
||||
|
Reference in New Issue
Block a user