lechnerio-git-hooks 1.1.7 → 1.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/hooks/post-commit +104 -2
- package/package.json +1 -1
package/hooks/post-commit
CHANGED
|
@@ -99,9 +99,10 @@ if [ "$files_changed" -eq 0 ] || [ -z "$lines_changed" ]; then
|
|
|
99
99
|
echo
|
|
100
100
|
echo "1) Push to GitHub"
|
|
101
101
|
echo "2) Merge to Main"
|
|
102
|
+
echo "3) Merge to Main + Push"
|
|
102
103
|
echo -e "${GRAY}0) None${NC}"
|
|
103
104
|
echo
|
|
104
|
-
echo -n "Select option (1-
|
|
105
|
+
echo -n "Select option (1-3, Enter for Default or 0 to skip): "
|
|
105
106
|
read -r choice
|
|
106
107
|
choice=${choice:-1}
|
|
107
108
|
else
|
|
@@ -140,6 +141,56 @@ if [ "$files_changed" -eq 0 ] || [ -z "$lines_changed" ]; then
|
|
|
140
141
|
fi
|
|
141
142
|
fi
|
|
142
143
|
;;
|
|
144
|
+
3)
|
|
145
|
+
echo -e "${YELLOW}🔄 Merging to main + pushing...${NC}"
|
|
146
|
+
if [ "$DRY_RUN" = "true" ]; then
|
|
147
|
+
echo -e "${YELLOW}[DRY RUN] Would execute: git push --follow-tags && git push --tags${NC}"
|
|
148
|
+
echo -e "${YELLOW}[DRY RUN] Would execute: git checkout main && git pull && git merge $(git branch --show-current) && git push${NC}"
|
|
149
|
+
echo -e "${YELLOW}[DRY RUN] Would execute: git checkout $(git branch --show-current)${NC}"
|
|
150
|
+
else
|
|
151
|
+
current_branch=$(git branch --show-current)
|
|
152
|
+
_merge_push_ok=true
|
|
153
|
+
echo -e "${YELLOW}✈️ Pushing ${current_branch}...${NC}"
|
|
154
|
+
if ! git push --follow-tags || ! git push --tags; then
|
|
155
|
+
echo -e "${RED}❌ Failed to push ${current_branch}${NC}"
|
|
156
|
+
_merge_push_ok=false
|
|
157
|
+
fi
|
|
158
|
+
if [ "$_merge_push_ok" = true ]; then
|
|
159
|
+
echo -e "${GREEN}✅ Pushed ${current_branch}${NC}"
|
|
160
|
+
if ! git checkout main; then
|
|
161
|
+
echo -e "${RED}❌ Failed to checkout main${NC}"
|
|
162
|
+
_merge_push_ok=false
|
|
163
|
+
fi
|
|
164
|
+
fi
|
|
165
|
+
if [ "$_merge_push_ok" = true ]; then
|
|
166
|
+
if ! git pull; then
|
|
167
|
+
echo -e "${RED}❌ Failed to pull main${NC}"
|
|
168
|
+
git checkout "$current_branch"
|
|
169
|
+
_merge_push_ok=false
|
|
170
|
+
fi
|
|
171
|
+
fi
|
|
172
|
+
if [ "$_merge_push_ok" = true ]; then
|
|
173
|
+
if ! git merge "$current_branch"; then
|
|
174
|
+
echo -e "${RED}❌ Failed to merge ${current_branch} into main${NC}"
|
|
175
|
+
git checkout "$current_branch"
|
|
176
|
+
_merge_push_ok=false
|
|
177
|
+
fi
|
|
178
|
+
fi
|
|
179
|
+
if [ "$_merge_push_ok" = true ]; then
|
|
180
|
+
echo -e "${GREEN}✅ Merged ${current_branch} into main${NC}"
|
|
181
|
+
if ! git push; then
|
|
182
|
+
echo -e "${RED}❌ Failed to push main${NC}"
|
|
183
|
+
git checkout "$current_branch"
|
|
184
|
+
_merge_push_ok=false
|
|
185
|
+
fi
|
|
186
|
+
fi
|
|
187
|
+
if [ "$_merge_push_ok" = true ]; then
|
|
188
|
+
echo -e "${GREEN}✅ Pushed main${NC}"
|
|
189
|
+
git checkout "$current_branch"
|
|
190
|
+
echo -e "${GREEN}✅ Back on ${current_branch}${NC}"
|
|
191
|
+
fi
|
|
192
|
+
fi
|
|
193
|
+
;;
|
|
143
194
|
0)
|
|
144
195
|
echo -e "${YELLOW}⏭️ Skipping additional actions${NC}"
|
|
145
196
|
;;
|
|
@@ -239,9 +290,10 @@ elif exec < /dev/tty 2>/dev/null; then
|
|
|
239
290
|
echo
|
|
240
291
|
echo -e "1) Push to GitHub ${YELLOW}(default)${NC}"
|
|
241
292
|
echo "2) Merge to Main"
|
|
293
|
+
echo "3) Merge to Main + Push"
|
|
242
294
|
echo -e "${GRAY}0) None${NC}"
|
|
243
295
|
echo
|
|
244
|
-
echo -n "Select option (1-
|
|
296
|
+
echo -n "Select option (1-3, Enter for Default or 0 to skip): "
|
|
245
297
|
read -r choice
|
|
246
298
|
choice=${choice:-1}
|
|
247
299
|
else
|
|
@@ -281,6 +333,56 @@ case $choice in
|
|
|
281
333
|
fi
|
|
282
334
|
fi
|
|
283
335
|
;;
|
|
336
|
+
3)
|
|
337
|
+
echo -e "${YELLOW}🔄 Merging to main + pushing...${NC}"
|
|
338
|
+
if [ "$DRY_RUN" = "true" ]; then
|
|
339
|
+
echo -e "${YELLOW}[DRY RUN] Would execute: git push --follow-tags && git push --tags${NC}"
|
|
340
|
+
echo -e "${YELLOW}[DRY RUN] Would execute: git checkout main && git pull && git merge $(git branch --show-current) && git push${NC}"
|
|
341
|
+
echo -e "${YELLOW}[DRY RUN] Would execute: git checkout $(git branch --show-current)${NC}"
|
|
342
|
+
else
|
|
343
|
+
current_branch=$(git branch --show-current)
|
|
344
|
+
_merge_push_ok=true
|
|
345
|
+
echo -e "${YELLOW}✈️ Pushing ${current_branch}...${NC}"
|
|
346
|
+
if ! git push --follow-tags || ! git push --tags; then
|
|
347
|
+
echo -e "${RED}❌ Failed to push ${current_branch}${NC}"
|
|
348
|
+
_merge_push_ok=false
|
|
349
|
+
fi
|
|
350
|
+
if [ "$_merge_push_ok" = true ]; then
|
|
351
|
+
echo -e "${GREEN}✅ Pushed ${current_branch}${NC}"
|
|
352
|
+
if ! git checkout main; then
|
|
353
|
+
echo -e "${RED}❌ Failed to checkout main${NC}"
|
|
354
|
+
_merge_push_ok=false
|
|
355
|
+
fi
|
|
356
|
+
fi
|
|
357
|
+
if [ "$_merge_push_ok" = true ]; then
|
|
358
|
+
if ! git pull; then
|
|
359
|
+
echo -e "${RED}❌ Failed to pull main${NC}"
|
|
360
|
+
git checkout "$current_branch"
|
|
361
|
+
_merge_push_ok=false
|
|
362
|
+
fi
|
|
363
|
+
fi
|
|
364
|
+
if [ "$_merge_push_ok" = true ]; then
|
|
365
|
+
if ! git merge "$current_branch"; then
|
|
366
|
+
echo -e "${RED}❌ Failed to merge ${current_branch} into main${NC}"
|
|
367
|
+
git checkout "$current_branch"
|
|
368
|
+
_merge_push_ok=false
|
|
369
|
+
fi
|
|
370
|
+
fi
|
|
371
|
+
if [ "$_merge_push_ok" = true ]; then
|
|
372
|
+
echo -e "${GREEN}✅ Merged ${current_branch} into main${NC}"
|
|
373
|
+
if ! git push; then
|
|
374
|
+
echo -e "${RED}❌ Failed to push main${NC}"
|
|
375
|
+
git checkout "$current_branch"
|
|
376
|
+
_merge_push_ok=false
|
|
377
|
+
fi
|
|
378
|
+
fi
|
|
379
|
+
if [ "$_merge_push_ok" = true ]; then
|
|
380
|
+
echo -e "${GREEN}✅ Pushed main${NC}"
|
|
381
|
+
git checkout "$current_branch"
|
|
382
|
+
echo -e "${GREEN}✅ Back on ${current_branch}${NC}"
|
|
383
|
+
fi
|
|
384
|
+
fi
|
|
385
|
+
;;
|
|
284
386
|
0)
|
|
285
387
|
echo -e "${YELLOW}⏭️ Skipping additional actions${NC}"
|
|
286
388
|
;;
|