mirror of
				https://github.com/nvbn/thefuck.git
				synced 2025-10-30 22:54:14 +00:00 
			
		
		
		
	Merge pull request #230 from scorphus/git-diff-staged-rule
add(rule): add the new git_diff_staged rule
This commit is contained in:
		| @@ -159,6 +159,7 @@ using the matched rule and runs it. Rules enabled by default are as follows: | ||||
| * `java` – removes `.java` extension when running Java programs; | ||||
| * `git_add` – fix *"Did you forget to 'git add'?"*; | ||||
| * `git_checkout` – creates the branch before checking-out; | ||||
| * `git_diff_staged` – adds `--staged` to previous `git diff` with unexpected output; | ||||
| * `git_no_command` – fixes wrong git commands like `git brnch`; | ||||
| * `git_pull` – sets upstream before executing previous `git pull`; | ||||
| * `git_push` – adds `--set-upstream origin $branch` to previous failed `git push`; | ||||
|   | ||||
							
								
								
									
										27
									
								
								tests/rules/test_git_diff_staged.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								tests/rules/test_git_diff_staged.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,27 @@ | ||||
| import pytest | ||||
| from thefuck.rules.git_diff_staged import match, get_new_command | ||||
| from tests.utils import Command | ||||
|  | ||||
|  | ||||
| @pytest.mark.parametrize('command', [ | ||||
|     Command(script='git diff'), | ||||
|     Command(script='git df'), | ||||
|     Command(script='git ds')]) | ||||
| def test_match(command): | ||||
|     assert match(command, None) | ||||
|  | ||||
|  | ||||
| @pytest.mark.parametrize('command', [ | ||||
|     Command(script='git tag'), | ||||
|     Command(script='git branch'), | ||||
|     Command(script='git log')]) | ||||
| def test_not_match(command): | ||||
|     assert not match(command, None) | ||||
|  | ||||
|  | ||||
| @pytest.mark.parametrize('command, new_command', [ | ||||
|     (Command('git diff'), 'git diff --staged'), | ||||
|     (Command('git df'), 'git df --staged'), | ||||
|     (Command('git ds'), 'git ds --staged')]) | ||||
| def test_get_new_command(command, new_command): | ||||
|     assert get_new_command(command, None) == new_command | ||||
							
								
								
									
										6
									
								
								thefuck/rules/git_diff_staged.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								thefuck/rules/git_diff_staged.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,6 @@ | ||||
| def match(command, settings): | ||||
|     return command.script.startswith('git d') | ||||
|  | ||||
|  | ||||
| def get_new_command(command, settings): | ||||
|     return '{} --staged'.format(command.script) | ||||
		Reference in New Issue
	
	Block a user