forked from djonasdev/DbContextScope
-
Notifications
You must be signed in to change notification settings - Fork 0
/
createBranch.ps1
31 lines (23 loc) · 900 Bytes
/
createBranch.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
param([string]$IssueName)
$branchName = $IssueName
###########################################################
# clean input string #
###########################################################
# character replacement
$rWhiteSpace = [regex]'[ ]{1,}'
$rSlash = [regex]'[/]{1,}'
$rBackSlash = [regex]'[\\]{1,}'
$rSeperator = [regex]'[-]{2,}'
$branchName = $rWhiteSpace.Replace($branchName, "-")
$branchName = $rSlash.Replace($branchName, "-")
$branchName = $rBackSlash.Replace($branchName, "-")
$branchName = $rSeperator.Replace($branchName, "-")
$branchName = $branchName.Trim('-')
# limit bracnhname to 40 characters length
$branchName = $branchName.Substring('0', '40')
echo "New branch '$branchName' created"
git checkout -b $branchName
git add .
git add -u
#git commit -m "Description of my changes for issue $IssueName"
#git push -u origin $branchName