Erick Brenes Solano
software tool logo

GitDiffProcessor returning wrong change set

5/4/2024

Context

We developed a custom deployer jar to send email notifications whenever an item (XML file) was published or deleted. This deployer target operates against the published repository.

Whenever there is a commit to process, it triggers a Script Processor to analyze the change set and generate an email based on the modified files.

Issue

Occasionally, the deployer would miscalculate the change set, resulting in us receiving email notifications containing documents that hadn’t been published yet!

Analysis

Upon investigation, we discovered that the GitDiffProcessor was utilizing a commit ID from the sandbox branch. It appears that in the published repository of CrafterCMS, there exist branches for both live and sandbox.

To obtain the latest commit in a repository, CrafterCMS retrieves the commit ID of the HEAD, which points to the most recent commit of the current branch. However, Crafter Studio executes a “git checkout” of the sandbox branch in the published repository each time something is published.

Consequently, our notification target, which runs every minute, was provided with an incorrect commit ID (a commit id from sandbox). As a result, the git diff calculation contained unpublished items.

Solution