-
-
Notifications
You must be signed in to change notification settings - Fork 116
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
feat: permissive git diff parameter #185
Conversation
Codecov Report
@@ Coverage Diff @@
## master #185 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 19 19
Lines 459 462 +3
=========================================
+ Hits 459 462 +3
Continue to review full report at Codecov.
|
Hi @nvuillam ! I copy paste my comment from the related issue I have questions:
Suggestion: the parameter name must follow the cli parameter apache convention. I suggest the following Please add me to your fork so I can contribute and help you solve CI/CD issues you may encounter |
Manage a new argument --permissivediff to add the following parameters to git diff call [ '--ignore-all-space', '--ignore-blank-lines', '--ignore-cr-at-eol', '--word-diff-regex', ] It allows to avoid detecting as a difference the indentation/spaces stuff
520f5e7
to
7c0fa4f
Compare
follow apache command line
@scolladon I see you made the code more clean, nice ! :) When do you think this could be released ? It would greatly help sfdx-hardis ^^ |
Hi @nvuillam !
We are going to discuss about it today with @mehdisfdc and see how we can improve (if we can) and when to ship it |
That's great, thanks for the feedback :) |
README.md
Outdated
trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL] | ||
|
||
OPTIONS | ||
-D, --ignore-destructive=ignore-destructive ignore file to use | ||
|
||
-P, --permissive-diff ignore git diff white char (space, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@scolladon As discussed together, would you prefer to name the new command -W, --ignore-whitespace
instead of -P, --permissive-diff
? Both are fine with me.
@nvuillam Any opinion on this alternative name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mehdisfdc --ignore-whitespace-diff maybe ? :)
Anyway, while the capability is here, I don't matter the argument name :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like -W, --ignore-whitespace
👍
'--ignore-all-space', | ||
'--ignore-blank-lines', | ||
'--ignore-cr-at-eol', | ||
'--word-diff-regex', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nvuillam According to the git documentation, the --word-diff-regex
parameter expects a <regex>
value.
Otherwise it may apply a regex that is set locally in your gitattributes or git-config (extract from doc: "The regex can also be set via a diff driver or configuration option, see gitattributes[5] or git-config[1]. Giving it explicitly overrides any diff driver or configuration setting.").
To make sure the behaviour of this command is consistent for all SGD users, what do you think about specifying explicitly the regex to use? In other words, I suggesting to modify line 10 to specify explicitly the <regex>
in --word-diff-regex=<regex>
(I guess you could look into you gitattributes and git-config to retrieve the value that you used during your tests).
@scolladon To go further, in addition to specifying explicitly the default regex to apply, we could even offer the ability for the users to override it with their own regex (but that would a "nice-to-have" feature, while ensure a consistent behaviour in the command in more important IMHO).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mehdisfdc I love the idea to let the user override the default regex, I will implement it with the new parameter name (once everyone is ok) and with the default regex value
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More flexibility for the user, I fully agree, great suggestion :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I bounce on @mehdisfdc's message, @nvuillam could you give us the git config taken by --word-diff-regex
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sorry, I just used the parameter and I think I viewed a difference compared to without, but i've not sent any value to this parameter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you retry on your side to make sure it does something ?
And if it does something on your side, as you don't use any regex with it, could you send us your gitattributes and git config please ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have any .gitattributes defined
About git config, except user.name & user.email, I use
- core.longpaths=true
- core.quotepath=false
I'll try to make new tests, but unfortunately my work week is already busy, it may wait until next week :/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But why not publishing as it is now, and send --word-diff-regex to git if --word-diff-regex is sent to sfdx-git-delta, and append --word-diff-regex value only if it is sent ? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer not to do that because if no parameter are given to --word-diff-regex
then it uses the local configuration in .gitattributes
and .git/config
, which can be anything and could lead to unexpected behaviour
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, I poced around and play a little bit with it.
It is also true for me that --word-diff-regex
is required to have the right behavior.
I dig a little bit more in the documentation of this parameter in git and I found that there are default regex used (which are appened to the override foundable in .gitattributes
and .git/config
)
I wonder if we will have issues about this and how it will be to debug 😅 but I don't think it will be used by most of the users.
With that knowledge, it looks good to me 😄 for the version without the regex passed in arguments
Code Climate has analyzed commit db0dc0c and detected 0 issues on this pull request. View more on Code Climate. |
Manage a new argument --permissivediff to add the following parameters to git diff call
It allows to avoid detecting as a difference the indentation/spaces stuff
Fixes #184