]> source.dussan.org Git - gitea.git/commitdiff
Add allow_rebase_update, default_delete_branch_after_merge to repository api response...
authorBian Jiaping <ssbianjp@gmail.com>
Fri, 15 Jul 2022 08:00:01 +0000 (16:00 +0800)
committerGitHub <noreply@github.com>
Fri, 15 Jul 2022 08:00:01 +0000 (16:00 +0800)
`PATCH /repos/{owner}/{repo}` API allows users to update `allow_rebase_update`, `default_delete_branch_after_merge`, but `GET /repos/{owner}/{repo}` API does not return these two options, and API users has no other ways to find the state of these two options.

This PR add `allow_rebase_update`, `default_delete_branch_after_merge` to repository query api response.

modules/convert/repository.go
modules/structs/repo.go
templates/swagger/v1_json.tmpl

index eb6bb377073914e58bcc417b28e5940d56e7ec8f..d333c124b54c631b6b72ea2caec7873f5a559932 100644 (file)
@@ -78,6 +78,8 @@ func innerToRepo(repo *repo_model.Repository, mode perm.AccessMode, isParent boo
        allowRebase := false
        allowRebaseMerge := false
        allowSquash := false
+       allowRebaseUpdate := false
+       defaultDeleteBranchAfterMerge := false
        defaultMergeStyle := repo_model.MergeStyleMerge
        if unit, err := repo.GetUnit(unit_model.TypePullRequests); err == nil {
                config := unit.PullRequestsConfig()
@@ -87,6 +89,8 @@ func innerToRepo(repo *repo_model.Repository, mode perm.AccessMode, isParent boo
                allowRebase = config.AllowRebase
                allowRebaseMerge = config.AllowRebaseMerge
                allowSquash = config.AllowSquash
+               allowRebaseUpdate = config.AllowRebaseUpdate
+               defaultDeleteBranchAfterMerge = config.DefaultDeleteBranchAfterMerge
                defaultMergeStyle = config.GetDefaultMergeStyle()
        }
        hasProjects := false
@@ -133,54 +137,56 @@ func innerToRepo(repo *repo_model.Repository, mode perm.AccessMode, isParent boo
        repoAPIURL := repo.APIURL()
 
        return &api.Repository{
-               ID:                        repo.ID,
-               Owner:                     ToUserWithAccessMode(repo.Owner, mode),
-               Name:                      repo.Name,
-               FullName:                  repo.FullName(),
-               Description:               repo.Description,
-               Private:                   repo.IsPrivate,
-               Template:                  repo.IsTemplate,
-               Empty:                     repo.IsEmpty,
-               Archived:                  repo.IsArchived,
-               Size:                      int(repo.Size / 1024),
-               Fork:                      repo.IsFork,
-               Parent:                    parent,
-               Mirror:                    repo.IsMirror,
-               HTMLURL:                   repo.HTMLURL(),
-               SSHURL:                    cloneLink.SSH,
-               CloneURL:                  cloneLink.HTTPS,
-               OriginalURL:               repo.SanitizedOriginalURL(),
-               Website:                   repo.Website,
-               Language:                  language,
-               LanguagesURL:              repoAPIURL + "/languages",
-               Stars:                     repo.NumStars,
-               Forks:                     repo.NumForks,
-               Watchers:                  repo.NumWatches,
-               OpenIssues:                repo.NumOpenIssues,
-               OpenPulls:                 repo.NumOpenPulls,
-               Releases:                  int(numReleases),
-               DefaultBranch:             repo.DefaultBranch,
-               Created:                   repo.CreatedUnix.AsTime(),
-               Updated:                   repo.UpdatedUnix.AsTime(),
-               Permissions:               permission,
-               HasIssues:                 hasIssues,
-               ExternalTracker:           externalTracker,
-               InternalTracker:           internalTracker,
-               HasWiki:                   hasWiki,
-               HasProjects:               hasProjects,
-               ExternalWiki:              externalWiki,
-               HasPullRequests:           hasPullRequests,
-               IgnoreWhitespaceConflicts: ignoreWhitespaceConflicts,
-               AllowMerge:                allowMerge,
-               AllowRebase:               allowRebase,
-               AllowRebaseMerge:          allowRebaseMerge,
-               AllowSquash:               allowSquash,
-               DefaultMergeStyle:         string(defaultMergeStyle),
-               AvatarURL:                 repo.AvatarLink(),
-               Internal:                  !repo.IsPrivate && repo.Owner.Visibility == api.VisibleTypePrivate,
-               MirrorInterval:            mirrorInterval,
-               MirrorUpdated:             mirrorUpdated,
-               RepoTransfer:              transfer,
+               ID:                            repo.ID,
+               Owner:                         ToUserWithAccessMode(repo.Owner, mode),
+               Name:                          repo.Name,
+               FullName:                      repo.FullName(),
+               Description:                   repo.Description,
+               Private:                       repo.IsPrivate,
+               Template:                      repo.IsTemplate,
+               Empty:                         repo.IsEmpty,
+               Archived:                      repo.IsArchived,
+               Size:                          int(repo.Size / 1024),
+               Fork:                          repo.IsFork,
+               Parent:                        parent,
+               Mirror:                        repo.IsMirror,
+               HTMLURL:                       repo.HTMLURL(),
+               SSHURL:                        cloneLink.SSH,
+               CloneURL:                      cloneLink.HTTPS,
+               OriginalURL:                   repo.SanitizedOriginalURL(),
+               Website:                       repo.Website,
+               Language:                      language,
+               LanguagesURL:                  repoAPIURL + "/languages",
+               Stars:                         repo.NumStars,
+               Forks:                         repo.NumForks,
+               Watchers:                      repo.NumWatches,
+               OpenIssues:                    repo.NumOpenIssues,
+               OpenPulls:                     repo.NumOpenPulls,
+               Releases:                      int(numReleases),
+               DefaultBranch:                 repo.DefaultBranch,
+               Created:                       repo.CreatedUnix.AsTime(),
+               Updated:                       repo.UpdatedUnix.AsTime(),
+               Permissions:                   permission,
+               HasIssues:                     hasIssues,
+               ExternalTracker:               externalTracker,
+               InternalTracker:               internalTracker,
+               HasWiki:                       hasWiki,
+               HasProjects:                   hasProjects,
+               ExternalWiki:                  externalWiki,
+               HasPullRequests:               hasPullRequests,
+               IgnoreWhitespaceConflicts:     ignoreWhitespaceConflicts,
+               AllowMerge:                    allowMerge,
+               AllowRebase:                   allowRebase,
+               AllowRebaseMerge:              allowRebaseMerge,
+               AllowSquash:                   allowSquash,
+               AllowRebaseUpdate:             allowRebaseUpdate,
+               DefaultDeleteBranchAfterMerge: defaultDeleteBranchAfterMerge,
+               DefaultMergeStyle:             string(defaultMergeStyle),
+               AvatarURL:                     repo.AvatarLink(),
+               Internal:                      !repo.IsPrivate && repo.Owner.Visibility == api.VisibleTypePrivate,
+               MirrorInterval:                mirrorInterval,
+               MirrorUpdated:                 mirrorUpdated,
+               RepoTransfer:                  transfer,
        }
 }
 
index ef247ebc9ce3a66e5128316be315f6b60aa4431c..6a5736898d13930e5683e75a5e5f0b7ba2903af4 100644 (file)
@@ -77,24 +77,26 @@ type Repository struct {
        // swagger:strfmt date-time
        Created time.Time `json:"created_at"`
        // swagger:strfmt date-time
-       Updated                   time.Time        `json:"updated_at"`
-       Permissions               *Permission      `json:"permissions,omitempty"`
-       HasIssues                 bool             `json:"has_issues"`
-       InternalTracker           *InternalTracker `json:"internal_tracker,omitempty"`
-       ExternalTracker           *ExternalTracker `json:"external_tracker,omitempty"`
-       HasWiki                   bool             `json:"has_wiki"`
-       ExternalWiki              *ExternalWiki    `json:"external_wiki,omitempty"`
-       HasPullRequests           bool             `json:"has_pull_requests"`
-       HasProjects               bool             `json:"has_projects"`
-       IgnoreWhitespaceConflicts bool             `json:"ignore_whitespace_conflicts"`
-       AllowMerge                bool             `json:"allow_merge_commits"`
-       AllowRebase               bool             `json:"allow_rebase"`
-       AllowRebaseMerge          bool             `json:"allow_rebase_explicit"`
-       AllowSquash               bool             `json:"allow_squash_merge"`
-       DefaultMergeStyle         string           `json:"default_merge_style"`
-       AvatarURL                 string           `json:"avatar_url"`
-       Internal                  bool             `json:"internal"`
-       MirrorInterval            string           `json:"mirror_interval"`
+       Updated                       time.Time        `json:"updated_at"`
+       Permissions                   *Permission      `json:"permissions,omitempty"`
+       HasIssues                     bool             `json:"has_issues"`
+       InternalTracker               *InternalTracker `json:"internal_tracker,omitempty"`
+       ExternalTracker               *ExternalTracker `json:"external_tracker,omitempty"`
+       HasWiki                       bool             `json:"has_wiki"`
+       ExternalWiki                  *ExternalWiki    `json:"external_wiki,omitempty"`
+       HasPullRequests               bool             `json:"has_pull_requests"`
+       HasProjects                   bool             `json:"has_projects"`
+       IgnoreWhitespaceConflicts     bool             `json:"ignore_whitespace_conflicts"`
+       AllowMerge                    bool             `json:"allow_merge_commits"`
+       AllowRebase                   bool             `json:"allow_rebase"`
+       AllowRebaseMerge              bool             `json:"allow_rebase_explicit"`
+       AllowSquash                   bool             `json:"allow_squash_merge"`
+       AllowRebaseUpdate             bool             `json:"allow_rebase_update"`
+       DefaultDeleteBranchAfterMerge bool             `json:"default_delete_branch_after_merge"`
+       DefaultMergeStyle             string           `json:"default_merge_style"`
+       AvatarURL                     string           `json:"avatar_url"`
+       Internal                      bool             `json:"internal"`
+       MirrorInterval                string           `json:"mirror_interval"`
        // swagger:strfmt date-time
        MirrorUpdated time.Time     `json:"mirror_updated,omitempty"`
        RepoTransfer  *RepoTransfer `json:"repo_transfer"`
index 39c5026b77ad7c96aa42c1af615b7490dc71a868..4b24cb729db82ba1ce118e9b5a35be3cea27b2be 100644 (file)
           "type": "boolean",
           "x-go-name": "AllowRebaseMerge"
         },
+        "allow_rebase_update": {
+          "type": "boolean",
+          "x-go-name": "AllowRebaseUpdate"
+        },
         "allow_squash_merge": {
           "type": "boolean",
           "x-go-name": "AllowSquash"
           "type": "string",
           "x-go-name": "DefaultBranch"
         },
+        "default_delete_branch_after_merge": {
+          "type": "boolean",
+          "x-go-name": "DefaultDeleteBranchAfterMerge"
+        },
         "default_merge_style": {
           "type": "string",
           "x-go-name": "DefaultMergeStyle"