gitwebhooks 2.2.0__tar.gz → 2.3.0__tar.gz
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.
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/CLAUDE.md +4 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/PKG-INFO +31 -12
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/README.md +30 -11
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/README.zh.md +30 -11
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/gitwebhooks/__init__.py +1 -1
- gitwebhooks-2.3.0/gitwebhooks/cli/__init__.py +203 -0
- gitwebhooks-2.3.0/gitwebhooks/cli/help.py +155 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/gitwebhooks/cli/prompts.py +48 -1
- gitwebhooks-2.3.0/gitwebhooks/cli/serve.py +151 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/gitwebhooks/cli/service.py +81 -7
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/gitwebhooks/main/__init__.py +100 -28
- gitwebhooks-2.3.0/gitwebhooks/main/version.py +24 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/gitwebhooks/models/__init__.py +2 -0
- gitwebhooks-2.3.0/gitwebhooks/models/config.py +74 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/gitwebhooks/utils/constants.py +49 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/gitwebhooks/utils/systemd.py +3 -3
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/gitwebhooks.egg-info/PKG-INFO +31 -12
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/gitwebhooks.egg-info/SOURCES.txt +12 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/pyproject.toml +1 -1
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/tests/integration/test_config_discovery.py +23 -15
- gitwebhooks-2.3.0/tests/unit/test_config_level.py +105 -0
- gitwebhooks-2.3.0/tests/unit/test_install_service_logic.py +251 -0
- gitwebhooks-2.3.0/tests/unit/test_prompts_config_level.py +168 -0
- gitwebhooks-2.3.0/tests/unit/test_service_install_context.py +145 -0
- gitwebhooks-2.2.0/gitwebhooks/cli/__init__.py +0 -107
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/.editorconfig +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/LICENSE +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/MANIFEST.in +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/doc/custom-body.png +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/doc/custom-header.png +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/doc/custom-response.png +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/doc/gitee-success.png +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/doc/gitee.png +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/doc/github-success.png +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/doc/github.png +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/doc/gitlab-success.png +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/doc/gitlab.png +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/doc/install.png +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/doc/uninstall.png +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/gitwebhooks/__main__.py +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/gitwebhooks/auth/__init__.py +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/gitwebhooks/auth/custom.py +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/gitwebhooks/auth/factory.py +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/gitwebhooks/auth/gitee.py +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/gitwebhooks/auth/github.py +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/gitwebhooks/auth/gitlab.py +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/gitwebhooks/auth/verifier.py +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/gitwebhooks/cli/config.py +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/gitwebhooks/cli/init_wizard.py +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/gitwebhooks/config/__init__.py +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/gitwebhooks/config/loader.py +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/gitwebhooks/config/models.py +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/gitwebhooks/config/registry.py +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/gitwebhooks/config/server.py +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/gitwebhooks/handlers/__init__.py +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/gitwebhooks/handlers/base.py +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/gitwebhooks/handlers/custom.py +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/gitwebhooks/handlers/factory.py +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/gitwebhooks/handlers/gitee.py +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/gitwebhooks/handlers/github.py +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/gitwebhooks/handlers/gitlab.py +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/gitwebhooks/handlers/request.py +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/gitwebhooks/logging/__init__.py +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/gitwebhooks/logging/setup.py +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/gitwebhooks/main/__main__.py +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/gitwebhooks/models/provider.py +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/gitwebhooks/models/request.py +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/gitwebhooks/models/result.py +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/gitwebhooks/server.py +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/gitwebhooks/utils/__init__.py +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/gitwebhooks/utils/exceptions.py +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/gitwebhooks/utils/executor.py +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/gitwebhooks.egg-info/dependency_links.txt +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/gitwebhooks.egg-info/entry_points.txt +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/gitwebhooks.egg-info/requires.txt +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/gitwebhooks.egg-info/top_level.txt +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/gitwebhooks.ini.sample +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/setup.cfg +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/tests/__init__.py +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/tests/__main__.py +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/tests/conftest.py +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/tests/fixtures/__init__.py +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/tests/fixtures/custom_payloads.py +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/tests/fixtures/gitee_payloads.py +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/tests/fixtures/github_payloads.py +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/tests/fixtures/gitlab_payloads.py +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/tests/fixtures/signature_builder.py +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/tests/integration/__init__.py +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/tests/integration/test_command_execution.py +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/tests/integration/test_config_view_integration.py +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/tests/integration/test_custom_webhook.py +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/tests/integration/test_edge_cases.py +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/tests/integration/test_gitee_webhook.py +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/tests/integration/test_github_webhook.py +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/tests/integration/test_gitlab_webhook.py +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/tests/test_auth/__init__.py +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/tests/test_config/__init__.py +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/tests/test_handlers/__init__.py +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/tests/test_integration/__init__.py +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/tests/unit/__init__.py +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/tests/unit/cli/__init__.py +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/tests/unit/cli/test_config_view.py +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/tests/unit/cli/test_init_wizard.py +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/tests/unit/test_config_loading.py +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/tests/unit/test_data_parsing.py +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/tests/unit/test_main.py +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/tests/unit/test_provider_detection.py +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/tests/unit/test_request_handler.py +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/tests/unit/test_signature_verification.py +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/tests/utils/__init__.py +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/tests/utils/certificate_generator.py +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/tests/utils/coverage_runner.py +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/tests/utils/http_client.py +0 -0
- {gitwebhooks-2.2.0 → gitwebhooks-2.3.0}/tests/utils/server_manager.py +0 -0
|
@@ -301,6 +301,10 @@ gitwebhooks/
|
|
|
301
301
|
- Python 3.7+ (项目要求) + Python 标准库仅(无外部依赖) (001-fix-config-init-bug)
|
|
302
302
|
- INI 配置文件 (configparser) (001-fix-config-init-bug)
|
|
303
303
|
- Python 3.7+ (项目要求) + Python 标准库(pathlib, configparser, argparse) (001-config-priority)
|
|
304
|
+
- Python 3.6+ (与项目要求一致,实际支持 3.6-3.14) + argparse (Python 标准库) (002-cli-commands-refactor)
|
|
305
|
+
- N/A (CLI 重构,不涉及存储) (002-cli-commands-refactor)
|
|
306
|
+
- Python 3.6+(项目要求),实际支持 3.6-3.14 + Python 标准库 `argparse`(命令行参数解析) (002-cli-commands-refactor)
|
|
307
|
+
- N/A(CLI 重构,不涉及存储) (002-cli-commands-refactor)
|
|
304
308
|
|
|
305
309
|
## Recent Changes
|
|
306
310
|
- 001-config-init-wizard: 添加 `config init` 交互式向导,支持配置级别选择、平台配置和仓库配置
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: gitwebhooks
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.3.0
|
|
4
4
|
Summary: A lightweight Git webhook server for automated deployment supporting GitHub, Gitee, GitLab, and custom webhooks
|
|
5
5
|
Author-email: Troy Tse <troy@holyhi.net>
|
|
6
6
|
Maintainer-email: Troy Tse <troy@holyhi.net>
|
|
@@ -169,28 +169,40 @@ This will create a configuration file with secure permissions (0600).
|
|
|
169
169
|
The service installation command automatically detects your installation type (pipx, venv, or system) and generates the appropriate service file.
|
|
170
170
|
|
|
171
171
|
```bash
|
|
172
|
-
# Install and start as a systemd service
|
|
173
|
-
sudo gitwebhooks-cli
|
|
172
|
+
# Install and start as a systemd service (interactive config level selection)
|
|
173
|
+
sudo gitwebhooks-cli serve install
|
|
174
|
+
|
|
175
|
+
# Install with specific config level (skip interactive selection)
|
|
176
|
+
sudo gitwebhooks-cli serve install --config-level user # User level (~/.gitwebhooks.ini)
|
|
177
|
+
sudo gitwebhooks-cli serve install --config-level local # Local level (/usr/local/etc/gitwebhooks.ini)
|
|
178
|
+
sudo gitwebhooks-cli serve install --config-level system # System level (/etc/gitwebhooks.ini)
|
|
179
|
+
|
|
180
|
+
# Use custom config file (backward compatibility)
|
|
181
|
+
sudo gitwebhooks-cli serve install -c /path/to/config.ini
|
|
174
182
|
|
|
175
183
|
# Preview service file without installing (dry-run mode)
|
|
176
|
-
sudo gitwebhooks-cli
|
|
184
|
+
sudo gitwebhooks-cli serve install --dry-run
|
|
185
|
+
sudo gitwebhooks-cli serve install --config-level local --dry-run # Preview specific level
|
|
177
186
|
|
|
178
187
|
# Install with verbose output
|
|
179
|
-
sudo gitwebhooks-cli
|
|
180
|
-
sudo gitwebhooks-cli service install -v # Basic verbosity
|
|
181
|
-
sudo gitwebhooks-cli service install -vv # Extra verbosity
|
|
188
|
+
sudo gitwebhooks-cli serve install --verbose
|
|
182
189
|
|
|
183
190
|
# Force overwrite existing service
|
|
184
|
-
sudo gitwebhooks-cli
|
|
191
|
+
sudo gitwebhooks-cli serve install --force
|
|
185
192
|
|
|
186
193
|
# Uninstall the service
|
|
187
|
-
sudo gitwebhooks-cli
|
|
194
|
+
sudo gitwebhooks-cli serve uninstall
|
|
188
195
|
```
|
|
189
196
|
|
|
197
|
+
**Configuration levels**:
|
|
198
|
+
- **user**: `~/.gitwebhooks.ini` - Single user configuration, highest priority
|
|
199
|
+
- **local**: `/usr/local/etc/gitwebhooks.ini` - Local system configuration, medium priority
|
|
200
|
+
- **system**: `/etc/gitwebhooks.ini` - Global system configuration, lowest priority
|
|
201
|
+
|
|
190
202
|
**Service file auto-detection**:
|
|
191
203
|
- **pipx installation**: Uses `gitwebhooks-cli` command directly
|
|
192
|
-
- **venv/virtualenv**: Uses `python -m gitwebhooks.
|
|
193
|
-
- **System pip**: Uses system Python with `python -m gitwebhooks.
|
|
204
|
+
- **venv/virtualenv**: Uses `python -m gitwebhooks.main` with environment's Python
|
|
205
|
+
- **System pip**: Uses system Python with `python -m gitwebhooks.main`
|
|
194
206
|
- **conda**: Not supported - installation will be refused with clear error message
|
|
195
207
|
|
|
196
208
|
### Manual Installation
|
|
@@ -208,7 +220,14 @@ sudo ln "$(pwd)/gitwebhooks-cli" /usr/local/bin/gitwebhooks-cli
|
|
|
208
220
|
### Verify Installation
|
|
209
221
|
|
|
210
222
|
```bash
|
|
211
|
-
|
|
223
|
+
# Show version
|
|
224
|
+
gitwebhooks-cli -v
|
|
225
|
+
|
|
226
|
+
# Show help
|
|
227
|
+
gitwebhooks-cli help
|
|
228
|
+
|
|
229
|
+
# View configuration
|
|
230
|
+
gitwebhooks-cli config view
|
|
212
231
|
```
|
|
213
232
|
|
|
214
233
|
## Migrating from System pip Installation
|
|
@@ -129,28 +129,40 @@ This will create a configuration file with secure permissions (0600).
|
|
|
129
129
|
The service installation command automatically detects your installation type (pipx, venv, or system) and generates the appropriate service file.
|
|
130
130
|
|
|
131
131
|
```bash
|
|
132
|
-
# Install and start as a systemd service
|
|
133
|
-
sudo gitwebhooks-cli
|
|
132
|
+
# Install and start as a systemd service (interactive config level selection)
|
|
133
|
+
sudo gitwebhooks-cli serve install
|
|
134
|
+
|
|
135
|
+
# Install with specific config level (skip interactive selection)
|
|
136
|
+
sudo gitwebhooks-cli serve install --config-level user # User level (~/.gitwebhooks.ini)
|
|
137
|
+
sudo gitwebhooks-cli serve install --config-level local # Local level (/usr/local/etc/gitwebhooks.ini)
|
|
138
|
+
sudo gitwebhooks-cli serve install --config-level system # System level (/etc/gitwebhooks.ini)
|
|
139
|
+
|
|
140
|
+
# Use custom config file (backward compatibility)
|
|
141
|
+
sudo gitwebhooks-cli serve install -c /path/to/config.ini
|
|
134
142
|
|
|
135
143
|
# Preview service file without installing (dry-run mode)
|
|
136
|
-
sudo gitwebhooks-cli
|
|
144
|
+
sudo gitwebhooks-cli serve install --dry-run
|
|
145
|
+
sudo gitwebhooks-cli serve install --config-level local --dry-run # Preview specific level
|
|
137
146
|
|
|
138
147
|
# Install with verbose output
|
|
139
|
-
sudo gitwebhooks-cli
|
|
140
|
-
sudo gitwebhooks-cli service install -v # Basic verbosity
|
|
141
|
-
sudo gitwebhooks-cli service install -vv # Extra verbosity
|
|
148
|
+
sudo gitwebhooks-cli serve install --verbose
|
|
142
149
|
|
|
143
150
|
# Force overwrite existing service
|
|
144
|
-
sudo gitwebhooks-cli
|
|
151
|
+
sudo gitwebhooks-cli serve install --force
|
|
145
152
|
|
|
146
153
|
# Uninstall the service
|
|
147
|
-
sudo gitwebhooks-cli
|
|
154
|
+
sudo gitwebhooks-cli serve uninstall
|
|
148
155
|
```
|
|
149
156
|
|
|
157
|
+
**Configuration levels**:
|
|
158
|
+
- **user**: `~/.gitwebhooks.ini` - Single user configuration, highest priority
|
|
159
|
+
- **local**: `/usr/local/etc/gitwebhooks.ini` - Local system configuration, medium priority
|
|
160
|
+
- **system**: `/etc/gitwebhooks.ini` - Global system configuration, lowest priority
|
|
161
|
+
|
|
150
162
|
**Service file auto-detection**:
|
|
151
163
|
- **pipx installation**: Uses `gitwebhooks-cli` command directly
|
|
152
|
-
- **venv/virtualenv**: Uses `python -m gitwebhooks.
|
|
153
|
-
- **System pip**: Uses system Python with `python -m gitwebhooks.
|
|
164
|
+
- **venv/virtualenv**: Uses `python -m gitwebhooks.main` with environment's Python
|
|
165
|
+
- **System pip**: Uses system Python with `python -m gitwebhooks.main`
|
|
154
166
|
- **conda**: Not supported - installation will be refused with clear error message
|
|
155
167
|
|
|
156
168
|
### Manual Installation
|
|
@@ -168,7 +180,14 @@ sudo ln "$(pwd)/gitwebhooks-cli" /usr/local/bin/gitwebhooks-cli
|
|
|
168
180
|
### Verify Installation
|
|
169
181
|
|
|
170
182
|
```bash
|
|
171
|
-
|
|
183
|
+
# Show version
|
|
184
|
+
gitwebhooks-cli -v
|
|
185
|
+
|
|
186
|
+
# Show help
|
|
187
|
+
gitwebhooks-cli help
|
|
188
|
+
|
|
189
|
+
# View configuration
|
|
190
|
+
gitwebhooks-cli config view
|
|
172
191
|
```
|
|
173
192
|
|
|
174
193
|
## Migrating from System pip Installation
|
|
@@ -129,28 +129,40 @@ sudo gitwebhooks-cli config init system # 系统级(/etc/gitwebhooks.ini,需
|
|
|
129
129
|
服务安装命令会自动检测您的安装类型(pipx、venv 或系统)并生成相应的服务文件。
|
|
130
130
|
|
|
131
131
|
```bash
|
|
132
|
-
# 安装并启动为 systemd
|
|
133
|
-
sudo gitwebhooks-cli
|
|
132
|
+
# 安装并启动为 systemd 服务(交互式选择配置级别)
|
|
133
|
+
sudo gitwebhooks-cli serve install
|
|
134
|
+
|
|
135
|
+
# 使用指定配置级别安装(跳过交互式选择)
|
|
136
|
+
sudo gitwebhooks-cli serve install --config-level user # 用户级配置 (~/.gitwebhooks.ini)
|
|
137
|
+
sudo gitwebhooks-cli serve install --config-level local # 本地级配置 (/usr/local/etc/gitwebhooks.ini)
|
|
138
|
+
sudo gitwebhooks-cli serve install --config-level system # 系统级配置 (/etc/gitwebhooks.ini)
|
|
139
|
+
|
|
140
|
+
# 使用自定义配置文件(向后兼容)
|
|
141
|
+
sudo gitwebhooks-cli serve install -c /path/to/config.ini
|
|
134
142
|
|
|
135
143
|
# 预览服务文件但不安装(dry-run 模式)
|
|
136
|
-
sudo gitwebhooks-cli
|
|
144
|
+
sudo gitwebhooks-cli serve install --dry-run
|
|
145
|
+
sudo gitwebhooks-cli serve install --config-level local --dry-run # 预览指定级别的配置
|
|
137
146
|
|
|
138
147
|
# 安装并显示详细输出
|
|
139
|
-
sudo gitwebhooks-cli
|
|
140
|
-
sudo gitwebhooks-cli service install -v # 基本详细程度
|
|
141
|
-
sudo gitwebhooks-cli service install -vv # 额外详细程度
|
|
148
|
+
sudo gitwebhooks-cli serve install --verbose
|
|
142
149
|
|
|
143
150
|
# 强制覆盖现有服务
|
|
144
|
-
sudo gitwebhooks-cli
|
|
151
|
+
sudo gitwebhooks-cli serve install --force
|
|
145
152
|
|
|
146
153
|
# 卸载服务
|
|
147
|
-
sudo gitwebhooks-cli
|
|
154
|
+
sudo gitwebhooks-cli serve uninstall
|
|
148
155
|
```
|
|
149
156
|
|
|
157
|
+
**配置级别说明**:
|
|
158
|
+
- **user(用户级)**:`~/.gitwebhooks.ini` - 单用户配置,最高优先级
|
|
159
|
+
- **local(本地级)**:`/usr/local/etc/gitwebhooks.ini` - 本地系统配置,中等优先级
|
|
160
|
+
- **system(系统级)**:`/etc/gitwebhooks.ini` - 全局系统配置,最低优先级
|
|
161
|
+
|
|
150
162
|
**服务文件自动检测**:
|
|
151
163
|
- **pipx 安装**:直接使用 `gitwebhooks-cli` 命令
|
|
152
|
-
- **venv/virtualenv**:使用环境的 Python 执行 `python -m gitwebhooks.
|
|
153
|
-
- **系统 pip**:使用系统 Python 执行 `python -m gitwebhooks.
|
|
164
|
+
- **venv/virtualenv**:使用环境的 Python 执行 `python -m gitwebhooks.main`
|
|
165
|
+
- **系统 pip**:使用系统 Python 执行 `python -m gitwebhooks.main`
|
|
154
166
|
- **conda**:不支持 - 安装将被拒绝并显示明确错误消息
|
|
155
167
|
|
|
156
168
|
### 手动安装
|
|
@@ -168,7 +180,14 @@ sudo ln "$(pwd)/gitwebhooks-cli" /usr/local/bin/gitwebhooks-cli
|
|
|
168
180
|
### 验证安装
|
|
169
181
|
|
|
170
182
|
```bash
|
|
171
|
-
|
|
183
|
+
# 显示版本
|
|
184
|
+
gitwebhooks-cli -v
|
|
185
|
+
|
|
186
|
+
# 显示帮助
|
|
187
|
+
gitwebhooks-cli help
|
|
188
|
+
|
|
189
|
+
# 查看配置
|
|
190
|
+
gitwebhooks-cli config view
|
|
172
191
|
```
|
|
173
192
|
|
|
174
193
|
## 从系统 pip 安装迁移
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
"""CLI subcommands module
|
|
2
|
+
|
|
3
|
+
Provides subcommand registration and implementation for gitwebhooks-cli.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from gitwebhooks.cli.service import cmd_install, cmd_uninstall
|
|
7
|
+
from gitwebhooks.cli.config import cmd_init, cmd_view
|
|
8
|
+
from gitwebhooks.cli.help import cmd_help
|
|
9
|
+
from gitwebhooks.cli.serve import cmd_serve
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def register_subparsers(subparsers):
|
|
13
|
+
"""Register all CLI subparsers
|
|
14
|
+
|
|
15
|
+
Args:
|
|
16
|
+
subparsers: argparse subparsers object from ArgumentParser.add_subparsers()
|
|
17
|
+
|
|
18
|
+
Returns:
|
|
19
|
+
None
|
|
20
|
+
"""
|
|
21
|
+
# Register help subcommand
|
|
22
|
+
register_help_subparser(subparsers)
|
|
23
|
+
|
|
24
|
+
# Register serve subcommand
|
|
25
|
+
register_serve_subparser(subparsers)
|
|
26
|
+
|
|
27
|
+
# Register config subcommand
|
|
28
|
+
register_config_subparser(subparsers)
|
|
29
|
+
|
|
30
|
+
# Register service subcommand (deprecated, for backward compatibility)
|
|
31
|
+
register_service_subparser(subparsers)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def register_serve_subparser(subparsers):
|
|
35
|
+
"""Register serve subcommand and its actions
|
|
36
|
+
|
|
37
|
+
Args:
|
|
38
|
+
subparsers: argparse subparsers object
|
|
39
|
+
|
|
40
|
+
Returns:
|
|
41
|
+
None
|
|
42
|
+
"""
|
|
43
|
+
serve_parser = subparsers.add_parser(
|
|
44
|
+
'serve',
|
|
45
|
+
add_help=False,
|
|
46
|
+
help='Start webhook server or manage systemd service'
|
|
47
|
+
)
|
|
48
|
+
serve_parser.add_argument(
|
|
49
|
+
'-c', '--config',
|
|
50
|
+
dest='config',
|
|
51
|
+
help='Path to configuration file (default: auto-discover)'
|
|
52
|
+
)
|
|
53
|
+
serve_subparsers = serve_parser.add_subparsers(dest='serve_action')
|
|
54
|
+
|
|
55
|
+
# install action
|
|
56
|
+
install_parser = serve_subparsers.add_parser('install', add_help=False)
|
|
57
|
+
install_parser.add_argument(
|
|
58
|
+
'--force',
|
|
59
|
+
action='store_true',
|
|
60
|
+
help='Force overwrite existing service'
|
|
61
|
+
)
|
|
62
|
+
install_parser.add_argument(
|
|
63
|
+
'--verbose',
|
|
64
|
+
action='count',
|
|
65
|
+
default=0,
|
|
66
|
+
help='Increase verbosity'
|
|
67
|
+
)
|
|
68
|
+
install_parser.add_argument(
|
|
69
|
+
'--dry-run',
|
|
70
|
+
action='store_true',
|
|
71
|
+
help='Preview mode without making changes'
|
|
72
|
+
)
|
|
73
|
+
install_parser.add_argument(
|
|
74
|
+
'--config-level',
|
|
75
|
+
choices=['user', 'local', 'system'],
|
|
76
|
+
help='Configuration file level (user/local/system)'
|
|
77
|
+
)
|
|
78
|
+
install_parser.set_defaults(func=cmd_serve)
|
|
79
|
+
|
|
80
|
+
# uninstall action
|
|
81
|
+
uninstall_parser = serve_subparsers.add_parser('uninstall', add_help=False)
|
|
82
|
+
uninstall_parser.add_argument(
|
|
83
|
+
'--purge',
|
|
84
|
+
action='store_true',
|
|
85
|
+
help='Also remove configuration file'
|
|
86
|
+
)
|
|
87
|
+
uninstall_parser.set_defaults(func=cmd_serve)
|
|
88
|
+
|
|
89
|
+
# Set default function for serve (when no action specified)
|
|
90
|
+
serve_parser.set_defaults(func=cmd_serve)
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def register_help_subparser(subparsers):
|
|
94
|
+
"""Register help subcommand
|
|
95
|
+
|
|
96
|
+
Args:
|
|
97
|
+
subparsers: argparse subparsers object
|
|
98
|
+
|
|
99
|
+
Returns:
|
|
100
|
+
None
|
|
101
|
+
"""
|
|
102
|
+
help_parser = subparsers.add_parser(
|
|
103
|
+
'help',
|
|
104
|
+
add_help=False
|
|
105
|
+
)
|
|
106
|
+
help_parser.add_argument(
|
|
107
|
+
'topic',
|
|
108
|
+
nargs='?',
|
|
109
|
+
help='Subcommand to show help for (serve, config)'
|
|
110
|
+
)
|
|
111
|
+
help_parser.set_defaults(func=cmd_help)
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
def register_service_subparser(subparsers):
|
|
115
|
+
"""Register service subcommand and its actions (deprecated)
|
|
116
|
+
|
|
117
|
+
Args:
|
|
118
|
+
subparsers: argparse subparsers object
|
|
119
|
+
|
|
120
|
+
Returns:
|
|
121
|
+
None
|
|
122
|
+
"""
|
|
123
|
+
service_parser = subparsers.add_parser(
|
|
124
|
+
'service',
|
|
125
|
+
add_help=False,
|
|
126
|
+
help='Manage systemd service installation (deprecated, use "serve" instead)'
|
|
127
|
+
)
|
|
128
|
+
service_subparsers = service_parser.add_subparsers(dest='service_action')
|
|
129
|
+
|
|
130
|
+
# install action
|
|
131
|
+
install_parser = service_subparsers.add_parser('install', add_help=False)
|
|
132
|
+
install_parser.add_argument(
|
|
133
|
+
'--force',
|
|
134
|
+
action='store_true',
|
|
135
|
+
help='Force overwrite existing service'
|
|
136
|
+
)
|
|
137
|
+
install_parser.add_argument(
|
|
138
|
+
'-v', '--verbose',
|
|
139
|
+
action='count',
|
|
140
|
+
default=0,
|
|
141
|
+
help='Increase verbosity (can be used: -v, -vv)'
|
|
142
|
+
)
|
|
143
|
+
install_parser.add_argument(
|
|
144
|
+
'--dry-run',
|
|
145
|
+
action='store_true',
|
|
146
|
+
help='Preview service file without installing'
|
|
147
|
+
)
|
|
148
|
+
install_parser.add_argument(
|
|
149
|
+
'--config-level',
|
|
150
|
+
choices=['user', 'local', 'system'],
|
|
151
|
+
help='Configuration file level (user/local/system). If not specified, will be prompted.'
|
|
152
|
+
)
|
|
153
|
+
install_parser.set_defaults(func=cmd_install)
|
|
154
|
+
|
|
155
|
+
# uninstall action
|
|
156
|
+
uninstall_parser = service_subparsers.add_parser('uninstall', add_help=False)
|
|
157
|
+
uninstall_parser.add_argument(
|
|
158
|
+
'--purge',
|
|
159
|
+
action='store_true',
|
|
160
|
+
help='Also remove configuration file'
|
|
161
|
+
)
|
|
162
|
+
uninstall_parser.set_defaults(func=cmd_uninstall)
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
def register_config_subparser(subparsers):
|
|
166
|
+
"""Register config subcommand and its actions
|
|
167
|
+
|
|
168
|
+
Args:
|
|
169
|
+
subparsers: argparse subparsers object
|
|
170
|
+
|
|
171
|
+
Returns:
|
|
172
|
+
None
|
|
173
|
+
"""
|
|
174
|
+
config_parser = subparsers.add_parser(
|
|
175
|
+
'config',
|
|
176
|
+
add_help=False,
|
|
177
|
+
help='Manage gitwebhooks configuration'
|
|
178
|
+
)
|
|
179
|
+
config_subparsers = config_parser.add_subparsers(dest='config_action')
|
|
180
|
+
|
|
181
|
+
# init action
|
|
182
|
+
init_parser = config_subparsers.add_parser(
|
|
183
|
+
'init',
|
|
184
|
+
add_help=False,
|
|
185
|
+
help='Initialize configuration file using interactive wizard'
|
|
186
|
+
)
|
|
187
|
+
init_parser.add_argument(
|
|
188
|
+
'level',
|
|
189
|
+
nargs='?',
|
|
190
|
+
choices=['system', 'local', 'user'],
|
|
191
|
+
help='Configuration level (system/local/user). If not specified, will be prompted.'
|
|
192
|
+
)
|
|
193
|
+
init_parser.set_defaults(func=cmd_init)
|
|
194
|
+
|
|
195
|
+
# view action
|
|
196
|
+
view_parser = config_subparsers.add_parser('view', add_help=False)
|
|
197
|
+
view_parser.add_argument(
|
|
198
|
+
'-c',
|
|
199
|
+
'--config',
|
|
200
|
+
dest='config',
|
|
201
|
+
help='Path to configuration file (default: auto-detect)'
|
|
202
|
+
)
|
|
203
|
+
view_parser.set_defaults(func=cmd_view)
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"""Help command module
|
|
2
|
+
|
|
3
|
+
Provides help information display functionality for gitwebhooks-cli.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
import argparse
|
|
7
|
+
import sys
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def cmd_help(args: argparse.Namespace) -> int:
|
|
11
|
+
"""Handle help subcommand.
|
|
12
|
+
|
|
13
|
+
Displays main help or subcommand-specific help depending on the topic.
|
|
14
|
+
|
|
15
|
+
Args:
|
|
16
|
+
args: Parsed command-line arguments
|
|
17
|
+
- topic: Optional subcommand name to show help for
|
|
18
|
+
|
|
19
|
+
Returns:
|
|
20
|
+
Exit code (0 = success)
|
|
21
|
+
|
|
22
|
+
Examples:
|
|
23
|
+
>>> args = argparse.Namespace(topic=None)
|
|
24
|
+
>>> cmd_help(args) # doctest: +SKIP
|
|
25
|
+
0
|
|
26
|
+
>>> args = argparse.Namespace(topic='serve')
|
|
27
|
+
>>> cmd_help(args) # doctest: +SKIP
|
|
28
|
+
0
|
|
29
|
+
"""
|
|
30
|
+
# Import here to avoid circular dependency
|
|
31
|
+
from gitwebhooks.main import get_parser
|
|
32
|
+
|
|
33
|
+
parser = get_parser()
|
|
34
|
+
|
|
35
|
+
if hasattr(args, 'topic') and args.topic:
|
|
36
|
+
# Show subcommand help
|
|
37
|
+
show_subcommand_help(parser, args.topic)
|
|
38
|
+
else:
|
|
39
|
+
# Show main help
|
|
40
|
+
show_main_help(parser)
|
|
41
|
+
|
|
42
|
+
return 0
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def show_main_help(parser: argparse.ArgumentParser) -> None:
|
|
46
|
+
"""Display main help information.
|
|
47
|
+
|
|
48
|
+
Args:
|
|
49
|
+
parser: The main argument parser
|
|
50
|
+
|
|
51
|
+
Returns:
|
|
52
|
+
None
|
|
53
|
+
"""
|
|
54
|
+
# Custom help output
|
|
55
|
+
help_text = """Git Webhooks Server - Automated deployment webhook handler
|
|
56
|
+
|
|
57
|
+
Usage:
|
|
58
|
+
gitwebhooks-cli [-v] [-c CONFIG] <command> [<args>]
|
|
59
|
+
|
|
60
|
+
Commands:
|
|
61
|
+
serve Start webhook server or manage systemd service
|
|
62
|
+
config Manage configuration file
|
|
63
|
+
help Show help information
|
|
64
|
+
|
|
65
|
+
Options:
|
|
66
|
+
-v, --version Show version information
|
|
67
|
+
-c, --config Path to configuration file (default: auto-discover)
|
|
68
|
+
|
|
69
|
+
Examples:
|
|
70
|
+
gitwebhooks-cli serve # Start server
|
|
71
|
+
gitwebhooks-cli serve install # Install systemd service
|
|
72
|
+
gitwebhooks-cli config init # Initialize configuration
|
|
73
|
+
gitwebhooks-cli help serve # Show serve command help
|
|
74
|
+
|
|
75
|
+
For more information on a specific command:
|
|
76
|
+
gitwebhooks-cli help <command>
|
|
77
|
+
"""
|
|
78
|
+
print(help_text)
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def show_subcommand_help(parser: argparse.ArgumentParser, topic: str) -> None:
|
|
82
|
+
"""Display help for a specific subcommand.
|
|
83
|
+
|
|
84
|
+
Args:
|
|
85
|
+
parser: The main argument parser
|
|
86
|
+
topic: Subcommand name
|
|
87
|
+
|
|
88
|
+
Returns:
|
|
89
|
+
None
|
|
90
|
+
"""
|
|
91
|
+
# Map topic to help text
|
|
92
|
+
help_texts = {
|
|
93
|
+
'serve': """Command: serve
|
|
94
|
+
Start webhook server or manage systemd service
|
|
95
|
+
|
|
96
|
+
Usage:
|
|
97
|
+
gitwebhooks-cli serve [-c CONFIG]
|
|
98
|
+
gitwebhooks-cli serve install [--force] [--dry-run] [--verbose]
|
|
99
|
+
gitwebhooks-cli serve uninstall [--purge]
|
|
100
|
+
|
|
101
|
+
Subcommands:
|
|
102
|
+
(none) Start the webhook server
|
|
103
|
+
install Install systemd service
|
|
104
|
+
uninstall Uninstall systemd service
|
|
105
|
+
|
|
106
|
+
Options:
|
|
107
|
+
-c, --config Path to configuration file
|
|
108
|
+
|
|
109
|
+
Install options:
|
|
110
|
+
--force Force overwrite existing service
|
|
111
|
+
--dry-run Preview mode, don't make changes
|
|
112
|
+
--verbose Increase verbosity
|
|
113
|
+
|
|
114
|
+
Uninstall options:
|
|
115
|
+
--purge Also remove configuration file
|
|
116
|
+
|
|
117
|
+
Examples:
|
|
118
|
+
gitwebhooks-cli serve # Start server
|
|
119
|
+
gitwebhooks-cli serve -c /etc/webhooks.ini # Start with custom config
|
|
120
|
+
gitwebhooks-cli serve install # Install service
|
|
121
|
+
gitwebhooks-cli serve install --force # Force overwrite
|
|
122
|
+
gitwebhooks-cli serve uninstall # Uninstall service
|
|
123
|
+
""",
|
|
124
|
+
'config': """Command: config
|
|
125
|
+
Manage configuration file
|
|
126
|
+
|
|
127
|
+
Usage:
|
|
128
|
+
gitwebhooks-cli config init [level]
|
|
129
|
+
gitwebhooks-cli config view [-c CONFIG]
|
|
130
|
+
|
|
131
|
+
Subcommands:
|
|
132
|
+
init Initialize configuration file
|
|
133
|
+
view View configuration file
|
|
134
|
+
|
|
135
|
+
Init arguments:
|
|
136
|
+
level Configuration level (system, local, user)
|
|
137
|
+
|
|
138
|
+
View options:
|
|
139
|
+
-c, --config Path to configuration file
|
|
140
|
+
|
|
141
|
+
Examples:
|
|
142
|
+
gitwebhooks-cli config init # Interactive init
|
|
143
|
+
gitwebhooks-cli config init user # User-level config
|
|
144
|
+
gitwebhooks-cli config init system # System-level config (requires sudo)
|
|
145
|
+
gitwebhooks-cli config view # View current config
|
|
146
|
+
""",
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
if topic in help_texts:
|
|
150
|
+
print(help_texts[topic])
|
|
151
|
+
else:
|
|
152
|
+
print(f"Error: Unknown command '{topic}'", file=sys.stderr)
|
|
153
|
+
print("Available commands: serve, config", file=sys.stderr)
|
|
154
|
+
print()
|
|
155
|
+
print("Use 'gitwebhooks-cli help' to see main help", file=sys.stderr)
|
|
@@ -4,7 +4,9 @@ Provides functions for interactive user input and validation.
|
|
|
4
4
|
"""
|
|
5
5
|
|
|
6
6
|
import sys
|
|
7
|
-
from typing import Any, Callable, Optional, Dict, List
|
|
7
|
+
from typing import Any, Callable, Optional, Dict, List, Tuple
|
|
8
|
+
|
|
9
|
+
from gitwebhooks.utils.constants import ConfigLevel
|
|
8
10
|
|
|
9
11
|
|
|
10
12
|
# Question template for configuration initialization
|
|
@@ -273,3 +275,48 @@ def validate_text(value: str) -> str:
|
|
|
273
275
|
if not value:
|
|
274
276
|
raise ValueError('Input cannot be empty')
|
|
275
277
|
return value
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
def ask_config_level() -> ConfigLevel:
|
|
281
|
+
"""Ask user to select configuration file level
|
|
282
|
+
|
|
283
|
+
Displays an interactive menu for selecting configuration file level
|
|
284
|
+
with descriptions of each option.
|
|
285
|
+
|
|
286
|
+
Returns:
|
|
287
|
+
Selected ConfigLevel enum value
|
|
288
|
+
|
|
289
|
+
Raises:
|
|
290
|
+
KeyboardInterrupt: If user confirms exit on Ctrl+C
|
|
291
|
+
"""
|
|
292
|
+
print('Select configuration file level for the service:')
|
|
293
|
+
print(' 1. User level (~/.gitwebhooks.ini) - Single user, highest priority')
|
|
294
|
+
print(' 2. Local level (/usr/local/etc/gitwebhooks.ini) - Local system, medium priority')
|
|
295
|
+
print(' 3. System level (/etc/gitwebhooks.ini) - Global system, lowest priority')
|
|
296
|
+
print()
|
|
297
|
+
|
|
298
|
+
choice_map = {
|
|
299
|
+
'1': ConfigLevel.USER,
|
|
300
|
+
'2': ConfigLevel.LOCAL,
|
|
301
|
+
'3': ConfigLevel.SYSTEM,
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
while True:
|
|
305
|
+
try:
|
|
306
|
+
response = input('Enter choice [1-3] (default: 1): ').strip()
|
|
307
|
+
|
|
308
|
+
# Use default if empty input
|
|
309
|
+
if not response:
|
|
310
|
+
return ConfigLevel.USER
|
|
311
|
+
|
|
312
|
+
# Validate and map response
|
|
313
|
+
if response in choice_map:
|
|
314
|
+
return choice_map[response]
|
|
315
|
+
|
|
316
|
+
# Invalid input
|
|
317
|
+
print('Invalid choice. Please enter a number between 1 and 3.')
|
|
318
|
+
|
|
319
|
+
except KeyboardInterrupt:
|
|
320
|
+
if ask_yes_no('Confirm exit? (y/N) ', default=False):
|
|
321
|
+
print('\nService installation cancelled')
|
|
322
|
+
sys.exit(0)
|