mirror of
				https://github.com/lingble/chatwoot.git
				synced 2025-10-30 18:47:51 +00:00 
			
		
		
		
	fix: Update pre-commit hook to handle staged deleted files (#11357)
The pre-commit hook was failing when there were staged deleted files because: - It was using 'ls' to filter files, which fails when they don't exist in the filesystem - Deleted files are still in Git's staging area but not in the filesystem Changes made: 1. Added a check to filter files with 'test -f' before passing to Rubocop 2. Added the same check for staging Rubocop's changes 3. Added '|| true' to prevent errors when no files match the filters This ensures the pre-commit hook completes successfully even when files are staged for deletion.
This commit is contained in:
		| @@ -4,8 +4,8 @@ | |||||||
| # lint js and vue files | # lint js and vue files | ||||||
| npx --no-install lint-staged | npx --no-install lint-staged | ||||||
|  |  | ||||||
| # lint only staged ruby files | # lint only staged ruby files that still exist (not deleted) | ||||||
| git diff --name-only --cached | xargs ls -1 2>/dev/null | grep '\.rb$' | xargs bundle exec rubocop --force-exclusion -a | git diff --name-only --cached | xargs -I {} sh -c 'test -f "{}" && echo "{}"' | grep '\.rb$' | xargs -I {} bundle exec rubocop --force-exclusion -a "{}" || true | ||||||
|  |  | ||||||
| # stage rubocop changes to files | # stage rubocop changes to files | ||||||
| git diff --name-only --cached | xargs git add | git diff --name-only --cached | xargs -I {} sh -c 'test -f "{}" && git add "{}"' || true | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Sojan Jose
					Sojan Jose