mirror of https://github.com/harness/drone.git
feat: [CODE-2370]: changes for using PR source branch delete/restore API (#2702)
* fixed error for branch not found * swagger.yaml prettier * removed commitSha queryParam and do a getBranch to get the commitSha * fixed lint issue * Merge branch 'main' of https://git0.harness.io/l7B_kbSEQD2wjrM7PShm5w/PROD/Harness_Commons/gitness into CODE-2370-2 * added commit_sha query param to PR delete branch API * fixed linting issues * updated swagger * feat: [CODE-2370]: changes for using PR source branch delete/restore APICODE-2402
parent
4482527dbf
commit
8bc9714c92
|
@ -22,6 +22,7 @@ import (
|
|||
"github.com/harness/gitness/app/api/usererror"
|
||||
"github.com/harness/gitness/app/auth"
|
||||
"github.com/harness/gitness/app/services/protection"
|
||||
"github.com/harness/gitness/errors"
|
||||
"github.com/harness/gitness/git"
|
||||
"github.com/harness/gitness/types"
|
||||
"github.com/harness/gitness/types/enum"
|
||||
|
@ -34,7 +35,7 @@ func (c *Controller) DeleteBranch(ctx context.Context,
|
|||
session *auth.Session,
|
||||
repoRef string,
|
||||
pullreqNum int64,
|
||||
bypassRules bool,
|
||||
bypassRules,
|
||||
dryRunRules bool,
|
||||
) (types.DeleteBranchOutput, []types.RuleViolations, error) {
|
||||
repo, err := c.getRepoCheckAccess(ctx, session, repoRef, enum.PermissionRepoPush)
|
||||
|
@ -88,10 +89,32 @@ func (c *Controller) DeleteBranch(ctx context.Context,
|
|||
return types.DeleteBranchOutput{}, nil, fmt.Errorf("failed to create RPC write params: %w", err)
|
||||
}
|
||||
|
||||
branch, err := func() (types.Branch, error) {
|
||||
rpcOut, err := c.git.GetBranch(ctx, &git.GetBranchParams{
|
||||
ReadParams: git.CreateReadParams(repo),
|
||||
BranchName: branchName,
|
||||
})
|
||||
if err != nil {
|
||||
return types.Branch{}, fmt.Errorf("failed to fetch source branch: %w", err)
|
||||
}
|
||||
|
||||
mappedBranch, err := controller.MapBranch(rpcOut.Branch)
|
||||
if err != nil {
|
||||
return types.Branch{}, fmt.Errorf("failed to map source branch: %w", err)
|
||||
}
|
||||
return mappedBranch, nil
|
||||
}()
|
||||
if err != nil {
|
||||
return types.DeleteBranchOutput{}, nil, err
|
||||
}
|
||||
if pr.SourceSHA != branch.SHA {
|
||||
return types.DeleteBranchOutput{}, nil, errors.Conflict("source branch SHA does not match pull request source SHA")
|
||||
}
|
||||
|
||||
err = c.git.DeleteBranch(ctx, &git.DeleteBranchParams{
|
||||
WriteParams: writeParams,
|
||||
BranchName: branchName,
|
||||
SHA: pr.SourceSHA,
|
||||
SHA: branch.SHA,
|
||||
})
|
||||
if err != nil {
|
||||
return types.DeleteBranchOutput{}, nil, err
|
||||
|
@ -103,7 +126,7 @@ func (c *Controller) DeleteBranch(ctx context.Context,
|
|||
}
|
||||
|
||||
_, err := c.activityStore.CreateWithPayload(ctx, pr, session.Principal.ID,
|
||||
&types.PullRequestActivityPayloadBranchDelete{SHA: pr.SourceSHA}, nil)
|
||||
&types.PullRequestActivityPayloadBranchDelete{SHA: branch.SHA}, nil)
|
||||
return err
|
||||
}()
|
||||
if err != nil {
|
||||
|
|
|
@ -32,9 +32,8 @@ func (c *Controller) DeleteBranch(ctx context.Context,
|
|||
session *auth.Session,
|
||||
repoRef string,
|
||||
branchName string,
|
||||
bypassRules bool,
|
||||
bypassRules,
|
||||
dryRunRules bool,
|
||||
commitSha string,
|
||||
) (types.DeleteBranchOutput, []types.RuleViolations, error) {
|
||||
repo, err := c.getRepoCheckAccess(ctx, session, repoRef, enum.PermissionRepoPush)
|
||||
if err != nil {
|
||||
|
@ -88,7 +87,6 @@ func (c *Controller) DeleteBranch(ctx context.Context,
|
|||
err = c.git.DeleteBranch(ctx, &git.DeleteBranchParams{
|
||||
WriteParams: writeParams,
|
||||
BranchName: branchName,
|
||||
SHA: commitSha,
|
||||
})
|
||||
if err != nil {
|
||||
return types.DeleteBranchOutput{}, nil, err
|
||||
|
|
|
@ -52,9 +52,7 @@ func HandleDeleteBranch(repoCtrl *repo.Controller) http.HandlerFunc {
|
|||
return
|
||||
}
|
||||
|
||||
commitSha := request.GetCommitSHAFromQueryOrDefault(r)
|
||||
|
||||
out, violations, err := repoCtrl.DeleteBranch(ctx, session, repoRef, branchName, bypassRules, dryRunRules, commitSha)
|
||||
out, violations, err := repoCtrl.DeleteBranch(ctx, session, repoRef, branchName, bypassRules, dryRunRules)
|
||||
if err != nil {
|
||||
render.TranslatedUserError(ctx, w, err)
|
||||
return
|
||||
|
|
|
@ -542,20 +542,6 @@ var queryParameterDryRunRules = openapi3.ParameterOrRef{
|
|||
},
|
||||
}
|
||||
|
||||
var queryParameterCommitSHA = openapi3.ParameterOrRef{
|
||||
Parameter: &openapi3.Parameter{
|
||||
Name: request.QueryParamCommitSHA,
|
||||
In: openapi3.ParameterInQuery,
|
||||
Description: ptr.String("Commit SHA the branch is at"),
|
||||
Required: ptr.Bool(false),
|
||||
Schema: &openapi3.SchemaOrRef{
|
||||
Schema: &openapi3.Schema{
|
||||
Type: ptrSchemaType(openapi3.SchemaTypeString),
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
var queryParameterDeletedAt = openapi3.ParameterOrRef{
|
||||
Parameter: &openapi3.Parameter{
|
||||
Name: request.QueryParamDeletedAt,
|
||||
|
@ -936,7 +922,7 @@ func repoOperations(reflector *openapi3.Reflector) {
|
|||
opDeleteBranch := openapi3.Operation{}
|
||||
opDeleteBranch.WithTags("repository")
|
||||
opDeleteBranch.WithMapOfAnything(map[string]interface{}{"operationId": "deleteBranch"})
|
||||
opDeleteBranch.WithParameters(queryParameterBypassRules, queryParameterDryRunRules, queryParameterCommitSHA)
|
||||
opDeleteBranch.WithParameters(queryParameterBypassRules, queryParameterDryRunRules)
|
||||
_ = reflector.SetRequest(&opDeleteBranch, new(deleteBranchRequest), http.MethodDelete)
|
||||
_ = reflector.SetJSONResponse(&opDeleteBranch, new(types.DeleteBranchOutput), http.StatusOK)
|
||||
_ = reflector.SetJSONResponse(&opDeleteBranch, new(usererror.Error), http.StatusInternalServerError)
|
||||
|
|
|
@ -34,6 +34,7 @@ export enum CommentType {
|
|||
MERGE = 'merge',
|
||||
BRANCH_UPDATE = 'branch-update',
|
||||
BRANCH_DELETE = 'branch-delete',
|
||||
BRANCH_RESTORE = 'branch-restore',
|
||||
STATE_CHANGE = 'state-change',
|
||||
LABEL_MODIFY = 'label-modify'
|
||||
}
|
||||
|
|
|
@ -808,6 +808,7 @@ export interface StringsMap {
|
|||
'pr.prBranchDeleteInfo': string
|
||||
'pr.prBranchForcePushInfo': string
|
||||
'pr.prBranchPushInfo': string
|
||||
'pr.prBranchRestoreInfo': string
|
||||
'pr.prCanBeMerged': string
|
||||
'pr.prClosed': string
|
||||
'pr.prMerged': string
|
||||
|
|
|
@ -321,6 +321,7 @@ pr:
|
|||
prBranchPushInfo: '{user} pushed a new commit {commit}'
|
||||
prBranchForcePushInfo: '{user} force-pushed the {gitRef} branch from {oldCommit} to {newCommit}'
|
||||
prBranchDeleteInfo: '{user} deleted the source branch with latest commit {commit}'
|
||||
prBranchRestoreInfo: '{user} restored the source branch with latest commit {commit}'
|
||||
prStateChanged: '{user} changed pull request state from {old} to {new}.'
|
||||
prStateChangedDraft: '{user} {changedToDraft|true:marked pull request as draft.,opened pull request for review.}'
|
||||
titleChanged: '{user} changed title from {old} to {new}.'
|
||||
|
|
|
@ -38,7 +38,7 @@ import cx from 'classnames'
|
|||
import ReactTimeago from 'react-timeago'
|
||||
import type {
|
||||
CreateBranchPathParams,
|
||||
DeleteBranchQueryParams,
|
||||
DeletePullReqSourceBranchQueryParams,
|
||||
OpenapiCreateBranchRequest,
|
||||
OpenapiStatePullReqRequest,
|
||||
TypesListCommitResponse,
|
||||
|
@ -77,7 +77,7 @@ export interface PullRequestActionsBoxProps extends Pick<GitInfoProps, 'repoMeta
|
|||
refetchActivities: () => void
|
||||
createBranch: MutateMethod<any, any, OpenapiCreateBranchRequest, CreateBranchPathParams>
|
||||
refetchBranch: () => Promise<void>
|
||||
deleteBranch: MutateMethod<any, any, DeleteBranchQueryParams, unknown>
|
||||
deleteBranch: MutateMethod<any, any, DeletePullReqSourceBranchQueryParams, unknown>
|
||||
showRestoreBranchButton: boolean
|
||||
showDeleteBranchButton: boolean
|
||||
setShowDeleteBranchButton: React.Dispatch<React.SetStateAction<boolean>>
|
||||
|
@ -270,6 +270,7 @@ export const PullRequestActionsBox: React.FC<PullRequestActionsBoxProps> = ({
|
|||
showDeleteBranchButton={showDeleteBranchButton}
|
||||
setShowDeleteBranchButton={setShowDeleteBranchButton}
|
||||
setShowRestoreBranchButton={setShowRestoreBranchButton}
|
||||
refetchActivities={refetchActivities}
|
||||
refetchBranch={refetchBranch}
|
||||
createBranch={createBranch}
|
||||
deleteBranch={deleteBranch}
|
||||
|
@ -549,9 +550,10 @@ const MergeInfo: React.FC<{
|
|||
showDeleteBranchButton: boolean
|
||||
setShowDeleteBranchButton: React.Dispatch<React.SetStateAction<boolean>>
|
||||
setShowRestoreBranchButton: React.Dispatch<React.SetStateAction<boolean>>
|
||||
refetchActivities: () => void
|
||||
refetchBranch: () => Promise<void>
|
||||
createBranch: MutateMethod<any, any, OpenapiCreateBranchRequest, CreateBranchPathParams>
|
||||
deleteBranch: MutateMethod<any, any, DeleteBranchQueryParams, unknown>
|
||||
deleteBranch: MutateMethod<any, any, DeletePullReqSourceBranchQueryParams, unknown>
|
||||
}> = props => {
|
||||
const { pullRequestMetadata, showRestoreBranchButton, showDeleteBranchButton } = props
|
||||
const { getString } = useStrings()
|
||||
|
|
|
@ -19,6 +19,7 @@ import cx from 'classnames'
|
|||
import { useGet, useMutate } from 'restful-react'
|
||||
import { Render } from 'react-jsx-match'
|
||||
import type {
|
||||
DeletePullReqSourceBranchQueryParams,
|
||||
TypesCodeOwnerEvaluation,
|
||||
TypesListCommitResponse,
|
||||
TypesPullReq,
|
||||
|
@ -26,8 +27,7 @@ import type {
|
|||
TypesPullReqReviewer,
|
||||
RepoRepositoryOutput,
|
||||
TypesRuleViolations,
|
||||
TypesBranch,
|
||||
DeleteBranchQueryParams
|
||||
TypesBranch
|
||||
} from 'services/code'
|
||||
import {
|
||||
PanelSectionOutletPosition,
|
||||
|
@ -132,13 +132,12 @@ const PullRequestOverviewPanel = (props: PullRequestOverviewPanelProps) => {
|
|||
})
|
||||
const { mutate: deleteBranch } = useMutate({
|
||||
verb: 'DELETE',
|
||||
path: `/api/v1/repos/${repoMetadata.path}/+/branches/${pullReqMetadata.source_branch}`,
|
||||
queryParams: { bypass_rules: true, dry_run_rules: true } as DeleteBranchQueryParams
|
||||
path: `/api/v1/repos/${repoMetadata.path}/+/pullreq/${pullReqMetadata.number}/branch`,
|
||||
queryParams: { bypass_rules: true, dry_run_rules: true } as DeletePullReqSourceBranchQueryParams
|
||||
})
|
||||
const { mutate: createBranch } = useMutate({
|
||||
verb: 'POST',
|
||||
path: `/api/v1/repos/${repoMetadata.path}/+/branches`,
|
||||
pathParams: { repo_ref: repoMetadata.path }
|
||||
path: `/api/v1/repos/${repoMetadata.path}/+/pullreq/${pullReqMetadata.number}/branch`
|
||||
})
|
||||
const { mutate: mergePR, loading: mergeLoading } = useMutate({
|
||||
verb: 'POST',
|
||||
|
@ -325,6 +324,7 @@ const PullRequestOverviewPanel = (props: PullRequestOverviewPanelProps) => {
|
|||
sourceBranch={sourceBranch?.name || pullReqMetadata.source_branch || ''}
|
||||
createBranch={createBranch}
|
||||
refetchBranch={refetchBranch}
|
||||
refetchActivities={refetchActivities}
|
||||
deleteBranch={deleteBranch}
|
||||
showDeleteBranchButton={showDeleteBranchButton}
|
||||
setShowRestoreBranchButton={setShowRestoreBranchButton}
|
||||
|
|
|
@ -21,15 +21,20 @@ import { Icon } from '@harnessio/icons'
|
|||
import { useStrings } from 'framework/strings'
|
||||
import { CodeIcon } from 'utils/GitUtils'
|
||||
import { getErrorMessage } from 'utils/Utils'
|
||||
import type { CreateBranchPathParams, DeleteBranchQueryParams, OpenapiCreateBranchRequest } from 'services/code'
|
||||
import type {
|
||||
CreateBranchPathParams,
|
||||
DeletePullReqSourceBranchQueryParams,
|
||||
OpenapiCreateBranchRequest
|
||||
} from 'services/code'
|
||||
import css from '../PullRequestOverviewPanel.module.scss'
|
||||
|
||||
interface BranchActionsSectionProps {
|
||||
sourceSha: string
|
||||
sourceBranch: string
|
||||
createBranch: MutateMethod<any, any, OpenapiCreateBranchRequest, CreateBranchPathParams>
|
||||
refetchActivities: () => void
|
||||
refetchBranch: () => Promise<void>
|
||||
deleteBranch: MutateMethod<any, any, DeleteBranchQueryParams, unknown>
|
||||
deleteBranch: MutateMethod<any, any, DeletePullReqSourceBranchQueryParams, unknown>
|
||||
showDeleteBranchButton: boolean
|
||||
setShowDeleteBranchButton: React.Dispatch<React.SetStateAction<boolean>>
|
||||
setShowRestoreBranchButton: React.Dispatch<React.SetStateAction<boolean>>
|
||||
|
@ -69,6 +74,7 @@ export const BranchActionsButton = ({
|
|||
sourceSha,
|
||||
sourceBranch,
|
||||
createBranch,
|
||||
refetchActivities,
|
||||
refetchBranch,
|
||||
deleteBranch,
|
||||
showDeleteBranchButton,
|
||||
|
@ -85,11 +91,12 @@ export const BranchActionsButton = ({
|
|||
variation={ButtonVariation.SECONDARY}
|
||||
onClick={() => {
|
||||
showDeleteBranchButton
|
||||
? deleteBranch({}, { queryParams: { bypass_rules: true, dry_run_rules: false, commit_sha: sourceSha } })
|
||||
? deleteBranch({}, { queryParams: { bypass_rules: true, dry_run_rules: false } })
|
||||
.then(() => {
|
||||
refetchBranch()
|
||||
setIsSourceBranchDeleted?.(true)
|
||||
setShowDeleteBranchButton(false)
|
||||
refetchActivities()
|
||||
showSuccess(
|
||||
<StringSubstitute
|
||||
str={getString('branchDeleted')}
|
||||
|
@ -106,6 +113,7 @@ export const BranchActionsButton = ({
|
|||
refetchBranch()
|
||||
setIsSourceBranchDeleted?.(false)
|
||||
setShowRestoreBranchButton(false)
|
||||
refetchActivities()
|
||||
showSuccess(
|
||||
<StringSubstitute
|
||||
str={getString('branchRestored')}
|
||||
|
|
|
@ -241,14 +241,16 @@ export const SystemComment: React.FC<SystemCommentProps> = ({ pullReqMetadata, c
|
|||
)
|
||||
}
|
||||
|
||||
case CommentType.BRANCH_DELETE: {
|
||||
case CommentType.BRANCH_DELETE:
|
||||
case CommentType.BRANCH_RESTORE: {
|
||||
const isSourceBranchDeleted = type === CommentType.BRANCH_DELETE
|
||||
return (
|
||||
<Container>
|
||||
<Layout.Horizontal spacing="small" style={{ alignItems: 'center' }} className={css.mergedBox}>
|
||||
<Avatar name={payload?.author?.display_name} size="small" hoverCard={false} />
|
||||
<Text flex tag="div">
|
||||
<StringSubstitute
|
||||
str={getString('pr.prBranchDeleteInfo')}
|
||||
str={isSourceBranchDeleted ? getString('pr.prBranchDeleteInfo') : getString('pr.prBranchRestoreInfo')}
|
||||
vars={{
|
||||
user: (
|
||||
<Text padding={{ right: 'small' }} inline>
|
||||
|
|
|
@ -26,6 +26,12 @@ export type EnumCheckPayloadKind = '' | 'markdown' | 'pipeline' | 'raw'
|
|||
|
||||
export type EnumCheckStatus = 'error' | 'failure' | 'pending' | 'running' | 'success'
|
||||
|
||||
export type EnumConnectorAuthType = 'basic' | 'bearer'
|
||||
|
||||
export type EnumConnectorStatus = 'failed' | 'success'
|
||||
|
||||
export type EnumConnectorType = 'github'
|
||||
|
||||
export type EnumContentEncodingType = 'base64' | 'utf8'
|
||||
|
||||
export type EnumFileDiffStatus = string
|
||||
|
@ -122,6 +128,7 @@ export type EnumPullReqActivityKind = 'change-comment' | 'comment' | 'system'
|
|||
|
||||
export type EnumPullReqActivityType =
|
||||
| 'branch-delete'
|
||||
| 'branch-restore'
|
||||
| 'branch-update'
|
||||
| 'code-comment'
|
||||
| 'comment'
|
||||
|
@ -353,12 +360,11 @@ export interface OpenapiCreateBranchRequest {
|
|||
}
|
||||
|
||||
export interface OpenapiCreateConnectorRequest {
|
||||
data?: string
|
||||
description?: string
|
||||
github?: TypesGithubConnectorData
|
||||
identifier?: string
|
||||
space_ref?: string
|
||||
type?: string
|
||||
uid?: string
|
||||
type?: EnumConnectorType
|
||||
}
|
||||
|
||||
export interface OpenapiCreateGitspaceRequest {
|
||||
|
@ -614,10 +620,8 @@ export interface OpenapiUpdateAdminRequest {
|
|||
}
|
||||
|
||||
export interface OpenapiUpdateConnectorRequest {
|
||||
data?: string | null
|
||||
description?: string | null
|
||||
identifier?: string | null
|
||||
uid?: string | null
|
||||
}
|
||||
|
||||
export interface OpenapiUpdateDefaultBranchRequest {
|
||||
|
@ -734,9 +738,11 @@ export interface ProtectionDefLifecycle {
|
|||
create_forbidden?: boolean
|
||||
delete_forbidden?: boolean
|
||||
update_forbidden?: boolean
|
||||
update_force_forbidden?: boolean
|
||||
}
|
||||
|
||||
export interface ProtectionDefMerge {
|
||||
block?: boolean
|
||||
delete_branch?: boolean
|
||||
strategies_allowed?: EnumMergeMethod[]
|
||||
}
|
||||
|
@ -927,6 +933,15 @@ export interface SystemConfigOutput {
|
|||
|
||||
export type TimeDuration = number | null
|
||||
|
||||
export interface TypesBasicAuthCreds {
|
||||
password?: TypesSecretRef
|
||||
username?: string
|
||||
}
|
||||
|
||||
export interface TypesBearerTokenCreds {
|
||||
token?: TypesSecretRef
|
||||
}
|
||||
|
||||
export interface TypesBranch {
|
||||
commit?: TypesCommit
|
||||
name?: string
|
||||
|
@ -1015,14 +1030,29 @@ export interface TypesCommitStats {
|
|||
|
||||
export interface TypesConnector {
|
||||
created?: number
|
||||
data?: string
|
||||
created_by?: number
|
||||
description?: string
|
||||
github?: TypesGithubConnectorData
|
||||
identifier?: string
|
||||
last_test_attempt?: number
|
||||
last_test_error_msg?: string
|
||||
last_test_status?: EnumConnectorStatus
|
||||
space_id?: number
|
||||
type?: string
|
||||
type?: EnumConnectorType
|
||||
updated?: number
|
||||
}
|
||||
|
||||
export type TypesConnectorAuth = {
|
||||
basic?: TypesBasicAuthCreds
|
||||
bearer?: TypesBearerTokenCreds
|
||||
type?: EnumConnectorAuthType
|
||||
} | null
|
||||
|
||||
export interface TypesConnectorTestResponse {
|
||||
error_msg?: string
|
||||
status?: EnumConnectorStatus
|
||||
}
|
||||
|
||||
export interface TypesCreateBranchOutput {
|
||||
commit?: TypesCommit
|
||||
dry_run_rules?: boolean
|
||||
|
@ -1083,6 +1113,12 @@ export interface TypesExecution {
|
|||
updated?: number
|
||||
}
|
||||
|
||||
export interface TypesGithubConnectorData {
|
||||
api_url?: string
|
||||
auth?: TypesConnectorAuth
|
||||
insecure?: boolean
|
||||
}
|
||||
|
||||
export interface TypesGitspaceConfig {
|
||||
branch?: string
|
||||
code_repo_is_private?: boolean
|
||||
|
@ -1347,6 +1383,7 @@ export interface TypesPullReq {
|
|||
target_branch?: string
|
||||
target_repo_id?: number
|
||||
title?: string
|
||||
updated?: number
|
||||
}
|
||||
|
||||
export interface TypesPullReqActivity {
|
||||
|
@ -1543,6 +1580,10 @@ export interface TypesSecret {
|
|||
updated?: number
|
||||
}
|
||||
|
||||
export interface TypesSecretRef {
|
||||
identifier?: string
|
||||
}
|
||||
|
||||
export interface TypesServiceAccount {
|
||||
admin?: boolean
|
||||
blocked?: boolean
|
||||
|
@ -2839,10 +2880,6 @@ export interface DeleteBranchQueryParams {
|
|||
* Dry run rules for operations
|
||||
*/
|
||||
dry_run_rules?: boolean
|
||||
/**
|
||||
* Commit SHA the branch is at
|
||||
*/
|
||||
commit_sha?: string
|
||||
}
|
||||
|
||||
export interface DeleteBranchPathParams {
|
||||
|
@ -4773,13 +4810,13 @@ export interface ListPullReqQueryParams {
|
|||
*/
|
||||
created_gt?: number
|
||||
/**
|
||||
* The result should contain only entries edited before this timestamp (unix millis).
|
||||
* The result should contain only entries updated before this timestamp (unix millis).
|
||||
*/
|
||||
edited_lt?: number
|
||||
updated_lt?: number
|
||||
/**
|
||||
* The result should contain only entries edited after this timestamp (unix millis).
|
||||
* The result should contain only entries updated after this timestamp (unix millis).
|
||||
*/
|
||||
edited_gt?: number
|
||||
updated_gt?: number
|
||||
/**
|
||||
* By providing this parameter the description would be included in the response.
|
||||
*/
|
||||
|
@ -4952,6 +4989,7 @@ export interface ListPullReqActivitiesQueryParams {
|
|||
*/
|
||||
type?: (
|
||||
| 'branch-delete'
|
||||
| 'branch-restore'
|
||||
| 'branch-update'
|
||||
| 'code-comment'
|
||||
| 'comment'
|
||||
|
@ -5013,6 +5051,146 @@ export const useListPullReqActivities = ({ repo_ref, pullreq_number, ...props }:
|
|||
{ base: getConfig('code/api/v1'), pathParams: { repo_ref, pullreq_number }, ...props }
|
||||
)
|
||||
|
||||
export interface DeletePullReqSourceBranchQueryParams {
|
||||
/**
|
||||
* Bypass rule violations if possible.
|
||||
*/
|
||||
bypass_rules?: boolean
|
||||
/**
|
||||
* Dry run rules for operations
|
||||
*/
|
||||
dry_run_rules?: boolean
|
||||
}
|
||||
|
||||
export interface DeletePullReqSourceBranchPathParams {
|
||||
repo_ref: string
|
||||
pullreq_number: number
|
||||
}
|
||||
|
||||
export type DeletePullReqSourceBranchProps = Omit<
|
||||
MutateProps<
|
||||
TypesDeleteBranchOutput,
|
||||
UsererrorError | TypesRulesViolations,
|
||||
DeletePullReqSourceBranchQueryParams,
|
||||
void,
|
||||
DeletePullReqSourceBranchPathParams
|
||||
>,
|
||||
'path' | 'verb'
|
||||
> &
|
||||
DeletePullReqSourceBranchPathParams
|
||||
|
||||
export const DeletePullReqSourceBranch = ({ repo_ref, pullreq_number, ...props }: DeletePullReqSourceBranchProps) => (
|
||||
<Mutate<
|
||||
TypesDeleteBranchOutput,
|
||||
UsererrorError | TypesRulesViolations,
|
||||
DeletePullReqSourceBranchQueryParams,
|
||||
void,
|
||||
DeletePullReqSourceBranchPathParams
|
||||
>
|
||||
verb="DELETE"
|
||||
path={`/repos/${repo_ref}/pullreq/${pullreq_number}/branch`}
|
||||
base={getConfig('code/api/v1')}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
|
||||
export type UseDeletePullReqSourceBranchProps = Omit<
|
||||
UseMutateProps<
|
||||
TypesDeleteBranchOutput,
|
||||
UsererrorError | TypesRulesViolations,
|
||||
DeletePullReqSourceBranchQueryParams,
|
||||
void,
|
||||
DeletePullReqSourceBranchPathParams
|
||||
>,
|
||||
'path' | 'verb'
|
||||
> &
|
||||
DeletePullReqSourceBranchPathParams
|
||||
|
||||
export const useDeletePullReqSourceBranch = ({
|
||||
repo_ref,
|
||||
pullreq_number,
|
||||
...props
|
||||
}: UseDeletePullReqSourceBranchProps) =>
|
||||
useMutate<
|
||||
TypesDeleteBranchOutput,
|
||||
UsererrorError | TypesRulesViolations,
|
||||
DeletePullReqSourceBranchQueryParams,
|
||||
void,
|
||||
DeletePullReqSourceBranchPathParams
|
||||
>(
|
||||
'DELETE',
|
||||
(paramsInPath: DeletePullReqSourceBranchPathParams) =>
|
||||
`/repos/${paramsInPath.repo_ref}/pullreq/${paramsInPath.pullreq_number}/branch`,
|
||||
{ base: getConfig('code/api/v1'), pathParams: { repo_ref, pullreq_number }, ...props }
|
||||
)
|
||||
|
||||
export interface RestorePullReqSourceBranchPathParams {
|
||||
repo_ref: string
|
||||
pullreq_number: number
|
||||
}
|
||||
|
||||
export interface RestorePullReqSourceBranchRequestBody {
|
||||
bypass_rules?: boolean
|
||||
dry_run_rules?: boolean
|
||||
}
|
||||
|
||||
export type RestorePullReqSourceBranchProps = Omit<
|
||||
MutateProps<
|
||||
TypesCreateBranchOutput,
|
||||
UsererrorError | TypesRulesViolations,
|
||||
void,
|
||||
RestorePullReqSourceBranchRequestBody,
|
||||
RestorePullReqSourceBranchPathParams
|
||||
>,
|
||||
'path' | 'verb'
|
||||
> &
|
||||
RestorePullReqSourceBranchPathParams
|
||||
|
||||
export const RestorePullReqSourceBranch = ({ repo_ref, pullreq_number, ...props }: RestorePullReqSourceBranchProps) => (
|
||||
<Mutate<
|
||||
TypesCreateBranchOutput,
|
||||
UsererrorError | TypesRulesViolations,
|
||||
void,
|
||||
RestorePullReqSourceBranchRequestBody,
|
||||
RestorePullReqSourceBranchPathParams
|
||||
>
|
||||
verb="POST"
|
||||
path={`/repos/${repo_ref}/pullreq/${pullreq_number}/branch`}
|
||||
base={getConfig('code/api/v1')}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
|
||||
export type UseRestorePullReqSourceBranchProps = Omit<
|
||||
UseMutateProps<
|
||||
TypesCreateBranchOutput,
|
||||
UsererrorError | TypesRulesViolations,
|
||||
void,
|
||||
RestorePullReqSourceBranchRequestBody,
|
||||
RestorePullReqSourceBranchPathParams
|
||||
>,
|
||||
'path' | 'verb'
|
||||
> &
|
||||
RestorePullReqSourceBranchPathParams
|
||||
|
||||
export const useRestorePullReqSourceBranch = ({
|
||||
repo_ref,
|
||||
pullreq_number,
|
||||
...props
|
||||
}: UseRestorePullReqSourceBranchProps) =>
|
||||
useMutate<
|
||||
TypesCreateBranchOutput,
|
||||
UsererrorError | TypesRulesViolations,
|
||||
void,
|
||||
RestorePullReqSourceBranchRequestBody,
|
||||
RestorePullReqSourceBranchPathParams
|
||||
>(
|
||||
'POST',
|
||||
(paramsInPath: RestorePullReqSourceBranchPathParams) =>
|
||||
`/repos/${paramsInPath.repo_ref}/pullreq/${paramsInPath.pullreq_number}/branch`,
|
||||
{ base: getConfig('code/api/v1'), pathParams: { repo_ref, pullreq_number }, ...props }
|
||||
)
|
||||
|
||||
export interface ChecksPullReqPathParams {
|
||||
repo_ref: string
|
||||
pullreq_number: number
|
||||
|
@ -7321,9 +7499,9 @@ export interface ListSpacePullReqQueryParams {
|
|||
*/
|
||||
created_gt?: number
|
||||
/**
|
||||
* The result should contain only entries edited before this timestamp (unix millis).
|
||||
* The result should contain only entries updated before this timestamp (unix millis).
|
||||
*/
|
||||
edited_lt?: number
|
||||
updated_lt?: number
|
||||
/**
|
||||
* By providing this parameter the description would be included in the response.
|
||||
*/
|
||||
|
|
|
@ -1602,12 +1602,6 @@ paths:
|
|||
schema:
|
||||
default: false
|
||||
type: boolean
|
||||
- description: Commit SHA the branch is at
|
||||
in: query
|
||||
name: commit_sha
|
||||
required: false
|
||||
schema:
|
||||
type: string
|
||||
- in: path
|
||||
name: repo_ref
|
||||
required: true
|
||||
|
@ -4332,18 +4326,18 @@ paths:
|
|||
schema:
|
||||
minimum: 0
|
||||
type: integer
|
||||
- description: The result should contain only entries edited before this timestamp
|
||||
- description: The result should contain only entries updated before this timestamp
|
||||
(unix millis).
|
||||
in: query
|
||||
name: edited_lt
|
||||
name: updated_lt
|
||||
required: false
|
||||
schema:
|
||||
minimum: 0
|
||||
type: integer
|
||||
- description: The result should contain only entries edited after this timestamp
|
||||
- description: The result should contain only entries updated after this timestamp
|
||||
(unix millis).
|
||||
in: query
|
||||
name: edited_gt
|
||||
name: updated_gt
|
||||
required: false
|
||||
schema:
|
||||
minimum: 0
|
||||
|
@ -4643,6 +4637,7 @@ paths:
|
|||
items:
|
||||
enum:
|
||||
- branch-delete
|
||||
- branch-restore
|
||||
- branch-update
|
||||
- code-comment
|
||||
- comment
|
||||
|
@ -4724,6 +4719,135 @@ paths:
|
|||
description: Internal Server Error
|
||||
tags:
|
||||
- pullreq
|
||||
/repos/{repo_ref}/pullreq/{pullreq_number}/branch:
|
||||
delete:
|
||||
operationId: deletePullReqSourceBranch
|
||||
parameters:
|
||||
- description: Bypass rule violations if possible.
|
||||
in: query
|
||||
name: bypass_rules
|
||||
required: false
|
||||
schema:
|
||||
default: false
|
||||
type: boolean
|
||||
- description: Dry run rules for operations
|
||||
in: query
|
||||
name: dry_run_rules
|
||||
required: false
|
||||
schema:
|
||||
default: false
|
||||
type: boolean
|
||||
- in: path
|
||||
name: repo_ref
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
- in: path
|
||||
name: pullreq_number
|
||||
required: true
|
||||
schema:
|
||||
type: integer
|
||||
responses:
|
||||
'200':
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/TypesDeleteBranchOutput'
|
||||
description: OK
|
||||
'401':
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/UsererrorError'
|
||||
description: Unauthorized
|
||||
'403':
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/UsererrorError'
|
||||
description: Forbidden
|
||||
'404':
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/UsererrorError'
|
||||
description: Not Found
|
||||
'422':
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/TypesRulesViolations'
|
||||
description: Unprocessable Entity
|
||||
'500':
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/UsererrorError'
|
||||
description: Internal Server Error
|
||||
tags:
|
||||
- pullreq
|
||||
post:
|
||||
operationId: restorePullReqSourceBranch
|
||||
parameters:
|
||||
- in: path
|
||||
name: repo_ref
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
- in: path
|
||||
name: pullreq_number
|
||||
required: true
|
||||
schema:
|
||||
type: integer
|
||||
requestBody:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
properties:
|
||||
bypass_rules:
|
||||
type: boolean
|
||||
dry_run_rules:
|
||||
type: boolean
|
||||
type: object
|
||||
responses:
|
||||
'201':
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/TypesCreateBranchOutput'
|
||||
description: Created
|
||||
'400':
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/UsererrorError'
|
||||
description: Bad Request
|
||||
'401':
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/UsererrorError'
|
||||
description: Unauthorized
|
||||
'403':
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/UsererrorError'
|
||||
description: Forbidden
|
||||
'422':
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/TypesRulesViolations'
|
||||
description: Unprocessable Entity
|
||||
'500':
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/UsererrorError'
|
||||
description: Internal Server Error
|
||||
tags:
|
||||
- pullreq
|
||||
/repos/{repo_ref}/pullreq/{pullreq_number}/checks:
|
||||
get:
|
||||
operationId: checksPullReq
|
||||
|
@ -7940,10 +8064,10 @@ paths:
|
|||
schema:
|
||||
minimum: 0
|
||||
type: integer
|
||||
- description: The result should contain only entries edited before this timestamp
|
||||
- description: The result should contain only entries updated before this timestamp
|
||||
(unix millis).
|
||||
in: query
|
||||
name: edited_lt
|
||||
name: updated_lt
|
||||
required: false
|
||||
schema:
|
||||
minimum: 0
|
||||
|
@ -10258,6 +10382,20 @@ components:
|
|||
- running
|
||||
- success
|
||||
type: string
|
||||
EnumConnectorAuthType:
|
||||
enum:
|
||||
- basic
|
||||
- bearer
|
||||
type: string
|
||||
EnumConnectorStatus:
|
||||
enum:
|
||||
- failed
|
||||
- success
|
||||
type: string
|
||||
EnumConnectorType:
|
||||
enum:
|
||||
- github
|
||||
type: string
|
||||
EnumContentEncodingType:
|
||||
enum:
|
||||
- base64
|
||||
|
@ -10417,6 +10555,7 @@ components:
|
|||
EnumPullReqActivityType:
|
||||
enum:
|
||||
- branch-delete
|
||||
- branch-restore
|
||||
- branch-update
|
||||
- code-comment
|
||||
- comment
|
||||
|
@ -10842,19 +10981,16 @@ components:
|
|||
type: object
|
||||
OpenapiCreateConnectorRequest:
|
||||
properties:
|
||||
data:
|
||||
type: string
|
||||
description:
|
||||
type: string
|
||||
github:
|
||||
$ref: '#/components/schemas/TypesGithubConnectorData'
|
||||
identifier:
|
||||
type: string
|
||||
space_ref:
|
||||
type: string
|
||||
type:
|
||||
type: string
|
||||
uid:
|
||||
deprecated: true
|
||||
type: string
|
||||
$ref: '#/components/schemas/EnumConnectorType'
|
||||
type: object
|
||||
OpenapiCreateGitspaceRequest:
|
||||
properties:
|
||||
|
@ -11299,19 +11435,12 @@ components:
|
|||
type: object
|
||||
OpenapiUpdateConnectorRequest:
|
||||
properties:
|
||||
data:
|
||||
nullable: true
|
||||
type: string
|
||||
description:
|
||||
nullable: true
|
||||
type: string
|
||||
identifier:
|
||||
nullable: true
|
||||
type: string
|
||||
uid:
|
||||
deprecated: true
|
||||
nullable: true
|
||||
type: string
|
||||
type: object
|
||||
OpenapiUpdateDefaultBranchRequest:
|
||||
properties:
|
||||
|
@ -11539,9 +11668,13 @@ components:
|
|||
type: boolean
|
||||
update_forbidden:
|
||||
type: boolean
|
||||
update_force_forbidden:
|
||||
type: boolean
|
||||
type: object
|
||||
ProtectionDefMerge:
|
||||
properties:
|
||||
block:
|
||||
type: boolean
|
||||
delete_branch:
|
||||
type: boolean
|
||||
strategies_allowed:
|
||||
|
@ -11859,6 +11992,18 @@ components:
|
|||
TimeDuration:
|
||||
nullable: true
|
||||
type: integer
|
||||
TypesBasicAuthCreds:
|
||||
properties:
|
||||
password:
|
||||
$ref: '#/components/schemas/TypesSecretRef'
|
||||
username:
|
||||
type: string
|
||||
type: object
|
||||
TypesBearerTokenCreds:
|
||||
properties:
|
||||
token:
|
||||
$ref: '#/components/schemas/TypesSecretRef'
|
||||
type: object
|
||||
TypesBranch:
|
||||
properties:
|
||||
commit:
|
||||
|
@ -12015,19 +12160,44 @@ components:
|
|||
properties:
|
||||
created:
|
||||
type: integer
|
||||
data:
|
||||
type: string
|
||||
created_by:
|
||||
type: integer
|
||||
description:
|
||||
type: string
|
||||
github:
|
||||
$ref: '#/components/schemas/TypesGithubConnectorData'
|
||||
identifier:
|
||||
type: string
|
||||
last_test_attempt:
|
||||
type: integer
|
||||
last_test_error_msg:
|
||||
type: string
|
||||
last_test_status:
|
||||
$ref: '#/components/schemas/EnumConnectorStatus'
|
||||
space_id:
|
||||
type: integer
|
||||
type:
|
||||
type: string
|
||||
$ref: '#/components/schemas/EnumConnectorType'
|
||||
updated:
|
||||
type: integer
|
||||
type: object
|
||||
TypesConnectorAuth:
|
||||
nullable: true
|
||||
properties:
|
||||
basic:
|
||||
$ref: '#/components/schemas/TypesBasicAuthCreds'
|
||||
bearer:
|
||||
$ref: '#/components/schemas/TypesBearerTokenCreds'
|
||||
type:
|
||||
$ref: '#/components/schemas/EnumConnectorAuthType'
|
||||
type: object
|
||||
TypesConnectorTestResponse:
|
||||
properties:
|
||||
error_msg:
|
||||
type: string
|
||||
status:
|
||||
$ref: '#/components/schemas/EnumConnectorStatus'
|
||||
type: object
|
||||
TypesCreateBranchOutput:
|
||||
properties:
|
||||
commit:
|
||||
|
@ -12144,6 +12314,15 @@ components:
|
|||
updated:
|
||||
type: integer
|
||||
type: object
|
||||
TypesGithubConnectorData:
|
||||
properties:
|
||||
api_url:
|
||||
type: string
|
||||
auth:
|
||||
$ref: '#/components/schemas/TypesConnectorAuth'
|
||||
insecure:
|
||||
type: boolean
|
||||
type: object
|
||||
TypesGitspaceConfig:
|
||||
properties:
|
||||
branch:
|
||||
|
@ -12658,6 +12837,8 @@ components:
|
|||
type: integer
|
||||
title:
|
||||
type: string
|
||||
updated:
|
||||
type: integer
|
||||
type: object
|
||||
TypesPullReqActivity:
|
||||
properties:
|
||||
|
@ -13004,6 +13185,11 @@ components:
|
|||
updated:
|
||||
type: integer
|
||||
type: object
|
||||
TypesSecretRef:
|
||||
properties:
|
||||
identifier:
|
||||
type: string
|
||||
type: object
|
||||
TypesServiceAccount:
|
||||
properties:
|
||||
admin:
|
||||
|
|
Loading…
Reference in New Issue