export async function deleteBranchFunc()

in operations/codeup/branches.ts [104:135]


export async function deleteBranchFunc(
    organizationId: string,
    repositoryId: string,
    branchName: string
): Promise<DeleteBranchResponse> {
  // Automatically handle unencoded slashes in repositoryId
  if (repositoryId.includes("/")) {
    // Found unencoded slash, automatically URL encode it
    const parts = repositoryId.split("/", 2);
    if (parts.length === 2) {
      const encodedRepoName = encodeURIComponent(parts[1]);
      // Remove + signs from encoding (spaces are encoded as +, but we need %20)
      const formattedEncodedName = encodedRepoName.replace(/\+/g, "%20");
      repositoryId = `${parts[0]}%2F${formattedEncodedName}`;
    }
  }

  // Automatically handle unencoded slashes in branchName
  if (branchName.includes("/")) {
    branchName = encodeURIComponent(branchName);
  }

  const url = `/oapi/v1/codeup/organizations/${organizationId}/repositories/${repositoryId}/branches/${branchName}`;

  const response = await yunxiaoRequest(url, {
    method: "DELETE",
  });

  return {
    branchName: branchName
  };
}