-
-
Notifications
You must be signed in to change notification settings - Fork 320
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #876 from steveukx/feat/support-checkout-B
Add support for using the `-B` modifier instead of the default `-b` w…
- Loading branch information
Showing
6 changed files
with
74 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'simple-git': minor | ||
--- | ||
|
||
Support the use of `-B` in place of the default `-b` in checkout methods |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import type { SimpleGit } from '../../../typings'; | ||
import type { SimpleGitApi } from '../simple-git-api'; | ||
import { getTrailingOptions, remove, trailingFunctionArgument } from '../utils'; | ||
import { straightThroughStringTask } from './task'; | ||
|
||
function checkoutTask(args: string[]) { | ||
const commands = ['checkout', ...args]; | ||
if (commands[1] === '-b' && commands.includes('-B')) { | ||
commands[1] = remove(commands, '-B'); | ||
} | ||
|
||
return straightThroughStringTask(commands); | ||
} | ||
|
||
export default function (): Pick<SimpleGit, 'checkout' | 'checkoutBranch' | 'checkoutLocalBranch'> { | ||
return { | ||
checkout(this: SimpleGitApi) { | ||
return this._runTask( | ||
checkoutTask(getTrailingOptions(arguments, 1)), | ||
trailingFunctionArgument(arguments) | ||
); | ||
}, | ||
|
||
checkoutBranch(this: SimpleGitApi, branchName, startPoint) { | ||
return this._runTask( | ||
checkoutTask(['-b', branchName, startPoint, ...getTrailingOptions(arguments)]), | ||
trailingFunctionArgument(arguments) | ||
); | ||
}, | ||
|
||
checkoutLocalBranch(this: SimpleGitApi, branchName) { | ||
return this._runTask( | ||
checkoutTask(['-b', branchName, ...getTrailingOptions(arguments)]), | ||
trailingFunctionArgument(arguments) | ||
); | ||
}, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters