icyleaf / hpr

镜像任意 git 仓库到 gitlab 的同步工具,具有定时更新的功能
https://hpr.ews.im
MIT License
92 stars 23 forks source link

无法使用api创建镜像仓库 #260

Open mcathena opened 4 months ago

mcathena commented 4 months ago

问题描述 无法使用api创建镜像仓库

填写完整问题的描述和复现的步骤

import requests
# API endpoint
api_endpoint = "http://124.223.177.10:8010/repositories"
# Repository URL to mirror
github_url = "https://github.com/icyleaf/hpr.git"

# API request data
data = {
    "url": "https://github.com/icyleaf/hpr.git"
}

# Username and password for basic authentication
username = "****"
password = "*******"

# Send API request with basic authentication
response = requests.post(api_endpoint, json=data, auth=(username, password))

# Check response status code
if response.status_code == 200:
    # Print job ID
    result = f"Mirror repository creation job ID: {response.json()['job_id']}"
    print(result)
else:
    # Print error message
    result = f"Error creating mirror repository: {response}"
    print(result)

返回结果

{
    "message": "undefined method `ssh_url_to_repo' for []:Gitlab::PaginatedResponse"
}

使用环境:

补充信息 补充提交 bug 的完整信息,如果有 hpr.logsidekiq.log 日志和 hpr.yml 配置文件为佳。

2024-04-18T08:46:56.764Z pid=52676 tid=12bw WARN: ArgumentError: concurrency: 0 is not a valid value
2024-04-18T08:46:56.765Z pid=52676 tid=12bw WARN: /usr/local/bundle/gems/sidekiq-6.1.2/lib/sidekiq/cli.rb:284:in `block in validate!'
/usr/local/bundle/gems/sidekiq-6.1.2/lib/sidekiq/cli.rb:283:in `each'
/usr/local/bundle/gems/sidekiq-6.1.2/lib/sidekiq/cli.rb:283:in `validate!'
/usr/local/bundle/gems/sidekiq-6.1.2/lib/sidekiq/cli.rb:26:in `parse'
/usr/local/bundle/gems/sidekiq-6.1.2/bin/sidekiq:27:in `<top (required)>'
/app/bin/sidekiq:29:in `load'
/app/bin/sidekiq:29:in `<main>'
2024-04-18T08:46:57.738Z pid=52682 tid=12bm WARN: ArgumentError: concurrency: 0 is not a valid value
2024-04-18T08:46:57.740Z pid=52682 tid=12bm WARN: /usr/local/bundle/gems/sidekiq-6.1.2/lib/sidekiq/cli.rb:284:in `block in validate!'
/usr/local/bundle/gems/sidekiq-6.1.2/lib/sidekiq/cli.rb:283:in `each'
/usr/local/bundle/gems/sidekiq-6.1.2/lib/sidekiq/cli.rb:283:in `validate!'
/usr/local/bundle/gems/sidekiq-6.1.2/lib/sidekiq/cli.rb:26:in `parse'
/usr/local/bundle/gems/sidekiq-6.1.2/bin/sidekiq:27:in `<top (required)>'
/app/bin/sidekiq:29:in `load'
/app/bin/sidekiq:29:in `<main>'
2024-04-18T08:46:58.751Z pid=52688 tid=12c8 WARN: ArgumentError: concurrency: 0 is not a valid value
2024-04-18T08:46:58.753Z pid=52688 tid=12c8 WARN: /usr/local/bundle/gems/sidekiq-6.1.2/lib/sidekiq/cli.rb:284:in `block in validate!'
/usr/local/bundle/gems/sidekiq-6.1.2/lib/sidekiq/cli.rb:283:in `each'
/usr/local/bundle/gems/sidekiq-6.1.2/lib/sidekiq/cli.rb:283:in `validate!'
/usr/local/bundle/gems/sidekiq-6.1.2/lib/sidekiq/cli.rb:26:in `parse'
/usr/local/bundle/gems/sidekiq-6.1.2/bin/sidekiq:27:in `<top (required)>'
/app/bin/sidekiq:29:in `load'
/app/bin/sidekiq:29:in `<main>'
icyleaf commented 4 months ago

应该是 gitlab 16 改了 API 结构,好久没适配了。

BTW,上来就贴 Python 代码是让我现学吗(笑)

mcathena commented 4 months ago

应该是 gitlab 16 改了 API 结构,好久没适配了。

BTW,上来就贴 Python 代码是让我现学吗(笑)

好的,感谢回复😂。请问近期有更新hpr的计划吗?如果没有我可能计划自己直接调用gitlab的api尝试实现一下。

icyleaf commented 4 months ago

查了 Gitlab API 并没有发生变化,做了一点调整 88eaa5ef247e6299704f0081077933bc74971389

icyleaf commented 4 months ago

试试 icyleafcn/hpr:nightly