diff options
author | Bian Jiaping <ssbianjp@gmail.com> | 2022-07-15 16:00:01 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-15 16:00:01 +0800 |
commit | e49ef56dde11e87ec5d43a001dfe59c57b21441c (patch) | |
tree | a607f0a9b8a0e2bf17dacb3ce7083d4fc629f58b /modules/convert | |
parent | edd945bca386929a0d0e5cfbc5fe1b225d64dd71 (diff) | |
download | gitea-e49ef56dde11e87ec5d43a001dfe59c57b21441c.tar.gz gitea-e49ef56dde11e87ec5d43a001dfe59c57b21441c.zip |
Add allow_rebase_update, default_delete_branch_after_merge to repository api response (#20079)
`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.
Diffstat (limited to 'modules/convert')
-rw-r--r-- | modules/convert/repository.go | 102 |
1 files changed, 54 insertions, 48 deletions
diff --git a/modules/convert/repository.go b/modules/convert/repository.go index eb6bb37707..d333c124b5 100644 --- a/modules/convert/repository.go +++ b/modules/convert/repository.go @@ -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, } } |