export async function getBranchFunc()

in operations/codeup/branches.ts [68:96]


export async function getBranchFunc(
    organizationId: string,
    repositoryId: string,
    branchName: string
): Promise<z.infer<typeof CodeupBranchSchema>>{
  // 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: "GET",
  });
  return CodeupBranchSchema.parse(response);
}