Skip to content

Refactor monolithic gitHappens.py into modular architecture (closes #116)#142

Open
trandaiviethung2001 wants to merge 1 commit into
zigcBenx:masterfrom
trandaiviethung2001:refactor/modular-architecture
Open

Refactor monolithic gitHappens.py into modular architecture (closes #116)#142
trandaiviethung2001 wants to merge 1 commit into
zigcBenx:masterfrom
trandaiviethung2001:refactor/modular-architecture

Conversation

@trandaiviethung2001
Copy link
Copy Markdown

Summary

Splits the 800+ line gitHappens.py into focused modules per the structure proposed in #116. Behaviour is preserved end-to-end, and the existing gitHappens.py entry point is kept as a thin compatibility shim so any user aliases (alias gh='python3 .../gitHappens.py') keep working unchanged.

New layout

├── main.py                 # Entry point and argument parsing
├── gitHappens.py           # Backwards-compatible shim → main.main()
├── config.py               # Config loading (config.ini + templates.json)
├── gitlab_api.py           # GitLab HTTP + glab CLI wrappers
├── templates.py            # Issue template selection
├── git_utils.py            # Local git operations
├── interactive.py          # inquirer prompts
├── project.py              # Resolve current project id
└── commands/
    ├── create_issue.py     # Issue + branch + MR creation
    ├── merge_request.py    # MR lookups, reviewers, auto-merge
    ├── open_mr.py          # Open active MR in browser
    ├── review.py           # Review workflow + AI review hook
    ├── deploy.py           # Last production deployment lookup
    ├── summary.py          # Two-week commit summary (raw + AI)
    └── incident.py         # Incident report workflow

Acceptance criteria from #116

  • Extract GitLab API calls into gitlab_api.py
  • Move configuration handling to config.py
  • Separate template logic into templates.py
  • Create command-specific modules in commands/ folder
  • Ensure all existing functionality works unchanged (every command path from the old file is wired through the new modules; gitHappens.py still works as before via the shim)
  • Add basic unit tests for each module — left for a follow-up PR to keep this change reviewable; the refactor is structured to make tests easy to add
  • Update README with new structure

Notes for reviewers

  • The shim in gitHappens.py means existing aliases keep working; python3 main.py ... works equivalently.
  • Added __pycache__/ and *.pyc to .gitignore.
  • No behaviour changes intended — the public CLI surface (gh report, gh open, gh review [--select] [-am], gh summary, gh summaryAI, gh last deploy, gh ai review, issue creation with templates) is identical.

Test plan

  • Run python3 gitHappens.py --help and confirm the same flags are listed
  • Run python3 gitHappens.py summary in a repo to confirm commit summary output is unchanged
  • Run python3 gitHappens.py "Some title" end-to-end on a test project to confirm issue/branch/MR creation still works
  • Run python3 gitHappens.py review on a branch with an open MR to confirm the review workflow still works

🤖 Generated with Claude Code

Splits the 800+ line gitHappens.py into focused modules so each piece is
easy to find, test and extend. Behaviour is preserved end-to-end and the
existing `gitHappens.py` entry point is kept as a thin compatibility shim
so any user aliases keep working.

New layout:
- main.py: argparse entry point and subcommand dispatch
- config.py: config.ini + templates.json loading
- gitlab_api.py: GitLab HTTP + glab CLI wrappers
- git_utils.py: local git operations
- templates.py: issue template selection
- interactive.py: inquirer prompts (milestones, iterations, epics, reviewers, labels)
- project.py: resolve current project id
- commands/create_issue.py: issue + branch + MR creation
- commands/merge_request.py: MR lookups, reviewers, auto-merge
- commands/open_mr.py: open active MR in browser
- commands/review.py: review workflow + AI review hook
- commands/deploy.py: last production deployment lookup
- commands/summary.py: two-week commit summary (raw + AI)
- commands/incident.py: incident report workflow

Refs zigcBenx#116
@trandaiviethung2001 trandaiviethung2001 force-pushed the refactor/modular-architecture branch from 754ce91 to 5ef4c7f Compare May 12, 2026 08:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants