mirror of
				https://github.com/nvbn/thefuck.git
				synced 2025-10-30 22:54:14 +00:00 
			
		
		
		
	Merge branch 'Asday-master'
This commit is contained in:
		| @@ -188,6 +188,7 @@ using the matched rule and runs it. Rules enabled by default are as follows: | ||||
| * `git_pull_uncommitted_changes` – stashes changes before pulling and pops them afterwards; | ||||
| * `git_push` – adds `--set-upstream origin $branch` to previous failed `git push`; | ||||
| * `git_push_pull` – runs `git pull` when `push` was rejected; | ||||
| * `git_push_without_commits` – Creates an initial commit if you forget and only `git add .`, when setting up a new project; | ||||
| * `git_rebase_no_changes` – runs `git rebase --skip` instead of `git rebase --continue` when there are no changes; | ||||
| * `git_rm_local_modifications` –  adds `-f` or `--cached` when you try to `rm` a locally modified file; | ||||
| * `git_rm_recursive` – adds `-r` when you try to `rm` a directory; | ||||
|   | ||||
							
								
								
									
										27
									
								
								tests/rules/test_git_push_without_commits.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								tests/rules/test_git_push_without_commits.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,27 @@ | ||||
| import pytest | ||||
|  | ||||
| from tests.utils import Command | ||||
| from thefuck.rules.git_push_without_commits import ( | ||||
|     fix, | ||||
|     get_new_command, | ||||
|     match, | ||||
| ) | ||||
|  | ||||
| command = 'git push -u origin master' | ||||
| expected_error = ''' | ||||
| error: src refspec master does not match any. | ||||
| error: failed to push some refs to 'git@github.com:User/repo.git' | ||||
| ''' | ||||
|  | ||||
|  | ||||
| @pytest.mark.parametrize('command', [Command(command, stderr=expected_error)]) | ||||
| def test_match(command): | ||||
|     assert match(command) | ||||
|  | ||||
|  | ||||
| @pytest.mark.parametrize('command, result', [( | ||||
|     Command(command, stderr=expected_error), | ||||
|     fix.format(command=command), | ||||
| )]) | ||||
| def test_get_new_command(command, result): | ||||
|     assert get_new_command(command) == result | ||||
							
								
								
									
										14
									
								
								thefuck/rules/git_push_without_commits.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								thefuck/rules/git_push_without_commits.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,14 @@ | ||||
| import re | ||||
| from thefuck.specific.git import git_support | ||||
|  | ||||
| fix = u'git commit -m "Initial commit." && {command}' | ||||
| refspec_does_not_match = re.compile(r'src refspec \w+ does not match any\.') | ||||
|  | ||||
|  | ||||
| @git_support | ||||
| def match(command): | ||||
|     return bool(refspec_does_not_match.search(command.stderr)) | ||||
|  | ||||
|  | ||||
| def get_new_command(command): | ||||
|     return fix.format(command=command.script) | ||||
		Reference in New Issue
	
	Block a user