mingyen066 commented on code in PR #20699:
URL: https://github.com/apache/kafka/pull/20699#discussion_r2438829160


##########
release/git.py:
##########
@@ -33,12 +34,22 @@ def __defaults(kwargs):
 
 def has_staged_changes(**kwargs):
     __defaults(kwargs)
-    execute("git diff --cached --exit-code --quiet", **kwargs)
+    try:
+        # 0: no staged changes; non-zero: there are staged changes

Review Comment:
   This is wrong. 
   non-zero(has diff) will raise exception since function execute use 
`subprocess.check_output`



##########
release/git.py:
##########
@@ -33,12 +34,22 @@ def __defaults(kwargs):
 
 def has_staged_changes(**kwargs):
     __defaults(kwargs)
-    execute("git diff --cached --exit-code --quiet", **kwargs)
+    try:
+        # 0: no staged changes; non-zero: there are staged changes
+        execute("git diff --cached --exit-code --quiet", **kwargs)
+        return False
+    except subprocess.CalledProcessError:
+        return True 
 
 
 def has_unstaged_changes(**kwargs):
     __defaults(kwargs)
-    execute("git diff --exit-code --quiet", **kwargs)
+    try:
+        # 0: no unstaged changes; non-zero: there are unstaged changes

Review Comment:
   ditto



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