This repository was archived by the owner on Feb 23, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit_commit.ps1
More file actions
144 lines (114 loc) · 7.65 KB
/
git_commit.ps1
File metadata and controls
144 lines (114 loc) · 7.65 KB
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# Banner
Write-Host @"
███████╗██╗ ██╗████████╗██╗ ██╗██████╗ ███████╗ ██╗███╗ ██╗███████╗██╗ ██████╗ ██╗ ██╗████████╗
██╔════╝██║ ██║╚══██╔══╝██║ ██║██╔══██╗██╔════╝ ██║████╗ ██║██╔════╝██║██╔════╝ ██║ ██║╚══██╔══╝
█████╗ ██║ ██║ ██║ ██║ ██║██████╔╝█████╗ ██║██╔██╗ ██║███████╗██║██║ ███╗███████║ ██║
██╔══╝ ██║ ██║ ██║ ██║ ██║██╔══██╗██╔══╝ ██║██║╚██╗██║╚════██║██║██║ ██║██╔══██║ ██║
██║ ╚██████╔╝ ██║ ╚██████╔╝██║ ██║███████╗ ██║██║ ╚████║███████║██║╚██████╔╝██║ ██║ ██║
╚═╝ ╚═════╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝ ╚═╝╚═╝ ╚═══╝╚══════╝╚═╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝
█████╗ ███╗ ██╗██████╗ ██████╗ ██████╗ ██╗██████╗ █████╗ ██████╗ ██████╗ ██╗ ██╗ ██████╗ █████╗ ████████╗██╗ ██████╗ ███╗ ██╗
██╔══██╗████╗ ██║██╔══██╗██╔══██╗██╔═══██╗██║██╔══██╗ ██╔══██╗██╔══██╗██╔══██╗██║ ██║██╔════╝██╔══██╗╚══██╔══╝██║██╔═══██╗████╗ ██║
███████║██╔██╗ ██║██║ ██║██████╔╝██║ ██║██║██║ ██║ ███████║██████╔╝██████╔╝██║ ██║██║ ███████║ ██║ ██║██║ ██║██╔██╗ ██║
██╔══██║██║╚██╗██║██║ ██║██╔══██╗██║ ██║██║██║ ██║ ██╔══██║██╔═══╝ ██╔═══╝ ██║ ██║██║ ██╔══██║ ██║ ██║██║ ██║██║╚██╗██║
██║ ██║██║ ╚████║██████╔╝██║ ██║╚██████╔╝██║██████╔╝ ██║ ██║██║ ██║ ███████╗██║╚██████╗██║ ██║ ██║ ██║╚██████╔╝██║ ╚████║
╚═╝ ╚═╝╚═╝ ╚═══╝╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚══════╝╚═╝ ╚═════╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝
"Unlocking the Future, One Insight at a Time"
"@
# Section: System Check
Write-Host "=== System Check ==="
Write-Host "Checking system status..."
# Section: Commit Message
Write-Host "=== Commit Message ==="
# Function to validate if a commit message is provided
function Validate-CommitMessage {
$message = Read-Host "✏️ Enter your commit message: "
if (-not $message) {
Write-Host "Commit message cannot be empty. Please enter a commit message."
return $false
}
else {
return $true
}
}
# Prompt the user for a commit message until a non-empty message is entered
while (-not (Validate-CommitMessage)) {
continue
}
Write-Host
# Section: Git Add
Write-Host "=== Git Add ==="
git add .
$add_exit_code = $LASTEXITCODE
if ($add_exit_code -ne 0) {
git add . > add.log
}
Write-Host
# Section: Check Git Add Success
Write-Host "=== Check Git Add Success ==="
if ($add_exit_code -eq 0) {
Write-Host "Git add successful! ✅"
Remove-Item -Path add.log -Force
}
else {
Write-Host "Git add failed. Please check your changes and try again. ❌"
Write-Host "Errors encountered during git add. Please check add.log for more details."
}
Write-Host
# Section: Git Commit
Write-Host "=== Git Commit ==="
git commit -m "$message"
$commit_exit_code = $LASTEXITCODE
if ($commit_exit_code -ne 0) {
git commit -m "$message" > commit.log
}
Write-Host
# Section: Check Git Commit Success
Write-Host "=== Check Git Commit Success ==="
if ($commit_exit_code -eq 0) {
Write-Host "Commit successful! 🎉"
Remove-Item -Path commit.log -Force
}
else {
Write-Host "Commit failed. Please check your changes and try again. ❌"
Write-Host "Errors encountered during commit. Please check commit.log for more details."
}
Write-Host
# Section: Push Commit
Write-Host "=== Push Commit ==="
$current_branch = git rev-parse --abbrev-ref HEAD
git push
$push_exit_code = $LASTEXITCODE
if ($push_exit_code -ne 0) {
git push > push.log
}
Write-Host
# Section: Check Push Commit Success
Write-Host "=== Check Push Commit Success ==="
if ($push_exit_code -eq 0) {
Write-Host "Commit pushed successfully! 🚀"
Remove-Item -Path push.log -Force
}
else {
Write-Host "Push failed. Please check your network connection and try again. ❌"
Write-Host "Errors encountered during push. Please check push.log for more details."
}
Write-Host
# Section: Push Commit Upstream
Write-Host "=== Push Commit Upstream ==="
git push -u origin $current_branch
$push_upstream_exit_code = $LASTEXITCODE
if ($push_upstream_exit_code -ne 0) {
git push -u origin $current_branch > push_upstream.log
}
Write-Host
# Section: Check Push Commit Upstream Success
Write-Host "=== Check Push Commit Upstream Success ==="
if ($push_upstream_exit_code -eq 0) {
Write-Host "Branch published and commit pushed successfully! 🚀"
Remove-Item -Path push_upstream.log -Force
}
else {
Write-Host "Push upstream failed. Please check your network connection and try again. ❌"
Write-Host "Errors encountered during push upstream. Please check push_upstream.log for more details."
}
Write-Host