Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use git attributes for better python diff #76

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

wpyoga
Copy link

@wpyoga wpyoga commented Jun 29, 2023

Use .gitattributes file:

*.py diff=python

So that git diff shows the Python function name:

@@ -284,7 +284,7 @@ def _send_receive(self,

Instead of just the class name:

@@ -284,7 +284,7 @@ class Serial(CommonModbusFunctions):

@brainelectronics
Copy link
Owner

Isn't it the default? It seems so according to https://stackoverflow.com/a/18948381
I can also not see a difference after placing this file

@wpyoga
Copy link
Author

wpyoga commented Jul 4, 2023

Hmm... I've retested on my system:

$ git --version
git version 2.41.0

This is a git diff example without the .gitattributes entry:

$ git diff
diff --git a/umodbus/serial.py b/umodbus/serial.py
index 04e9c56..a78b29e 100644
--- a/umodbus/serial.py
+++ b/umodbus/serial.py
@@ -320,6 +320,8 @@ class Serial(CommonModbusFunctions):
         :returns:   Modbus response content
         :rtype:     bytes
         """
+        print("Response: {}".format(response.hex()))
+
         if len(response) == 0:
             raise OSError('no data received from slave')
 

This is the same command, with the .gitattributes entry:

$ git diff
diff --git a/umodbus/serial.py b/umodbus/serial.py
index 04e9c56..a78b29e 100644
--- a/umodbus/serial.py
+++ b/umodbus/serial.py
@@ -320,6 +320,8 @@ def _validate_resp_hdr(self,
         :returns:   Modbus response content
         :rtype:     bytes
         """
+        print("Response: {}".format(response.hex()))
+
         if len(response) == 0:
             raise OSError('no data received from slave')
 

How does it look like on your system? Do you have a ~/.gitconfig, ~/.config/git/config, or /etc/gitconfig file? I don't have any of those on my system.

Either way, this PR is not very important -- it only concerns git diff output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants