mirror of
				https://github.com/nvbn/thefuck.git
				synced 2025-10-30 22:54:14 +00:00 
			
		
		
		
	Add the git_checkout rule
It creates a branch before checking-out to it if the branch does not exist.
This commit is contained in:
		| @@ -146,6 +146,7 @@ using matched rule and run it. Rules enabled by default: | |||||||
| * `cp_omitting_directory` – adds `-a` when you `cp` directory; | * `cp_omitting_directory` – adds `-a` when you `cp` directory; | ||||||
| * `fix_alt_space` – replaces Alt+Space with Space character; | * `fix_alt_space` – replaces Alt+Space with Space character; | ||||||
| * `git_add` – fix *"Did you forget to 'git add'?"*; | * `git_add` – fix *"Did you forget to 'git add'?"*; | ||||||
|  | * `git_checkout` – creates the branch before checking-out; | ||||||
| * `git_no_command` – fixes wrong git commands like `git brnch`; | * `git_no_command` – fixes wrong git commands like `git brnch`; | ||||||
| * `git_push` – adds `--set-upstream origin $branch` to previous failed `git push`; | * `git_push` – adds `--set-upstream origin $branch` to previous failed `git push`; | ||||||
| * `has_exists_script` – prepends `./` when script/binary exists; | * `has_exists_script` – prepends `./` when script/binary exists; | ||||||
|   | |||||||
							
								
								
									
										15
									
								
								thefuck/rules/git_checkout.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								thefuck/rules/git_checkout.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,15 @@ | |||||||
|  | import re | ||||||
|  |  | ||||||
|  |  | ||||||
|  | def match(command, settings): | ||||||
|  |     return ('git' in command.script | ||||||
|  |             and 'did not match any file(s) known to git.' in command.stderr | ||||||
|  |             and "Did you forget to 'git add'?" not in command.stderr) | ||||||
|  |  | ||||||
|  |  | ||||||
|  | def get_new_command(command, settings): | ||||||
|  |     missing_file = re.findall( | ||||||
|  |             r"error: pathspec '([^']*)' " | ||||||
|  |             "did not match any file\(s\) known to git.", command.stderr)[0] | ||||||
|  |  | ||||||
|  |     return 'git branch {} && {}'.format(missing_file, command.script) | ||||||
		Reference in New Issue
	
	Block a user