gerrit不能对一个已经merge/abandon的change进行再次提交

http://blog.csdn.net/velanjun/article/details/40372079

With this error message Gerrit rejects to push a commit or submit a review label (approval) to a change that is already closed.


This error occurs if you are trying to push a commit that contains the Change-Id of a closed change in its commit message. A change can be closed either because it was already submitted and merged or because it was abandoned.


If the change for which you wanted to upload a new patch set was already submitted and merged you may want to push your commit as a new change. To do this you have to remove the Change-Id from the commit message as explained here and ideally generate a new Change-Id using the commit hook or EGit. Before pushing again it is also recommended to do agit rebase to base your commit on the submitted change. Pushing again should now create a new change in Gerrit.


If the change for which you wanted to upload a new patch set was abandoned and your new changes overcome the reasons for abandoning this change you may want to restore the change in the Gerrit WebUI (browse the abandoned change in the Gerrit WebUI and click on the Restore Change button). Afterwards the push should succeed and a new patch set for this change will be created.


When Submitting a Review Label
This error occurs if you are trying to submit a review label (approval) using the ssh review command after the change has been closed. A change can be closed because it was submitted and merged, because it was abandoned, or because the patchset to which you are submitting the review has been replaced by a newer patchset.
Gerrit一个基于 Web 的代码审查工具,与 Git 版本控制系统配合使用,常用于代码的管理与代码审查。要通过脚本对 Gerrit 上的某个项目库进行提交查询,你可以使用 Gerrit 提供的 REST API 接口。 以下是一个基本的步骤介绍: 1. 获取 Gerrit 服务器的 API 地址。通常情况下,Gerrit 的 API 接口地址是在 Gerrit 服务器地址后面加上 `/a/`。例如,如果 Gerrit 服务器地址是 `https://gerrit.example.com/`,那么 API 地址就是 `https://gerrit.example.com/a/`。 2. 使用 HTTP 请求访问 API。你需要进行认证(通常是 HTTP 基本认证),并且可能需要使用 Gerrit 的 cookie 来处理会话。可以使用命令行工具如 `curl`,或者编写脚本使用 Python 的 `requests` 库、Node.js 的 `axios` 库等来发送请求。 3. 构造查询参数。根据需求构造查询参数,例如查询特定的项目库、提交者、状态、时间范围等。 4. 解析返回的 JSON 数据。Gerrit 的 API 通常返回 JSON 格式的数据,你需要解析这些数据以获取所需的提交信息。 例如,使用 `curl` 命令在命令行中查询 TestTool 库的提交: ```bash curl -k -u username:password https://gerrit.example.com/a/changes/?q=project:TestTool ``` 这里的 `-u` 参数用于指定 Gerrit 的用户名和密码进行认证,`-k` 参数表示允许不安全的 SSL 连接(如果服务器使用的是自签名证书则需要),`q=project:TestTool` 是查询参数,表示查询项目名为 TestTool 的提交。 脚本实现的示例代码(Python 使用 requests 库): ```python import requests from requests.auth import HTTPBasicAuth # Gerrit 服务器地址 url = 'https://gerrit.example.com/a/' # 用户名和密码 username = 'your_username' password = 'your_password' # 项目名称 project = 'TestTool' # 构造 API 请求的完整 URL api_url = f'{url}changes/?q=project:{project}' # 发送请求 response = requests.get(api_url, auth=HTTPBasicAuth(username, password)) # 检查请求是否成功 if response.status_code == 200: # 解析响应的 JSON 数据 changes = response.json() for change in changes: print(change) # 输出每个提交的信息 else: print(f'Error: {response.status_code}') ``` 注意,实际使用时应当考虑脚本的安全性和效率,避免明文存储密码,并且可能需要处理分页(如果查询结果较多)。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值