Skip to content

Tell a conflicting port from a clean one by its draft state - #17609

Merged
koppor merged 4 commits into
mainfrom
classify-port-drafts
Oct 29, 2026
Merged

koppor merged 4 commits into
mainfrom
classify-port-drafts

Conversation

@koppor

@koppor koppor commented Oct 27, 2026

Copy link
Copy Markdown
Member

Summary

The first cross-repository port (JabRef#11) showed two gaps in the port job: the backport action reports a committed conflict as success, so the draft got the automerge path, and the label call failed because gh pr edit needs a token scope the jabref-machine token lacks. The job now tells the two cases apart by the draft state and labels through the API. Dependabot pull requests in JabRef/jabref-black-forest are auto-merged the same way as here, and GitVersion gets a configuration for black-forest, since that repository has no main to derive versions from.

Analogies: honey that looks set but is still runny needs a second look before the jar is labelled; chocolate gets the same wrapper in both shops; the moon shows the same face to both repositories.

jabref-contrib-policy:4.2:reviewed​:ok

Steps to test

  1. Merge a PR with dev: send-to-black-forest that applies cleanly: the port PR in JabRef/jabref-black-forest gets automerge and the run is green.
  2. Merge one that conflicts: the draft port PR gets status: changes-required and the run is red.
  3. In JabRef/jabref-black-forest, a Dependabot PR is approved and auto-merge enabled once this file is on black-forest.
  4. The binaries job of [Port to black-forest] Move the release branch to JabRef/jabref-black-forest jabref-black-forest#11 passes GitVersion with the same GitVersion.yml.

Related issues and pull requests

Closes _____

Triggered by https://github.com/JabRef/jabref/actions/runs/40599392673 (port of #17606). Replaces #17608, whose branch name started with port- and was therefore excluded from porting.

AI usage

Claude Code (model claude-fable-5-1), AIL4.

AI CHECKLIST.md walkthrough
  • [/] No == null / != null checks — JSpecify annotations used instead.
  • [/] No Objects.requireNonNull(...).
  • [/] New classes annotated with @NullMarked.
  • [/] New packages annotated with @NullMarked.
  • [/] Optional consumed with ifPresent / map / orElseThrow.
  • [/] StringUtil.isBlank(...) used.
  • [/] No catch (Exception e).
  • [/] No throw new RuntimeException(...) / IllegalStateException(...).
  • [/] Logged exceptions passed as the last logger argument.
  • [/] New BibEntry objects built with withers.
  • [/] Modern Java used.
  • [/] Regexes use a precompiled Pattern.
  • [/] Alphabetical ordering kept.
  • [/] Background work uses BackgroundTask.
  • No commented-out code, no trivial comments, no AI-disclosure comments in source.
  • [/] Markdown Javadoc uses Markdown syntax.
  • [/] All user-facing text localized.
  • [/] Sentence case; no trailing !; labels do not end with :.
  • [/] Variance expressed with placeholders.
  • [/] User-controlled data HTML-escaped.
  • [/] Issue example covered by a test case.
  • [/] Behavior changes in org.jabref.model / org.jabref.logic have tests.
  • [/] Tests assert object contents, plain JUnit asserts.
  • [/] Fetcher tests hit the live endpoints.
  • [/] ./gradlew :jablib:check (workflow-only change).
  • [/] ./gradlew checkstyleMain checkstyleTest checkstyleJmh.
  • [/] ./gradlew modernizer.
  • [/] ./gradlew --no-configuration-cache :rewriteDryRun.
  • [/] ./gradlew javadoc.
  • [/] npx markdownlint-cli2 (no Markdown changed).
  • [/] npm run textlint (no Markdown changed).
  • [/] intellij-format.
  • [/] CHANGELOG.md entry (not user-visible).
  • [/] Searched for a related issue (triggered by a workflow run).
  • [/] Requirement added (existing requirement unchanged).
  • [/] Developer documentation (behavior as documented).
  • PR body built from the template, every section filled.
  • All checklist items kept and marked.
  • [/] "Steps to test" screenshots (no UI change).
  • All HTML comments removed from the PR body.
  • PR created with gh pr create --body-file.
  • [/] CHANGELOG.md TODO placeholder.

Checklist

  • I own the copyright of the code submitted and I license it under the MIT license
  • If AI tools were used, I disclosed them in the "AI usage" section and reviewed, understood, and take full ownership of all AI-generated code
  • [/] I manually tested my changes in running JabRef (always required)
  • [/] I added JUnit tests for changes (if applicable)
  • [/] I added screenshots in the PR description (if change is visible to the user)
  • [/] I added one sentence (max 20 words) to CHANGELOG.md describing the change from the user's point of view (if the change is visible to the user)
  • [/] I checked the user documentation for up to dateness and submitted a pull request to our user documentation repository

🤖 Generated with Claude Code

koppor and others added 2 commits October 28, 2026 00:07
The backport action reports a committed conflict as success, so the first cross-repository port got the automerge label and the labeling failed on a missing token scope. Dependabot pull requests in the black-forest repository are auto-merged like here.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
JabRef/jabref-black-forest has no main branch, so GitVersion found no source for pull requests there and the binaries job failed before building.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@koppor koppor added the dev: send-to-black-forest Port to the black-forest branch of JabRef/jabref-black-forest after merging (ADR-0073) label Oct 27, 2026
@koppor
koppor marked this pull request as ready for review October 27, 2026 23:20
@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

PR Summary by Qodo

Classify port conflicts by draft state and enable black-forest automation

🐞 Bug fix ✨ Enhancement ⚙️ Configuration changes 🕐 20-40 Minutes

Grey Divider

AI Description

• Label draft ports as conflicts and fail the job; send clean ports to auto-merge.
• Use the GitHub API for labels to avoid the machine token’s missing scope.
• Extend guarded auto-merge and GitVersion configuration to jabref-black-forest.
Diagram

graph TD
  A["Merged source PR"] --> B["Backport action"] --> C{"Port is draft?"}
  C -->|Yes| D["Changes-required label"] --> E["Fail port job"]
  C -->|No| F["Automerge label"] --> G["Automerge workflow"]
Loading
High-Level Assessment

Querying the created PR’s draft state fits the backport action’s conflict behavior; its success output cannot distinguish committed conflicts. Reimplementing cherry-pick conflict detection would duplicate the action’s work, while REST label calls avoid requiring a broader token scope.

Files changed (3) +37 / -22

Enhancement (1) +8 / -3
automerge.ymlGuard auto-merge in jabref-black-forest +8/-3

Guard auto-merge in jabref-black-forest

• Allows the auto-merge job to run in jabref-black-forest and checks internal PR branches against the current repository. In that repository, synchronization events from senders other than the listed bots are excluded so a human push cannot reuse a stale auto-merge label.

.github/workflows/automerge.yml

Bug fix (1) +22 / -19
port-to-other-branch.ymlLabel ports according to their draft state +22/-19

Label ports according to their draft state

• Replaces the backport action’s success-output check with a draft-state query for each created port PR. GitHub API calls apply either the conflict or auto-merge label without the scope required by 'gh pr edit'; missing PRs and conflicting drafts fail the job.

.github/workflows/port-to-other-branch.yml

Other (1) +7 / -0
GitVersion.ymlRecognize black-forest as a version source +7/-0

Recognize black-forest as a version source

• Defines the black-forest release branch as a main branch for GitVersion and includes it among pull-request source branches. This lets GitVersion derive versions for PR builds in the repository that has no 'main' branch.

GitVersion.yml

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)

Grey Divider


Action required

1. Human pushes can retain auto-merge ✓ Resolved
Description
Enabling automerge.yml in JabRef/jabref-black-forest leaves its synchronize events able to act
on an automerge label that the push-cleanup job removes only in JabRef/jabref. When a human
pushes to an already-labeled black-forest PR, the auto-merge job can see that retained label and
approve or enable auto-merge for the new head without the label being granted again.
Code

.github/workflows/automerge.yml[11]

+    if: github.repository == 'JabRef/jabref' || github.repository == 'JabRef/jabref-black-forest'
Evidence
The changed repository gate enables auto-merge for black-forest, and that workflow runs on
pull-request updates and accepts the live automerge label. The separate workflow explicitly
removes that label after a human push, but its repository gate prevents that cleanup from running in
black-forest.

.github/workflows/automerge.yml[1-11]
.github/workflows/automerge.yml[45-47]
.github/workflows/automerge.yml[62-65]
.github/workflows/automerge.yml[72-96]
.github/workflows/on-pr-opened-updated.yml[15-18]
.github/workflows/on-pr-opened-updated.yml[28-39]
.github/workflows/on-pr-opened-updated.yml[53-58]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The newly enabled black-forest auto-merge job can use an old `automerge` label after a human pushes new commits, because the workflow that removes that label runs only in JabRef/jabref.
## Fix Focus Areas
- .github/workflows/automerge.yml[11-11]
- .github/workflows/on-pr-opened-updated.yml[18-18]
- .github/workflows/on-pr-opened-updated.yml[37-58]
## Recommended Fix
Make label invalidation run for black-forest PR synchronize events as well, while preserving the live-head check and the exemption for pushes by jabref-machine. Ensure auto-merge cannot act on a stale label before that cleanup completes.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

2. Renovate updates lose auto-merge ✓ Resolved
Description
The new job condition skips black-forest synchronize events unless the sender is Dependabot or
jabref-machine, even though Determine if job should run accepts Renovate PRs. When Renovate
updates an existing PR, the approval and auto-merge steps do not run, and its existing label does
not trigger the label-only companion workflow again.
Code

.github/workflows/automerge.yml[16]

+       !(github.event.action == 'synchronize' && github.event.sender.login != 'dependabot[bot]' && github.event.sender.login != 'jabref-machine'))
Evidence
The new condition excludes Renovate as a synchronize sender, while the job's subsequent eligibility
check explicitly accepts Renovate. The companion workflow runs on labeling, not on an update to an
already-labeled PR.

.github/workflows/automerge.yml[13-16]
.github/workflows/automerge.yml[38-42]
.github/workflows/on-pr-labeled.yml[1-9]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The black-forest synchronize filter skips Renovate updates despite the job explicitly accepting Renovate PRs.
## Fix Focus Areas
- .github/workflows/automerge.yml[13-16]
## Recommended Fix
Exempt Renovate's sender from the black-forest synchronize restriction while continuing to skip human pushes.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Tip of the day
💡 Did you know, you can add REVIEW.md to your repo root and Qodo follows it on every PR

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@koppor
koppor marked this pull request as draft October 27, 2026 23:22
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@koppor
koppor marked this pull request as ready for review October 27, 2026 23:23
@github-actions github-actions Bot added the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Oct 27, 2026
@qodo-free-for-open-source-projects

Copy link
Copy Markdown
Contributor

Code review by qodo was updated up to the latest commit 3f29227

@koppor
koppor marked this pull request as draft October 27, 2026 23:26
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@koppor
koppor marked this pull request as ready for review October 27, 2026 23:27
@github-actions github-actions Bot removed the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Oct 27, 2026
@qodo-free-for-open-source-projects

Copy link
Copy Markdown
Contributor

Code review by qodo was updated up to the latest commit 21cfbc0

@github-actions github-actions Bot added the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Oct 27, 2026
koppor pushed a commit to JabRef/jabref-koppor that referenced this pull request Oct 28, 2026
JabRef:donation-snooze (github.com/JabRef/pull/17008)
JabRef:entry-editor-resize-scroll (github.com/JabRef/pull/17167)
JabRef:classify-port-drafts (github.com/JabRef/pull/17609)
@koppor
koppor merged commit c4015fc into main Oct 29, 2026
87 of 90 checks passed
@koppor
koppor deleted the classify-port-drafts branch October 29, 2026 05:24
@jabref-machine

Copy link
Copy Markdown
Collaborator

Created backport PR for black-forest:

Please cherry-pick the changes locally and resolve any conflicts.

git fetch origin port-17609-to-black-forest
git worktree add --checkout .worktree/port-17609-to-black-forest port-17609-to-black-forest
cd .worktree/port-17609-to-black-forest
git reset --hard HEAD^
git cherry-pick -x c4015fc23dcee621bbe79d176bca2c42742e6324

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dev: ci-cd dev: send-to-black-forest Port to the black-forest branch of JabRef/jabref-black-forest after merging (ADR-0073) size: small status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants