pvillard31 commented on code in PR #10778:
URL: https://github.com/apache/nifi/pull/10778#discussion_r2718080072


##########
nifi-extension-bundles/nifi-atlassian-bundle/nifi-atlassian-extensions/src/main/java/org/apache/nifi/atlassian/bitbucket/BitbucketRepositoryClient.java:
##########
@@ -460,10 +467,10 @@ private String createContentDataCenter(final 
GitCreateContentRequest request, fi
             multipartBuilder.addPart(FIELD_MESSAGE, 
StandardHttpContentType.TEXT_PLAIN, message.getBytes(StandardCharsets.UTF_8));
         }
 
-        final String existingContentSha = request.getExistingContentSha();
-        final boolean existingContentProvided = existingContentSha != null && 
!existingContentSha.isBlank();
-        if (existingContentProvided) {
-            multipartBuilder.addPart(FIELD_SOURCE_COMMIT_ID, 
StandardHttpContentType.TEXT_PLAIN, 
existingContentSha.getBytes(StandardCharsets.UTF_8));
+        // Use expectedCommitSha for atomic commit - Bitbucket DC will reject 
if the file has changed since this commit
+        final String expectedCommitSha = request.getExpectedCommitSha();
+        if (expectedCommitSha != null && !expectedCommitSha.isBlank()) {
+            multipartBuilder.addPart(FIELD_SOURCE_COMMIT_ID, 
StandardHttpContentType.TEXT_PLAIN, 
expectedCommitSha.getBytes(StandardCharsets.UTF_8));

Review Comment:
   Yes based on my understanding of the documentation the SHA is valid:
   - 
https://developer.atlassian.com/cloud/bitbucket/rest/api-group-source/#api-repositories-workspace-repo-slug-src-post
   > A comma-separated list of SHA1s of the commits that should be the parents 
of the newly created commit
   - https://docs.gitlab.com/api/repository_files/
   > last_commit_id, string, SHA of the last commit that modified this file
   - https://learn.microsoft.com/en-us/rest/api/azure/devops/git/pushes/create
   > examples show a sull SHA for the commit ID



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to