mirror of
				https://github.com/nvbn/thefuck.git
				synced 2025-10-30 22:54:14 +00:00 
			
		
		
		
	git_push: Handle branch names containing 'set-upstream' (#759)
This should fix https://github.com/nvbn/thefuck/issues/723 (IndexError when using bitbucket)
This commit is contained in:
		
				
					committed by
					
						 Joseph Frazier
						Joseph Frazier
					
				
			
			
				
	
			
			
			
						parent
						
							7c858fadb3
						
					
				
				
					commit
					c205683a8d
				
			| @@ -15,6 +15,19 @@ To push the current branch and set the remote as upstream, use | ||||
| '''.format(branch_name, branch_name) | ||||
|  | ||||
|  | ||||
| @pytest.fixture | ||||
| def output_bitbucket(): | ||||
|     return '''Total 0 (delta 0), reused 0 (delta 0) | ||||
| remote: | ||||
| remote: Create pull request for feature/set-upstream: | ||||
| remote:   https://bitbucket.org/set-upstream | ||||
| remote: | ||||
| To git@bitbucket.org:test.git | ||||
|    e5e7fbb..700d998  feature/set-upstream -> feature/set-upstream | ||||
| Branch feature/set-upstream set up to track remote branch feature/set-upstream from origin. | ||||
| ''' | ||||
|  | ||||
|  | ||||
| @pytest.mark.parametrize('script, branch_name', [ | ||||
|     ('git push', 'master'), | ||||
|     ('git push origin', 'master')]) | ||||
| @@ -22,6 +35,10 @@ def test_match(output, script, branch_name): | ||||
|     assert match(Command(script, output)) | ||||
|  | ||||
|  | ||||
| def test_match_bitbucket(output_bitbucket): | ||||
|     assert not match(Command('git push origin', output_bitbucket)) | ||||
|  | ||||
|  | ||||
| @pytest.mark.parametrize('script, branch_name', [ | ||||
|     ('git push master', None), | ||||
|     ('ls', 'master')]) | ||||
|   | ||||
| @@ -6,7 +6,7 @@ from thefuck.specific.git import git_support | ||||
| @git_support | ||||
| def match(command): | ||||
|     return ('push' in command.script_parts | ||||
|             and 'set-upstream' in command.output) | ||||
|             and 'git push --set-upstream' in command.output) | ||||
|  | ||||
|  | ||||
| def _get_upstream_option_index(command_parts): | ||||
|   | ||||
		Reference in New Issue
	
	Block a user