pickman: Add a way to update a gitlab merge-request
Add function to update a merge request's description via the GitLab API. This is used to update the MR with the agent's conversation log after processing review comments. Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com>
This commit is contained in:
@@ -320,6 +320,43 @@ def reply_to_mr(remote, mr_iid, message):
|
||||
return False
|
||||
|
||||
|
||||
def update_mr_description(remote, mr_iid, desc):
|
||||
"""Update a merge request's description
|
||||
|
||||
Args:
|
||||
remote (str): Remote name
|
||||
mr_iid (int): Merge request IID
|
||||
desc (str): New description
|
||||
|
||||
Returns:
|
||||
bool: True on success
|
||||
"""
|
||||
if not check_available():
|
||||
return False
|
||||
|
||||
token = get_token()
|
||||
if not token:
|
||||
tout.error('GITLAB_TOKEN environment variable not set')
|
||||
return False
|
||||
|
||||
remote_url = get_remote_url(remote)
|
||||
host, proj_path = parse_url(remote_url)
|
||||
|
||||
if not host or not proj_path:
|
||||
return False
|
||||
|
||||
try:
|
||||
glab = gitlab.Gitlab(f'https://{host}', private_token=token)
|
||||
project = glab.projects.get(proj_path)
|
||||
merge_req = project.mergerequests.get(mr_iid)
|
||||
merge_req.description = desc
|
||||
merge_req.save()
|
||||
return True
|
||||
except gitlab.exceptions.GitlabError as exc:
|
||||
tout.error(f'GitLab API error: {exc}')
|
||||
return False
|
||||
|
||||
|
||||
def push_and_create_mr(remote, branch, target, title, desc=''):
|
||||
"""Push a branch and create a merge request
|
||||
|
||||
|
||||
Reference in New Issue
Block a user