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


##########
nifi-extension-bundles/nifi-github-bundle/nifi-github-extensions/src/main/java/org/apache/nifi/github/GitHubRepositoryClient.java:
##########
@@ -398,6 +398,34 @@ public Optional<String> getContentSha(final String path, 
final String branch) th
         });
     }
 
+    /**
+     * Gets the blob SHA for the given path at a specific commit.
+     * This is used for atomic commit operations where we need the blob SHA at 
the
+     * user's expected version, not the current version.
+     *
+     * @param path the path to the content
+     * @param commitSha the commit SHA
+     * @return blob SHA for the given file at the specified commit, or empty 
optional
+     *
+     * @throws IOException if an I/O error happens calling GitHub
+     * @throws FlowRegistryException if a non I/O error happens calling GitHub
+     */
+    @Override
+    public Optional<String> getContentShaAtCommit(final String path, final 
String commitSha) throws IOException, FlowRegistryException {
+        final String resolvedPath = getResolvedPath(path);
+        logger.debug("Getting content SHA for [{}] at commit [{}] in repo [{}] 
", resolvedPath, commitSha, repository.getName());

Review Comment:
   ```suggestion
           logger.debug("Getting content SHA for [{}] at commit [{}] in 
repository [{}]", resolvedPath, commitSha, repository.getName());
   ```



##########
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:
   Is the Commit SHA also valid as the Commit ID? The Commit ID is often the 
short form, so it sounds like it should work, but just wanted to confirm.



-- 
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