-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGitCommit.ps1
63 lines (52 loc) · 1.72 KB
/
GitCommit.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
<#
Git Helpers for PowerShell
Author: Damian Suess - 2018-07-30
Revision: 3 - 2019-01-16
Resources:
https://stackoverflow.com/questions/2157554/how-to-handle-command-line-arguments-in-powershell
TO DO:
[ ] Add -a switch to add all new files to commit
[ ] Add -o to specify repo if other than, "Origin"
Change Log:
2019-0321 - 4 - Renamed from GitCheckin to GitCommit, cause it is
2019-0116 - 3 - Cleaned up functionality and added help
#>
# Commandline Params ---
param (
[Parameter(Mandatory=$true)][string]$msg,
[Parameter(Mandatory=$false)][switch]$push = $false,
[Parameter(Mandatory=$false)][switch]$help = $false
);
# Include Files---------
. "$PSScriptRoot/lib/GitHelpers.ps1";
# Our code -------------
if ($h -eq $true)
{
Write-Host "Git Commit HELP";
Write-Host "-----------------";
Write-Host "Pushes branch to remote device" -ForegroundColor Yellow;
Write-Host " GitCommit ""<MESSAGE>"" Check-in code with message and auto-PUSH" -ForegroundColor Yellow;
Write-Host " GitCommit ""<MESSAGE>"" -push Check-in but DO NOT push changes" -ForegroundColor Yellow;
Write-Host " GitCommit -h This help text" -ForegroundColor Yellow;
Write-Host "";
exit;
}
if ($msg.Trim() -eq [String]::Empty)
{
Write-Host "Missing input: You must supply a commit message!" -ForegroundColor red;
exit;
}
[string]$branch = GitCurrentBranch;
if ($branch.Trim() -eq "")
{
Write-Host "No repository found in currect directory." -ForegroundColor red;
exit;
}
Write-Host "Git Commiting..." -ForegroundColor yellow;
GitCommit($msg)($a);
if ($push -eq $true)
{
Write-Host "Git Commiting..." -ForegroundColor yellow;
GitPush("origin")($branch);
}
Write-Host "Done!" -ForegroundColor Green;