-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbulk-commit-generator.py
More file actions
executable file
·1875 lines (1662 loc) · 70.4 KB
/
Copy pathbulk-commit-generator.py
File metadata and controls
executable file
·1875 lines (1662 loc) · 70.4 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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env python3
"""
Bulk Commit Generator v2.0
~~~~~~~~~~~~~~~~~~~~~~~~~~
A professional, production-ready CLI tool for generating real Git commits
with actual file changes, supporting signed and unsigned commits.
Repository: https://github.com/mkr-infinity/most-commited
Author: Mohammad Kaif Raja (mkr-infinity)
Copyright: Copyright (c) 2026 Mohammad Kaif Raja. All Rights Reserved.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ If you modify, redistribute, fork, or reuse this project, please ~
~ provide proper credit to Mohammad Kaif Raja (mkr-infinity). ~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND.
Unauthorized removal of attribution is strictly prohibited.
"""
from __future__ import annotations
import os
import sys
import subprocess
import random
import time
import argparse
from datetime import datetime
from typing import Optional, Tuple
def ensure_python_dependency(package: str, import_name: Optional[str] = None) -> None:
"""Install a required Python dependency before importing it.
The script is intentionally self-contained, so a missing UI dependency should
be fixed automatically instead of crashing with ModuleNotFoundError.
"""
module_name = import_name or package
try:
__import__(module_name)
return
except ImportError:
pass
print(f"Installing missing dependency: {package}")
install_attempts = [
[sys.executable, "-m", "pip", "install", "--user", package],
[sys.executable, "-m", "pip", "install", "--break-system-packages", package],
]
last_error = ""
for command in install_attempts:
try:
result = subprocess.run(
command,
capture_output=True,
text=True,
timeout=180,
)
except (OSError, subprocess.TimeoutExpired) as exc:
last_error = str(exc)
continue
if result.returncode == 0:
try:
__import__(module_name)
print(f"Installed dependency successfully: {package}")
return
except ImportError as exc:
last_error = str(exc)
continue
last_error = result.stderr.strip() or result.stdout.strip()
print(f"Could not install required dependency: {package}")
print(last_error)
print(f"Install it manually with: {sys.executable} -m pip install {package}")
sys.exit(1)
ensure_python_dependency("rich")
from rich.console import Console
from rich.panel import Panel
from rich.table import Table
from rich.progress import (
Progress,
BarColumn,
TextColumn,
TimeElapsedColumn,
TimeRemainingColumn,
SpinnerColumn,
)
from rich.text import Text
from rich import box
from rich.align import Align
from rich.prompt import Prompt, Confirm, IntPrompt
from rich.theme import Theme
from rich.rule import Rule
from rich.live import Live
# ═════════════════════════════════════════════════════════════════════════ #
# CONSTANTS & BRANDING #
# ═════════════════════════════════════════════════════════════════════════ #
VERSION = "v2.0.0"
RELEASE_DATE = "2026-06-19"
BUILD = "Current Release"
AUTHOR = "Mohammad Kaif Raja"
USERNAME = "mkr-infinity"
INSTAGRAM_ID = "mkr_infinity"
GITHUB_LOGO = ""
INSTAGRAM_LOGO = ""
REPOSITORY_URL = "https://github.com/mkr-infinity/most-commited"
GITHUB_URL = "https://github.com/mkr-infinity"
INSTAGRAM_URL = "https://instagram.com/mkr_infinity"
COPYRIGHT = f"Copyright (c) 2026 {AUTHOR}. All Rights Reserved."
DEFAULT_FOLDER = "src"
ACTIVITY_FILE = "activity.log"
# ═════════════════════════════════════════════════════════════════════════ #
# EMOJI POOL (100+ unique emojis) #
# ═════════════════════════════════════════════════════════════════════════ #
EMOJI_POOL = [
# Activity & Status
"\U0001f680", # 🚀 Rocket
"\U0001f3af", # 🎯 Target
"\U0001f525", # 🔥 Fire
"\u2728", # ✨ Sparkles
"\U0001f6e0\ufe0f", # 🛠️ Tools
"\U0001f4e6", # 📦 Package
"\u26a1", # ⚡ Lightning
"\U0001f31f", # 🌟 Star
"\U0001f389", # 🎉 Party Popper
"\u2705", # ✅ Check Mark
# Technology & Code
"\U0001f9e0", # 🧠 Brain
"\U0001f4a1", # 💡 Light Bulb
"\U0001f4c8", # 📈 Chart Up
"\U0001f527", # 🔧 Wrench
"\U0001f4dd", # 📝 Memo
"\U0001f30d", # 🌍 Globe
"\U0001f3c6", # 🏆 Trophy
"\U0001f3a8", # 🎨 Art Palette
"\U0001f4da", # 📚 Books
"\U0001f512", # 🔒 Lock
"\U0001f504", # 🔄 Refresh
# Development
"\U0001f4bb", # 💻 Laptop
"\U0001f916", # 🤖 Robot
"\U0001f50d", # 🔍 Magnifying Glass
"\U0001f50e", # 🔎 Magnifying Glass Right
"\U0001f4ca", # 📊 Bar Chart
"\U0001f4cb", # 📋 Clipboard
"\U0001f4cc", # 📌 Pushpin
"\U0001f4cd", # 📍 Round Pushpin
"\U0001f4ce", # 📎 Paperclip
"\U0001f4d0", # 📐 Triangle Ruler
# Success & Growth
"\U0001f31f", # 🌟 Glowing Star
"\u2b50", # ⭐ Star
"\U0001f947", # 🥇 Gold Medal
"\U0001f948", # 🥈 Silver Medal
"\U0001f949", # 🥉 Bronze Medal
"\U0001f3c5", # 🏅 Sports Medal
"\U0001f396\ufe0f", # 🎖️ Military Medal
"\U0001f44d", # 👍 Thumbs Up
"\U0001f44c", # 👌 OK Hand
"\U0001f4af", # 💯 Hundred Points
# Objects & Tools
"\U0001f4e7", # 📧 Email
"\U0001f4e8", # 📨 Incoming Envelope
"\U0001f4e9", # 📩 Envelope with Arrow
"\U0001f4ea", # 📫 Mailbox
"\U0001f4eb", # 📬 Mailbox with Mail
"\U0001f4ee", # 📮 Postbox
"\U0001f4f1", # 📱 Mobile Phone
"\U0001f4f7", # 📷 Camera
"\U0001f4f8", # 📸 Camera with Flash
"\U0001f4fd\ufe0f", # 📽️ Projector
# Nature & Environment
"\U0001f33c", # 🌼 Blossom
"\U0001f33a", # 🌺 Hibiscus
"\U0001f338", # 🌸 Cherry Blossom
"\U0001f33b", # 🌻 Sunflower
"\U0001f331", # 🌱 Seedling
"\U0001f334", # 🌴 Palm Tree
"\U0001f335", # 🌵 Cactus
"\U0001f30e", # 🌎 Globe Americas
"\U0001f30f", # 🌏 Globe Asia-Australia
"\U0001f310", # 🌐 Globe with Meridians
# Weather & Elements
"\u2600\ufe0f", # ☀️ Sun
"\U0001f31c", # 🌜 Moon
"\u2601\ufe0f", # ☁️ Cloud
"\u26c5", # ⛅ Sun Behind Cloud
"\U0001f308", # 🌈 Rainbow
"\U0001f4a6", # 💦 Droplets
"\U0001f4a7", # 💧 Droplet
"\U0001f30a", # 🌊 Water Wave
"\U0001f525", # 🔥 Fire
# Symbols & Signs
"\u267b\ufe0f", # ♻️ Recycling
"\u2699\ufe0f", # ⚙️ Gear
"\u2697\ufe0f", # ⚗️ Alembic
"\U0001f4e1", # 📡 Satellite Antenna
"\U0001f50b", # 🔋 Battery
"\U0001f50c", # 🔌 Electric Plug
"\U0001f3b5", # 🎵 Musical Note
"\U0001f3b6", # 🎶 Multiple Musical Notes
"\U0001f3b7", # 🎷 Saxophone
"\U0001f3b8", # 🎸 Guitar
# Flags & Awards
"\U0001f3c1", # 🏁 Chequered Flag
"\U0001f6a9", # 🚩 Triangular Flag
"\U0001f38c", # 🎌 Crossed Flags
"\U0001f3f3\ufe0f", # 🏳️ White Flag
"\U0001f3f4", # 🏴 Black Flag
# Miscellaneous
"\U0001f4ac", # 💬 Speech Balloon
"\U0001f4ad", # 💭 Thought Balloon
"\U0001f5e8\ufe0f", # 🗨️ Left Speech Bubble
"\U0001f5ef\ufe0f", # 🗯️ Right Anger Bubble
"\U0001f4a2", # 💢 Anger Symbol
"\U0001f4a3", # 💣 Bomb
"\U0001f4a4", # 💤 Zzz
"\U0001f4a5", # 💥 Collision
"\U0001f4a8", # 💨 Dashing Away
"\U0001f4a9", # 💩 Pile of Poo
"\U0001f4aa", # 💪 Flexed Biceps
# More Tech
"\U0001f5a5\ufe0f", # 🖥️ Desktop Computer
"\U0001f5a8\ufe0f", # 🖨️ Printer
"\U0001f5b1\ufe0f", # 🖱️ Computer Mouse
"\U0001f5b2\ufe0f", # 🖲️ Trackball
"\U0001f4bd", # 💽 Computer Disk
"\U0001f4be", # 💾 Floppy Disk
"\U0001f4bf", # 💿 Optical Disk
"\U0001f4c0", # 📀 DVD
"\U0001f3a5", # 🎥 Movie Camera
"\U0001f39e\ufe0f", # 🎞️ Film Frames
]
# ═════════════════════════════════════════════════════════════════════════ #
# ACTIVITY MESSAGES POOL (200+ messages) #
# ═════════════════════════════════════════════════════════════════════════ #
MESSAGE_POOL = [
# Repository & Structure
"Improved repository structure",
"Enhanced project consistency",
"Updated development history",
"Added workflow activity",
"Improved source organization",
"Enhanced project metadata",
"Optimized repository tracking",
"Refined application workflow",
"Enhanced code maintainability",
"Updated project documentation",
# Code Quality
"Refactored core modules",
"Optimized performance bottlenecks",
"Improved error handling logic",
"Enhanced type safety across codebase",
"Reduced technical debt in modules",
"Improved code coverage metrics",
"Enhanced logging infrastructure",
"Optimized data processing pipeline",
"Refined algorithm efficiency",
"Cleaned up deprecated methods",
# Features & Development
"Added new feature implementation",
"Enhanced existing functionality",
"Integrated external API service",
"Implemented caching mechanism",
"Added validation logic",
"Enhanced user authentication flow",
"Improved data serialization",
"Added pagination support",
"Implemented rate limiting",
"Enhanced search functionality",
# Testing & Quality
"Added unit test coverage",
"Enhanced integration tests",
"Updated test fixtures",
"Improved test performance",
"Added end-to-end testing",
"Enhanced mocking framework",
"Updated test documentation",
"Improved assertion patterns",
"Added regression tests",
"Enhanced test configuration",
# Documentation
"Updated API documentation",
"Enhanced code comments",
"Added usage examples",
"Improved README structure",
"Updated changelog entries",
"Enhanced docstring coverage",
"Added configuration guide",
"Improved troubleshooting docs",
"Updated migration guide",
"Enhanced developer guide",
# Dependencies & Build
"Updated project dependencies",
"Enhanced build configuration",
"Optimized dependency tree",
"Updated package metadata",
"Improved CI/CD pipeline",
"Enhanced deployment scripts",
"Updated environment configuration",
"Optimized build artifacts",
"Enhanced release workflow",
"Updated container configuration",
# Security
"Enhanced security measures",
"Updated encryption protocols",
"Improved access controls",
"Enhanced input validation",
"Updated authentication tokens",
"Improved session management",
"Enhanced data sanitization",
"Updated security headers",
"Improved vulnerability patches",
"Enhanced audit logging",
# Performance
"Optimized query performance",
"Enhanced memory management",
"Improved load times",
"Reduced latency bottlenecks",
"Optimized database indexes",
"Enhanced resource utilization",
"Improved concurrent processing",
"Optimized network requests",
"Enhanced data streaming",
"Improved garbage collection",
# Architecture
"Refined architectural patterns",
"Enhanced module separation",
"Improved dependency injection",
"Enhanced service layer abstraction",
"Updated repository pattern",
"Improved event-driven architecture",
"Enhanced middleware pipeline",
"Updated factory patterns",
"Improved observer implementation",
"Enhanced strategy pattern usage",
# Maintenance
"Performed routine maintenance",
"Applied system updates",
"Cleaned up temporary files",
"Optimized storage usage",
"Enhanced backup procedures",
"Updated recovery protocols",
"Improved monitoring setup",
"Enhanced alerting rules",
"Updated logging levels",
"Optimized cron schedules",
# Configuration
"Updated application settings",
"Enhanced configuration management",
"Improved environment variables",
"Updated default parameters",
"Enhanced feature flags",
"Improved runtime configuration",
"Updated schema definitions",
"Enhanced migrations system",
"Improved seeding logic",
"Updated fixture data",
# UI/UX
"Enhanced user interface elements",
"Improved responsive design",
"Updated component library",
"Enhanced accessibility features",
"Improved color scheme contrast",
"Updated typography settings",
"Enhanced form validation UI",
"Improved navigation structure",
"Updated animation timing",
"Enhanced loading states",
# Database
"Optimized database queries",
"Enhanced connection pooling",
"Updated migration scripts",
"Improved data normalization",
"Enhanced indexing strategy",
"Updated schema relations",
"Improved transaction handling",
"Enhanced data integrity checks",
"Updated stored procedures",
"Optimized query plans",
# Networking
"Enhanced API endpoint responses",
"Improved request handling",
"Updated rate limiting rules",
"Enhanced websocket connections",
"Improved DNS resolution",
"Enhanced SSL/TLS configuration",
"Updated proxy settings",
"Improved load balancing",
"Enhanced failover mechanisms",
"Improved timeout handling",
# DevOps
"Enhanced Docker configuration",
"Improved Kubernetes manifests",
"Updated Terraform scripts",
"Enhanced Ansible playbooks",
"Improved Helm charts",
"Updated monitoring dashboards",
"Enhanced logging aggregation",
"Improved metric collection",
"Updated alert thresholds",
"Enhanced auto-scaling rules",
# Additional Messages
"Applied hotfix for critical bug",
"Backported security patches",
"Deprecated legacy endpoints",
"Removed unused dependencies",
"Consolidated duplicate utilities",
"Standardized error codes",
"Normalized data formats",
"Harmonized API responses",
"Unified logging patterns",
"Synchronized configuration files",
"Rectified edge case behavior",
"Mitigated potential race condition",
"Addressed memory leak issue",
"Patched cross-site scripting vulnerability",
"Fortified authentication mechanism",
"Strengthened authorization checks",
"Bolstered input sanitization",
"Reinforced validation pipeline",
"Escalated error reporting",
"Refined fallback strategies",
"Extended timeout boundaries",
"Adjusted concurrency limits",
"Tuned connection parameters",
"Calibrated performance metrics",
"Aligned with coding standards",
"Conformed to style guidelines",
"Revised naming conventions",
"Updated formatting rules",
"Enforced linting rules",
"Applied code formatting",
"Restructured directory layout",
"Reorganized module exports",
"Redistributed responsibilities",
"Decoupled tightly bound components",
"Extracted reusable utilities",
"Simplified complex logic",
"Streamlined data flow",
"Clarified ambiguous conditions",
"Untangled nested control flow",
"Consolidated scattered logic",
"Expanded test scenarios",
"Diversified test data sets",
"Strengthened assertion coverage",
"Fleshed out boundary tests",
"Added stress testing suite",
"Benchmarked critical paths",
"Profiled CPU utilization",
"Traced memory allocation patterns",
"Analyzed I/O bottlenecks",
"Inspected thread contention",
"Augmented developer tooling",
"Enhanced debugging capabilities",
"Added profiling hooks",
"Instrumented key metrics",
"Implemented telemetry collection",
"Enabled verbose logging mode",
"Configured structured logging",
"Established log rotation policies",
"Defined retention strategies",
"Archived old log data",
"Catalogued API versions",
"Tagged release candidates",
"Published beta builds",
"Staged rolling updates",
"Coordinated release schedule",
"Validated upgrade paths",
"Tested downgrade procedures",
"Verified rollback mechanisms",
"Certified release artifacts",
"Signed distribution packages",
"Boosted compilation flags",
"Minified production assets",
"Tree-shook unused exports",
"Code-split large bundles",
"Lazy-loaded heavy components",
"Prefetched critical resources",
"Cached static assets",
"CDN-distributed media files",
"Gzipped transfer payloads",
"Brotli-compressed responses",
"Planned capacity upgrades",
"Forecasted resource demands",
"Provisioned additional nodes",
"Scaled horizontal clusters",
"Distributed shard keys",
"Replicated read instances",
"Failed-over to standby region",
"Recovered from backup snapshot",
"Restored point-in-time data",
"Validated backup integrity",
"Reviewed access logs",
"Audited permission changes",
"Rotated API credentials",
"Refreshed TLS certificates",
"Revoked compromised tokens",
"Inspected network traffic",
"Analyzed threat patterns",
"Blocked malicious requests",
"Quarantined suspicious activity",
"Hardened system configuration",
"Wrote architectural decision record",
"Drafted RFC for new proposal",
"Commented on design review",
"Addressed PR feedback",
"Resolved merge conflicts",
"Rebased feature branch",
"Squashed intermediate commits",
"Cherry-picked critical fix",
"Reverted breaking change",
"Tagged stable release point",
]
# ═════════════════════════════════════════════════════════════════════════ #
# THEME & STYLES #
# ═════════════════════════════════════════════════════════════════════════ #
custom_theme = Theme(
{
"info": "cyan",
"warning": "yellow",
"error": "bold red",
"success": "bold green",
"brand": "bold blue",
"highlight": "bold magenta",
"dim": "grey50",
"accent": "bold yellow",
}
)
console = Console(theme=custom_theme, highlight=False)
def env_bool(name: str) -> Optional[bool]:
"""Read a boolean environment variable if it is set."""
value = os.environ.get(name)
if value is None:
return None
return value.strip().lower() in {"1", "true", "yes", "y", "on"}
def env_int(name: str) -> Optional[int]:
"""Read an integer environment variable if it is valid."""
value = os.environ.get(name)
if value is None or not value.strip():
return None
try:
return int(value)
except ValueError:
console.print(f"[error]\u274c Invalid integer for {name}: {value}[/error]")
sys.exit(1)
def is_github_actions() -> bool:
"""Return whether the script is running inside GitHub Actions."""
return os.environ.get("GITHUB_ACTIONS", "").lower() == "true"
def should_prompt(args: argparse.Namespace) -> bool:
"""Return whether interactive prompts are safe and desired."""
return sys.stdin.isatty() and not args.yes and not args.ci
def normalize_target_folder(folder: str) -> str:
"""Normalize and validate a repository-relative target folder."""
target = folder.strip().replace("\\", "/").strip("/") or DEFAULT_FOLDER
parts = [part for part in target.split("/") if part]
if any(part in {".", ".."} for part in parts):
console.print("[error]\u274c Target folder must stay inside the repository.[/error]")
sys.exit(1)
return "/".join(parts) or DEFAULT_FOLDER
def progress_interval(count: int, quiet: bool = False) -> int:
"""Return how often progress should be rendered for a batch."""
if quiet:
return max(1, min(500, count // 10 or 1))
return 1 if count <= 1000 else max(10, count // 1000)
def parse_args() -> argparse.Namespace:
"""Parse CLI arguments while keeping the interactive workflow as default."""
parser = argparse.ArgumentParser(
description="Generate real Git commits by updating an activity log file.",
)
parser.add_argument(
"-c",
"--count",
type=int,
default=env_int("BCG_COUNT"),
help="Number of commits to generate. Env: BCG_COUNT",
)
parser.add_argument(
"-m",
"--mode",
choices=["signed", "unsigned"],
default=os.environ.get("BCG_MODE"),
help="Commit mode. Env: BCG_MODE=signed|unsigned",
)
parser.add_argument(
"-f",
"--folder",
default=os.environ.get("BCG_FOLDER"),
help=f"Target folder relative to repo root. Env: BCG_FOLDER. Default: {DEFAULT_FOLDER}",
)
parser.add_argument(
"-r",
"--repo",
default=os.environ.get("BCG_REPO"),
help="Path to the Git repository. Env: BCG_REPO. GitHub Actions defaults to GITHUB_WORKSPACE.",
)
parser.add_argument(
"--push",
action="store_true",
default=env_bool("BCG_PUSH") is True,
help="Push generated commits to origin after generation. Env: BCG_PUSH=true",
)
parser.add_argument(
"--no-push",
action="store_true",
help="Never push generated commits, even if BCG_PUSH=true.",
)
parser.add_argument(
"-y",
"--yes",
action="store_true",
default=env_bool("BCG_YES") is True,
help="Skip confirmations and use defaults for missing options. Env: BCG_YES=true",
)
parser.add_argument(
"--ci",
action="store_true",
default=is_github_actions() or env_bool("CI") is True,
help="Run in non-interactive CI mode.",
)
parser.add_argument(
"--no-banner",
action="store_true",
default=env_bool("BCG_NO_BANNER") is True,
help="Skip the animated startup banner. Env: BCG_NO_BANNER=true",
)
parser.add_argument(
"--quiet",
action="store_true",
default=env_bool("BCG_QUIET") is True,
help="Reduce progress rendering for faster CI logs. Env: BCG_QUIET=true",
)
return parser.parse_args()
# ═════════════════════════════════════════════════════════════════════════ #
# BRAND & UI COMPONENTS #
# ═════════════════════════════════════════════════════════════════════════ #
BOX_WIDTH = 170
def spin_animation(message: str, duration: float = 1.5) -> None:
"""Show a spinner animation for the given duration."""
chars = "⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏"
end_time = time.time() + duration
i = 0
while time.time() < end_time:
print(f"\r\x1b[36m{chars[i % len(chars)]}\x1b[0m {message}", end="", flush=True)
time.sleep(0.08)
i += 1
print(f"\r\x1b[32m\u2713\x1b[0m {message} ")
def print_credit_splash() -> None:
"""Show structured branded splash with signature wordmark, no author name."""
width = min(BOX_WIDTH, console.width - 2)
date_now = datetime.now().strftime("%Y-%m-%d")
meta_line = Text.from_markup(
f"[black on bright_green] {VERSION} [/black on bright_green] "
f"[black on green] {date_now} [/black on green] "
f"[black on bright_blue] {BUILD} [/black on bright_blue]"
)
wordmark = Panel(
Align.center(Text(" \U0001d4dc \U0001d4da \U0001d4e1 - \U0001d4d8 \U0001d4dd \U0001d4d5 \U0001d4d8 \U0001d4dd \U0001d4d8 \U0001d4e3 \U0001d4e8 ", style="bold white")),
box=box.ROUNDED,
border_style="bright_green",
style="on black",
padding=(1, 6),
)
title_line = Panel(
Align.center(Text("BULK COMMIT GENERATOR", style="bold white")),
box=box.HEAVY,
border_style="bright_green",
style="on black",
padding=(0, 10),
)
social_links = Table.grid(padding=(0, 1))
social_links.add_column(justify="right", no_wrap=True)
social_links.add_column(justify="left", no_wrap=True)
social_links.add_row(
f"[bold white]{GITHUB_LOGO} GitHub[/bold white]",
f"[link={GITHUB_URL}][green]{GITHUB_URL}[/green][/link]",
)
social_links.add_row(
f"[bold magenta]{INSTAGRAM_LOGO} Instagram[/bold magenta]",
f"[link={INSTAGRAM_URL}][magenta]{INSTAGRAM_URL}[/magenta][/link]",
)
social_links.add_row(
"[bold yellow]📦 Repo[/bold yellow]",
f"[link={REPOSITORY_URL}][bold green]{REPOSITORY_URL}[/bold green][/link]",
)
chips = Table.grid(padding=(0, 1))
chips.add_column(justify="center")
chips.add_column(justify="center")
chips.add_column(justify="center")
chips.add_row(
"[black on bright_green] REAL COMMITS [/black on bright_green]",
"[black on green] SIGNED / UNSIGNED [/black on green]",
"[black on bright_yellow] FAST BULK MODE [/black on bright_yellow]",
)
notice = Panel(
Align.center(Text.from_markup(
f"[bold yellow]⚠ NOTICE:[/bold yellow] "
f"If you modify, redistribute, fork, or reuse this project, please "
f"provide proper credit to [bold green]{AUTHOR}[/bold green] ([bold green]{USERNAME}[/bold green]) "
f"[dim]|[/dim] [green]{REPOSITORY_URL}[/green]"
)),
box=box.ROUNDED,
border_style="yellow",
padding=(0, 2),
)
content = Table.grid(expand=True)
content.add_column(justify="center")
content.add_row(Align.center(meta_line))
content.add_row("")
content.add_row(Align.center(wordmark))
content.add_row("")
content.add_row(Align.center(title_line))
content.add_row(Align.center(Text("Professional Git Activity Automation", style="italic green")))
content.add_row("")
content.add_row(Align.center(social_links))
content.add_row("")
content.add_row(Align.center(chips))
content.add_row("")
content.add_row(Align.center(notice))
content.add_row("")
content.add_row(Align.center(Text(COPYRIGHT, style="dim italic")))
splash = Panel(
Align.center(content),
box=box.DOUBLE,
border_style="bright_green",
padding=(1, 2),
width=width,
title="[bold green]\U0001f680 Bulk Commit Generator[/bold green]",
subtitle=f"[bold green]{USERNAME}[/bold green]",
title_align="center",
subtitle_align="center",
)
with Live(console=console, refresh_per_second=10, transient=True) as live:
for idx, step in enumerate([
"🎨 Painting brand", "🔗 Linking platforms", "🚀 Launching",
], start=1):
loading = Panel(
Align.center(Text.from_markup(
f"\n[bold green]{step}[/bold green]\n"
f"[bright_green]{'●' * idx}[/bright_green][dim]{'○' * (3 - idx)}[/dim]\n"
)),
box=box.ROUNDED, border_style="green",
width=min(50, width),
title="[bold green]Building Launch Box[/bold green]",
title_align="center",
)
live.update(Align.center(loading))
time.sleep(0.25)
console.print(Align.center(splash))
time.sleep(0.8)
def print_banner() -> None:
"""Display the full branded startup banner with animations."""
console.clear()
# ── Animated startup sequence ────────────────────────────────────────
spin_animation("Initializing Bulk Commit Generator...", 1.2)
spin_animation("Loading assets and modules...", 0.8)
spin_animation("Preparing user interface...", 0.6)
time.sleep(0.3)
console.clear()
console.print("")
# ── Single main branded launch box ───────────────────────────────────
print_credit_splash()
console.print("")
# ═════════════════════════════════════════════════════════════════════════ #
# GIT OPERATIONS #
# ═════════════════════════════════════════════════════════════════════════ #
def run_git_command(
args: list[str],
cwd: Optional[str] = None,
timeout: int = 30,
env: Optional[dict[str, str]] = None,
) -> Tuple[int, str, str]:
"""Safely execute a Git command using subprocess (never shell=True).
Args:
args: List of Git arguments (e.g., ['rev-list', '--count', 'HEAD']).
cwd: Working directory for the command. Defaults to current.
timeout: Maximum execution time in seconds.
env: Additional environment variables (merged with current env).
Returns:
Tuple of (returncode, stdout, stderr).
"""
cmd_env = os.environ.copy()
if env:
cmd_env.update(env)
try:
result = subprocess.run(
["git"] + args,
capture_output=True,
text=True,
timeout=timeout,
cwd=cwd,
env=cmd_env,
)
return result.returncode, result.stdout.strip(), result.stderr.strip()
except FileNotFoundError:
return -1, "", "Git is not installed or not found in PATH."
except subprocess.TimeoutExpired:
return -2, "", f"Git command timed out after {timeout} seconds."
except PermissionError:
return -3, "", "Permission denied while running Git command."
except OSError as exc:
return -4, "", f"OS error: {exc}"
def is_git_repository(path: Optional[str] = None) -> bool:
"""Check if the given path (or current directory) is a Git repository."""
code, _, _ = run_git_command(["rev-parse", "--git-dir"], cwd=path)
return code == 0
def get_git_repo_root(path: Optional[str] = None) -> Optional[str]:
"""Get the absolute path of the Git repository root."""
code, out, _ = run_git_command(["rev-parse", "--show-toplevel"], cwd=path)
return out if code == 0 else None
def get_current_branch(path: Optional[str] = None) -> Optional[str]:
"""Get the current active branch name."""
code, out, _ = run_git_command(["rev-parse", "--abbrev-ref", "HEAD"], cwd=path)
if code == 0 and out == "HEAD" and os.environ.get("GITHUB_REF_NAME"):
return os.environ["GITHUB_REF_NAME"]
return out if code == 0 else None
def get_commit_count(path: Optional[str] = None) -> int:
"""Count total commits in the current branch (or return 0 if none)."""
code, out, _ = run_git_command(["rev-list", "--count", "HEAD"], cwd=path)
return int(out) if code == 0 else 0
def get_worktree_status(path: Optional[str] = None) -> Tuple[bool, str]:
"""Return whether the repository has uncommitted changes and raw status."""
code, out, err = run_git_command(["status", "--porcelain"], cwd=path, timeout=20)
if code != 0:
return True, err or "Could not read working tree status."
return bool(out.strip()), out
def get_git_user_name(path: Optional[str] = None) -> Optional[str]:
"""Get the configured Git user name."""
code, out, _ = run_git_command(["config", "user.name"], cwd=path)
return out if code == 0 else None
def get_git_user_email(path: Optional[str] = None) -> Optional[str]:
"""Get the configured Git user email."""
code, out, _ = run_git_command(["config", "user.email"], cwd=path)
return out if code == 0 else None
def ensure_github_actions_git_defaults(repo_root: str) -> None:
"""Apply safe Git defaults commonly needed in GitHub Actions."""
if not is_github_actions():
return
run_git_command(["config", "--global", "--add", "safe.directory", repo_root], timeout=20)
if not get_git_user_name(repo_root):
run_git_command(["config", "user.name", "github-actions[bot]"], cwd=repo_root)
if not get_git_user_email(repo_root):
run_git_command(
["config", "user.email", "41898282+github-actions[bot]@users.noreply.github.com"],
cwd=repo_root,
)
def is_file_tracked(file_path: str, cwd: Optional[str] = None) -> bool:
"""Return whether Git already tracks the file."""
code, _, _ = run_git_command(
["ls-files", "--error-unmatch", "--", file_path], cwd=cwd, timeout=20
)
return code == 0
def check_signing_config(path: Optional[str] = None) -> Tuple[bool, str, str]:
"""Check if Git signing is properly configured.
Returns:
Tuple of (is_configured, signing_key, detail_message).
"""
# Check commit.gpgSign
code_sign, out_sign, _ = run_git_command(
["config", "--get", "commit.gpgSign"], cwd=path
)
# Check user.signingkey
code_key, out_key, _ = run_git_command(
["config", "--get", "user.signingkey"], cwd=path
)
if code_sign != 0 or out_sign.lower() not in ("true", "t", "yes", "y", "1"):
return False, "", "commit.gpgSign is not enabled.\nRun: git config --global commit.gpgSign true"
if code_key != 0 or not out_key.strip():
return False, "", (
"No GPG/SSH signing key found.\n"
"Generate a key: gpg --full-generate-key\n"
"List keys: gpg --list-secret-keys --keyid-format=long\n"
"Configure: git config --global user.signingkey <KEY_ID>\n"
"Add to GitHub: https://github.com/settings/gpg/new"
)
return True, out_key.strip(), "Signing is properly configured."
def stage_file(file_path: str, cwd: Optional[str] = None) -> Tuple[bool, str]:
"""Stage a file for commit using git add."""
code, _, err = run_git_command(["add", "--", file_path], cwd=cwd, timeout=20)
if code != 0:
return False, f"Failed to stage file: {err}"
return True, ""
def create_unsigned_commit(
message: str,
cwd: Optional[str] = None,
pathspec: Optional[str] = None,
) -> Tuple[bool, str]:
"""Create an unsigned Git commit."""
args = ["-c", "gc.auto=0", "commit", "--quiet", "--no-gpg-sign", "-m", message]
if pathspec:
args.extend(["--", pathspec])
code, _, err = run_git_command(
args,
cwd=cwd,
timeout=60,
env={"GIT_TERMINAL_PROMPT": "0"},
)
if code != 0:
detail = err or "Git commit failed without returning details."
return False, f"Failed to create unsigned commit: {detail}"
return True, ""
def create_signed_commit(
message: str,
cwd: Optional[str] = None,
pathspec: Optional[str] = None,
) -> Tuple[bool, str]:
"""Create a signed Git commit (-S flag) with GPG agent support.
Uses GIT_TERMINAL_PROMPT=0 to prevent hanging on GPG passphrase
prompts — the GPG agent must already be running and have the key