Skip to content

Conversation

@ljavorsk
Copy link
Collaborator

Also add a check for the duplicate to not post the checklist on multiple runs

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a mechanism to prevent posting duplicate checklists on GitLab merge requests. This is achieved by modifying the create_merge_request_checklist tool to first check for an existing checklist note before creating a new one. The checklist content is also now sourced from the GITLAB_MR_CHECKLIST constant. The changes are well-tested with a new unit test for the duplicate-checking logic. My review includes a suggestion to make the duplicate check more robust by dynamically determining the checklist identifier and using a more precise string comparison, which will improve maintainability.

Comment on lines 316 to 325
checklist_body = note_body.strip()
checklist_identifier = "# Jötnar MR Review Checklist"

for note in notes:
note_body_text = note.body.strip()
if (checklist_identifier in note_body_text or
note_body_text == checklist_body):
return True
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This implementation has a couple of areas for improvement to make it more robust:

  1. The checklist_identifier is hardcoded. This is brittle because if the title in the GITLAB_MR_CHECKLIST constant changes, this code will fail to detect existing checklists. It's better to derive the identifier from the note_body's first line.
  2. Using in for a substring check could lead to false positives. It's safer to check if the note body startswith() the identifier.
  3. The case where note_body is empty isn't handled, which could lead to unexpected behavior.

Here's a suggestion that addresses these points.

Suggested change
checklist_body = note_body.strip()
checklist_identifier = "# Jötnar MR Review Checklist"
for note in notes:
note_body_text = note.body.strip()
if (checklist_identifier in note_body_text or
note_body_text == checklist_body):
return True
checklist_body = note_body.strip()
if not checklist_body:
# Can't check for an empty checklist, assume it doesn't exist.
return False
# Use the first line of the checklist as the unique identifier.
checklist_identifier = checklist_body.splitlines()[0]
for note in notes:
note_body_text = note.body.strip()
if (note_body_text.startswith(checklist_identifier) or
note_body_text == checklist_body):
return True

Also add a check for the duplicate to not post the checklist on multiple
runs
@nforro
Copy link
Member

nforro commented Nov 25, 2025

Could you please also update this point?

- [ ] **Labels**: `target::latest` is set, exception or zstream are set only for exceptions or 0day, please consult Veronika Kabatova for that

target::latest/target::zstream is set, exception is set only for exceptions ...

There are probably more things to update, but this one is important.

@ljavorsk
Copy link
Collaborator Author

@nforro please review the latest commit. I made several changes to the message body, since there were quite a few outdated or wrong information

- [ ] **RHEL Build**: Successful scratch build
- [ ] **build_rpm**: Successful draft build. Once the gating is complete, it will automatically trigger a RHEL build.
- [ ] **Gitbz Check**: Commit messages correctly associated with approved Jira ticket (commit messages use "Resolves: RHEL-XXXXX" format)
- [ ] **Labels**: `target::latest` is set, exception or zstream are set only for exceptions or 0day, please consult Veronika Kabatova for that
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about target::zstream label?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can see it mentioned below, but it could be already set by the automation.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's under the Labels checkmark. And yes, it is set by automation. I left this note here just to ensure it is set correctly.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But it says "target::latest is set", while it can be target::zstream.

- [ ] **Labels**: `target::latest` is set, exception or zstream are set only for exceptions or 0day, please consult Veronika Kabatova for that
- you can utilise draft builds if you don’t want to trigger builds after merging manually, by labelling the MR with `feature::draft-builds::enabled` and clicking `Run pipeline` to rerun the pipeline
- Draft builds are now enabled by default, you should see the label `feature::draft-builds::enabled` on your MR.
- 0day is a regullar zstream build, it just needs to be added to the 0day batch at the Erratum level.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if we need this here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm okay with removing it. I left it there for people who don't often come into contact with RHEL development.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose it doesn't hurt to have it here, there is just a typo in regular.

@ljavorsk ljavorsk merged commit dc62dd9 into packit:main Nov 26, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants