✨ feat(aliyun): 更新阿里云URL构建逻辑,支持组织名称并优化令牌解码处理

This commit is contained in:
HibiKier
2025-08-01 09:28:46 +08:00
parent 0e19de102a
commit 6c136b904d
3 changed files with 42 additions and 25 deletions
+18 -7
View File
@@ -450,16 +450,27 @@ class AliyunCodeupManager(BaseRepoManager):
"""
# 定义预处理函数,构建阿里云CodeUp的URL
def prepare_aliyun_url(repo_name: str) -> str:
def prepare_aliyun_url(repo_url: str) -> str:
import base64
repo_name = repo_url.split("/")[-1].replace(".git", "")
# 构建仓库URL
# 阿里云CodeUp的仓库URL格式通常为:
# https://codeup.aliyun.com/{organization_id}/{repo_name}.git
url = f"https://codeup.aliyun.com/{self.config.aliyun_codeup.organization_id}/{repo_name}.git"
# https://codeup.aliyun.com/{organization_id}/{organization_name}/{repo_name}.git
url = f"https://codeup.aliyun.com/{self.config.aliyun_codeup.organization_id}/{self.config.aliyun_codeup.organization_name}/{repo_name}.git"
# 添加访问令牌
# 添加访问令牌 - 使用base64解码后的令牌
if self.config.aliyun_codeup.rdc_access_token_encrypted:
token = self.config.aliyun_codeup.rdc_access_token_encrypted
url = url.replace("https://", f"https://oauth2:{token}@")
try:
# 解码RDC访问令牌
token = base64.b64decode(
self.config.aliyun_codeup.rdc_access_token_encrypted.encode()
).decode()
# 阿里云CodeUp使用oauth2:token的格式进行身份验证
url = url.replace("https://", f"https://oauth2:{token}@")
logger.debug(f"使用RDC令牌构建阿里云URL: {url.split('@')[0]}@***")
except Exception as e:
logger.error(f"解码RDC令牌失败: {e}")
return url
@@ -541,7 +552,7 @@ class AliyunCodeupManager(BaseRepoManager):
raise e
except Exception as e:
if retry < self.config.aliyun_codeup.download_retry:
logger.warning(f"下载文件失败,将重试: {e}")
logger.warning("下载文件失败,将重试", LOG_COMMAND, e=e)
await asyncio.sleep(1)
continue
raise RepoDownloadError(f"下载文件失败: {e}")