Fix patch to use origin branch instead of first branch
When patching nodes across 3+ branches, PatchNodeCommand incorrectly used the first branch in the list as the source instead of the current context branch (origin). This caused patches to propagate from the wrong branch when the origin wasn't first.
Changes:
-
patchNodeInBranch(): UseContextAccessor.current().getBranch()instead ofthis.branches.first()when pushing patched nodes -
verifyPermissions(): Use origin branch from context for permission checks and version comparisons instead of first branch
Before:
this.nodeStorageService.push(
NodeBranchEntry.fromNodeVersionMetadata(patchedNode.metadata()),
this.branches.first(), // Wrong: uses first branch, not origin
internalContext
);
After:
this.nodeStorageService.push(
NodeBranchEntry.fromNodeVersionMetadata(patchedNode.metadata()),
ContextAccessor.current().getBranch(), // Correct: uses origin branch
internalContext
);
Added test modify_with_origin_branch_not_first that patches from branch2 to [branch1, branch2, branch3] and verifies all branches receive content from branch2 (the origin), not branch1 (the first in the list).
[!WARNING]
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
scans-in.gradle.com
- Triggering command:
/usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens=java.xml/javax.xml.namespace=ALL-UNNAMED --add-opens=java.base/java.time=ALL-UNNAMED -XX:MaxMetaspaceSize=384m -XX:+HeapDumpOnOutOfMemoryError -Xms256m -Xmx512m -Dfile.encoding=UTF-8(dns block)If you need me to access, download, or install something from one of these locations, you can either:
- Configure Actions setup steps to set up my environment, which run before the firewall is enabled
- Add the appropriate URLs or hosts to the custom allowlist in this repository's Copilot coding agent settings (admins only)
Original prompt
This section details on the original issue you should resolve
<issue_title>Patch should use originBranch</issue_title> <issue_description>The first branch is considered as source branch during the patch for now. But in the case of 3+ branches, it could be a case when the source branch is different from the first one. </issue_description>
Comments on the Issue (you are @copilot in this section)
- Fixes enonic/xp#11544
ð¡ You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.