-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.ps1
82 lines (57 loc) · 2.8 KB
/
run.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
cd $pwd
.\bin\BankReport.exe -c "C:\Users\Mobolaji.Aina\Documents\c_sharp\bank_reports_runner\conf\bank_report_config.json"
Write-Host "Listing branches..."
git branch
$shouldCommit = Read-Host -Prompt "Do you want to commit the application on the current branch? (type 'y' or 'n')"
while ($shouldCommit -eq $null){
$shouldCommit = Read-Host -Prompt "Do you want to commit the application on the current branch? (type 'y' or 'n')"
}
if ($shouldCommit -eq 'y'){
$commitMessage= Read-Host -Prompt 'Please type commit message'
git add .
git commit -m $commitMessage
}
$current_branch_string = Get-Content ".git/HEAD"
$current_branch = $current_branch_string.Replace("ref: refs/heads/","")
if ($current_branch -ne "master" ){
$branch_response = Read-Host -Prompt "Do you want to merge to the local master branch? (type 'y' or 'n')"
while ($branch_response -eq $null){
$branch_response = Read-Host -Prompt "Do you want to merge to the local master branch? (type 'y' or 'n')"
}
if ($branch_response -eq 'y'){
Write-Host "Running: git merge $current_branch"
git merge $current_branch
}
}
$push_response= Read-Host -Prompt "Do you want to push to the remote master branch? (type 'y' or 'n')"
while ($push_response -eq $null){
$push_response= Read-Host -Prompt "Do you want to push to the remote master branch? (type 'y' or 'n')"
}
if($push_response -eq 'y' ){
$filepath ="$pwd\remote_repo.txt"
Write-Host "Checking saved remote repo in $pwd\remote_repo.txt "
if([System.IO.File]::Exists($filepath)){
$remote_repo_url = Get-Content $filepath
}
Write-Host "Saved remote repo "$remote_repo_url
if($remote_repo_url -eq $null){
$remote_repo_url = Read-Host -Prompt "Please type the URL of the remote repository"
while ($remote_repo_url -eq $null){
$remote_repo_url = Read-Host -Prompt "Please type the URL of the remote repository"
}
echo $remote_repo_url | Out-File -FilePath "$pwd\remote_repo.txt"
}
$remote_repo_name = git remote
if($remote_repo_name -eq $null -Or $remote_repo_name -eq 'n'){
Write-Host "git remote add origin $remote_repo_url"
git remote add origin $remote_repo_url
}
$push_branch = Read-Host -Prompt "Please type the name of the branch you wish to push"
while ($push_branch -eq $null){
$push_branch = Read-Host -Prompt "Please type the name of the branch you wish to push"
}
Write-Host "Running command git push -u origin $push_branch..."
git push -u origin $push_branch --force
Write-Host "checking remote branch: "
git remote
}