This repository was archived by the owner on Sep 9, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 75
Update Pre Commit Hook Script #89
Open
Marto32
wants to merge
5
commits into
sk-:master
Choose a base branch
from
Marto32:mm/pre-commit-updates
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
7fdf069
Update precommit hook to work across OSs git
Marto32 5727349
Update precommit hook to work across OSs hg
Marto32 17f0afc
Update git lint argument - git
Marto32 7092839
Update git lint argument - mercurial
Marto32 7d93f36
Replace variable with command when piping to xargs
Marto32 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Bash does not store new lines nor
\0, so the above won't work. See http://stackoverflow.com/questions/6570531/assign-string-containing-null-character-0-to-a-variable-in-bash#answer-22985397Apparently the only bullet proof solution is to save the result to a file, but that has the complications of deleting the temporary file even in case of errors.
Another alternative is to run the command twice. The first time to check whether the output is empty. And the second piped to xargs.
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.
Would it be possible to convert this to a python script and store those results as variables? Or does the hook have to be a shell script?
Uh oh!
There was an error while loading. Please reload this page.
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.
@sk- I opted for the latter solution and used the variable to check if there is output, if there is, I reran the command and piped it into xargs. I tested the git script by running it manually line by line - works on OSX 10.11.6 (I did not test mercurial).