export async function deleteFileFunc()

in operations/codeup/files.ts [221:263]


export async function deleteFileFunc(
  organizationId: string,
  repositoryId: string,
  filePath: string,
  commitMessage: string,
  branch: string
): Promise<z.infer<typeof DeleteFileResponseSchema>> {
  let encodedRepoId = repositoryId;
  let encodedFilePath = filePath;

  if (repositoryId.includes("/")) {
    // 发现未编码的斜杠,自动进行URL编码
    const parts = repositoryId.split("/", 2);
    if (parts.length === 2) {
      const encodedRepoName = encodeURIComponent(parts[1]);
      // 移除编码中的+号(空格被编码为+,但我们需要%20)
      const formattedEncodedName = encodedRepoName.replace(/\+/g, "%20");
      encodedRepoId = `${parts[0]}%2F${formattedEncodedName}`;
    }
  }

  // 确保filePath已被URL编码
  if (filePath.includes("/")) {
    encodedFilePath = encodeURIComponent(filePath);
  }

  const baseUrl = `/oapi/v1/codeup/organizations/${organizationId}/repositories/${encodedRepoId}/files/${encodedFilePath}`;
  
  // 构建查询参数
  const queryParams: Record<string, string | number | undefined> = {
    branch: branch,
    commitMessage: commitMessage
  };

  // 使用buildUrl函数构建包含查询参数的URL
  const url = buildUrl(baseUrl, queryParams);

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

  return DeleteFileResponseSchema.parse(response);
}