Claus Ibsen created CAMEL-26192:
-----------------------------------
Summary: camel-git - checkout always creates the branch, so
checking out an existing branch fails, and CamelGitCommitId of the commit
consumer is not the sha
Key: CAMEL-26192
URL: https://issues.apache.org/jira/browse/CAMEL-26192
Project: Camel
Issue Type: Bug
Components: camel-git
Reporter: Claus Ibsen
Fix For: 4.24.0
Found while adding the catalog body types of git (CAMEL-24961, PR #28414).
h4. 1. checkout of an existing branch fails with RefAlreadyExistsException
{{GitProducer.doCheckout}} (main 2a465aa4814c, line 249 and 251) always calls
{{setCreateBranch(true)}}, so the checkout operation can only create a new
branch; checking out a branch that already exists fails with
RefAlreadyExistsException. Checked on 4.24.0-SNAPSHOT with a temporary git
repository.
Proposed: create the branch only when it does not exist (or add an option or
header for it).
h4. 2. The CamelGitCommitId header of the commit consumer is the RevCommit
object, not the sha
{{GitCommitConsumer}} (line 64) sets the header to {{commit.getId()}}, which is
the RevCommit itself. Its String form is not the sha, so feeding the header to
the cherrypick operation ({{GitProducer.doCherryPick}}, line 582 to 583, reads
it as a String) fails with RevisionSyntaxException. Checked on 4.24.0-SNAPSHOT
with a temporary git repository.
Proposed: set the header to {{commit.getName()}} (the sha as text).
h4. 3. commit and commitAll keep the old body: the new commit is not available
{{GitProducer.doCommit}} (line 337 and 339) and {{doCommitAll}} (line 371 to
374) discard the RevCommit returned by {{call()}}, so the route cannot know the
id of the commit it just made. Checked on 4.24.0-SNAPSHOT with a temporary git
repository.
Proposed: set the new commit (or its id) as the body or as the CamelGitCommitId
header.
_Claude Code on behalf of davsclaus_
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)