gitlab-watcher 1.0.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.
- gitlab_watcher-1.0.0/PKG-INFO +175 -0
- gitlab_watcher-1.0.0/README.md +147 -0
- gitlab_watcher-1.0.0/pyproject.toml +48 -0
- gitlab_watcher-1.0.0/setup.cfg +4 -0
- gitlab_watcher-1.0.0/src/gitlab_watcher/__init__.py +3 -0
- gitlab_watcher-1.0.0/src/gitlab_watcher/__main__.py +6 -0
- gitlab_watcher-1.0.0/src/gitlab_watcher/cache.py +76 -0
- gitlab_watcher-1.0.0/src/gitlab_watcher/cli.py +24 -0
- gitlab_watcher-1.0.0/src/gitlab_watcher/config.py +233 -0
- gitlab_watcher-1.0.0/src/gitlab_watcher/discord.py +112 -0
- gitlab_watcher-1.0.0/src/gitlab_watcher/exceptions.py +106 -0
- gitlab_watcher-1.0.0/src/gitlab_watcher/git_ops.py +138 -0
- gitlab_watcher-1.0.0/src/gitlab_watcher/gitlab_client.py +364 -0
- gitlab_watcher-1.0.0/src/gitlab_watcher/logging_utils.py +56 -0
- gitlab_watcher-1.0.0/src/gitlab_watcher/processor.py +444 -0
- gitlab_watcher-1.0.0/src/gitlab_watcher/protocols.py +96 -0
- gitlab_watcher-1.0.0/src/gitlab_watcher/state.py +201 -0
- gitlab_watcher-1.0.0/src/gitlab_watcher/watcher.py +267 -0
- gitlab_watcher-1.0.0/src/gitlab_watcher.egg-info/PKG-INFO +175 -0
- gitlab_watcher-1.0.0/src/gitlab_watcher.egg-info/SOURCES.txt +31 -0
- gitlab_watcher-1.0.0/src/gitlab_watcher.egg-info/dependency_links.txt +1 -0
- gitlab_watcher-1.0.0/src/gitlab_watcher.egg-info/entry_points.txt +2 -0
- gitlab_watcher-1.0.0/src/gitlab_watcher.egg-info/requires.txt +7 -0
- gitlab_watcher-1.0.0/src/gitlab_watcher.egg-info/top_level.txt +1 -0
- gitlab_watcher-1.0.0/tests/test_cache.py +113 -0
- gitlab_watcher-1.0.0/tests/test_config.py +201 -0
- gitlab_watcher-1.0.0/tests/test_config_extra.py +274 -0
- gitlab_watcher-1.0.0/tests/test_discord.py +180 -0
- gitlab_watcher-1.0.0/tests/test_git_ops.py +259 -0
- gitlab_watcher-1.0.0/tests/test_gitlab_client.py +452 -0
- gitlab_watcher-1.0.0/tests/test_logging_utils.py +138 -0
- gitlab_watcher-1.0.0/tests/test_processor.py +804 -0
- gitlab_watcher-1.0.0/tests/test_watcher.py +885 -0
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: gitlab-watcher
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Monitor GitLab projects and automatically process issues and merge requests
|
|
5
|
+
Author: Gyengus
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/gyengus/gitlab-watcher
|
|
8
|
+
Project-URL: Repository, https://github.com/gyengus/gitlab-watcher.git
|
|
9
|
+
Project-URL: Issues, https://github.com/gyengus/gitlab-watcher/issues
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Environment :: Console
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Topic :: Software Development :: Bug Tracking
|
|
19
|
+
Classifier: Topic :: Software Development :: Version Control :: Git
|
|
20
|
+
Requires-Python: >=3.11
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
Requires-Dist: click>=8.0.0
|
|
23
|
+
Requires-Dist: requests>=2.28.0
|
|
24
|
+
Requires-Dist: charset-normalizer>=3.0.0
|
|
25
|
+
Provides-Extra: dev
|
|
26
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
27
|
+
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
|
|
28
|
+
|
|
29
|
+
# GitLab Watcher
|
|
30
|
+
|
|
31
|
+
Monitor GitLab projects and automatically process issues and merge requests using AI tools. It features built-in support for automated branch management, AI-driven code generation, and Discord notifications.
|
|
32
|
+
|
|
33
|
+
## What the Watcher Does
|
|
34
|
+
|
|
35
|
+
### Issue Processing (Automatic)
|
|
36
|
+
|
|
37
|
+
When an issue is assigned to the configured user without workflow labels:
|
|
38
|
+
|
|
39
|
+
1. Adds "In progress" label
|
|
40
|
+
2. Creates branch `<issue-id>-<slug>` from default branch
|
|
41
|
+
3. Runs AI tool with the issue description
|
|
42
|
+
4. Pushes changes and creates merge request
|
|
43
|
+
5. Moves issue to "Review" label
|
|
44
|
+
6. Sends optional Discord notification
|
|
45
|
+
|
|
46
|
+
### MR Comment Processing (Automatic)
|
|
47
|
+
|
|
48
|
+
When a new comment appears on an open MR (not from the bot user):
|
|
49
|
+
|
|
50
|
+
1. Checks out the MR's source branch
|
|
51
|
+
2. Runs AI tool with the comment as feedback
|
|
52
|
+
3. Pushes the changes to the remote branch
|
|
53
|
+
4. Notifies Discord channels about applied changes
|
|
54
|
+
|
|
55
|
+
### Post-Merge Cleanup (Automatic)
|
|
56
|
+
|
|
57
|
+
When an MR is merged:
|
|
58
|
+
|
|
59
|
+
1. Updates default branch (e.g., master/main)
|
|
60
|
+
2. Deletes the merged feature branch
|
|
61
|
+
3. Sends Discord notification to confirm cleanup
|
|
62
|
+
|
|
63
|
+
## Prerequisites
|
|
64
|
+
|
|
65
|
+
- **Python 3.11** or higher
|
|
66
|
+
- **Git** installed and available in your system path
|
|
67
|
+
- **GitLab Access Token** with API access
|
|
68
|
+
- **Claude CLI** (or `opencode`) must be installed and available in your PATH. (`ollama` is optional but supported for launching Claude).
|
|
69
|
+
|
|
70
|
+
## Installation
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
# From PyPI (recommended)
|
|
74
|
+
pip install gitlab-watcher
|
|
75
|
+
|
|
76
|
+
# From source (development mode)
|
|
77
|
+
git clone https://git.gyengus.hu/gyengus/gitlab-watcher.git
|
|
78
|
+
cd gitlab-watcher
|
|
79
|
+
pip install -e ".[dev]"
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Usage
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
# Run with default config
|
|
86
|
+
gitlab-watcher
|
|
87
|
+
|
|
88
|
+
# Custom config file
|
|
89
|
+
gitlab-watcher -c /path/to/config.conf
|
|
90
|
+
|
|
91
|
+
# Verbose mode
|
|
92
|
+
gitlab-watcher --verbose
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Configuration
|
|
96
|
+
|
|
97
|
+
Create the default configuration directory:
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
mkdir -p ~/.config/gitlab-watcher
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Create `~/.config/gitlab-watcher/config.conf` with your environment details:
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
# Your GitLab instance URL
|
|
107
|
+
GITLAB_URL="https://git.example.com"
|
|
108
|
+
|
|
109
|
+
# Personal or Group Access Token
|
|
110
|
+
GITLAB_TOKEN="your_token_here"
|
|
111
|
+
|
|
112
|
+
# (Optional) Discord Webhook for detailed event notifications
|
|
113
|
+
DISCORD_WEBHOOK="https://discord.com/api/webhooks/your_webhook_id"
|
|
114
|
+
|
|
115
|
+
# Monitoring interval in seconds
|
|
116
|
+
POLL_INTERVAL=30
|
|
117
|
+
|
|
118
|
+
# AI Tool implementation style (ollama, direct, opencode, custom)
|
|
119
|
+
AI_TOOL_MODE="ollama"
|
|
120
|
+
|
|
121
|
+
# List of absolute paths to project directories to monitor
|
|
122
|
+
PROJECT_DIRS=(
|
|
123
|
+
"/path/to/project1"
|
|
124
|
+
"/path/to/project2"
|
|
125
|
+
)
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
*(Note: If `GITLAB_URL` and `GITLAB_TOKEN` are not provided in the configuration, the watcher will attempt to extract them from your git remotes automatically.)*
|
|
129
|
+
|
|
130
|
+
Each monitored project directory must have a `PROJECT.md`, `AGENTS.md`, or `CLAUDE.md` file with a corresponding Project ID:
|
|
131
|
+
|
|
132
|
+
```markdown
|
|
133
|
+
Project ID: 31
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## Supported AI Tools
|
|
137
|
+
|
|
138
|
+
The watcher supports multiple AI tools:
|
|
139
|
+
|
|
140
|
+
| Mode | Description |
|
|
141
|
+
|------|-------------|
|
|
142
|
+
| `ollama` | Launches Claude via Ollama (requires both `ollama` and `claude`) (default) |
|
|
143
|
+
| `direct` | Direct Claude CLI execution (`claude`) |
|
|
144
|
+
| `opencode` | Opencode CLI execution (`opencode`) |
|
|
145
|
+
| `custom` | Custom command for any AI tool |
|
|
146
|
+
|
|
147
|
+
Configure in `config.conf`:
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
AI_TOOL_MODE="ollama" # or "direct", "opencode", "custom"
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## Development
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
# Install dev dependencies
|
|
157
|
+
pip install -e ".[dev]"
|
|
158
|
+
|
|
159
|
+
# Run tests
|
|
160
|
+
pytest
|
|
161
|
+
|
|
162
|
+
# Run tests with coverage
|
|
163
|
+
pytest --cov=gitlab_watcher
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## Support & Donations
|
|
167
|
+
|
|
168
|
+
If you find this tool helpful and would like to support its continued development, crypto donations are very much appreciated!
|
|
169
|
+
|
|
170
|
+
- **Bitcoin (BTC):** `bc1qx4q5epl7nsyu9mum8edrvp2my8tut0enrz7kcn`
|
|
171
|
+
- **Dogecoin (DOGE):** `DS62HBswTfAJLadRcMyrUJq6CAE8XV6SqC`
|
|
172
|
+
- **EVM (ETH/BSC/Polygon):** `0x9F0a70A7306DF3fc072446cAF540F6766a4CC4E8`
|
|
173
|
+
- **Web3 Domain:** `gyengus.sendme1satoshi.wallet`
|
|
174
|
+
|
|
175
|
+
Thank you for your support!
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
# GitLab Watcher
|
|
2
|
+
|
|
3
|
+
Monitor GitLab projects and automatically process issues and merge requests using AI tools. It features built-in support for automated branch management, AI-driven code generation, and Discord notifications.
|
|
4
|
+
|
|
5
|
+
## What the Watcher Does
|
|
6
|
+
|
|
7
|
+
### Issue Processing (Automatic)
|
|
8
|
+
|
|
9
|
+
When an issue is assigned to the configured user without workflow labels:
|
|
10
|
+
|
|
11
|
+
1. Adds "In progress" label
|
|
12
|
+
2. Creates branch `<issue-id>-<slug>` from default branch
|
|
13
|
+
3. Runs AI tool with the issue description
|
|
14
|
+
4. Pushes changes and creates merge request
|
|
15
|
+
5. Moves issue to "Review" label
|
|
16
|
+
6. Sends optional Discord notification
|
|
17
|
+
|
|
18
|
+
### MR Comment Processing (Automatic)
|
|
19
|
+
|
|
20
|
+
When a new comment appears on an open MR (not from the bot user):
|
|
21
|
+
|
|
22
|
+
1. Checks out the MR's source branch
|
|
23
|
+
2. Runs AI tool with the comment as feedback
|
|
24
|
+
3. Pushes the changes to the remote branch
|
|
25
|
+
4. Notifies Discord channels about applied changes
|
|
26
|
+
|
|
27
|
+
### Post-Merge Cleanup (Automatic)
|
|
28
|
+
|
|
29
|
+
When an MR is merged:
|
|
30
|
+
|
|
31
|
+
1. Updates default branch (e.g., master/main)
|
|
32
|
+
2. Deletes the merged feature branch
|
|
33
|
+
3. Sends Discord notification to confirm cleanup
|
|
34
|
+
|
|
35
|
+
## Prerequisites
|
|
36
|
+
|
|
37
|
+
- **Python 3.11** or higher
|
|
38
|
+
- **Git** installed and available in your system path
|
|
39
|
+
- **GitLab Access Token** with API access
|
|
40
|
+
- **Claude CLI** (or `opencode`) must be installed and available in your PATH. (`ollama` is optional but supported for launching Claude).
|
|
41
|
+
|
|
42
|
+
## Installation
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
# From PyPI (recommended)
|
|
46
|
+
pip install gitlab-watcher
|
|
47
|
+
|
|
48
|
+
# From source (development mode)
|
|
49
|
+
git clone https://git.gyengus.hu/gyengus/gitlab-watcher.git
|
|
50
|
+
cd gitlab-watcher
|
|
51
|
+
pip install -e ".[dev]"
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Usage
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
# Run with default config
|
|
58
|
+
gitlab-watcher
|
|
59
|
+
|
|
60
|
+
# Custom config file
|
|
61
|
+
gitlab-watcher -c /path/to/config.conf
|
|
62
|
+
|
|
63
|
+
# Verbose mode
|
|
64
|
+
gitlab-watcher --verbose
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Configuration
|
|
68
|
+
|
|
69
|
+
Create the default configuration directory:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
mkdir -p ~/.config/gitlab-watcher
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Create `~/.config/gitlab-watcher/config.conf` with your environment details:
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
# Your GitLab instance URL
|
|
79
|
+
GITLAB_URL="https://git.example.com"
|
|
80
|
+
|
|
81
|
+
# Personal or Group Access Token
|
|
82
|
+
GITLAB_TOKEN="your_token_here"
|
|
83
|
+
|
|
84
|
+
# (Optional) Discord Webhook for detailed event notifications
|
|
85
|
+
DISCORD_WEBHOOK="https://discord.com/api/webhooks/your_webhook_id"
|
|
86
|
+
|
|
87
|
+
# Monitoring interval in seconds
|
|
88
|
+
POLL_INTERVAL=30
|
|
89
|
+
|
|
90
|
+
# AI Tool implementation style (ollama, direct, opencode, custom)
|
|
91
|
+
AI_TOOL_MODE="ollama"
|
|
92
|
+
|
|
93
|
+
# List of absolute paths to project directories to monitor
|
|
94
|
+
PROJECT_DIRS=(
|
|
95
|
+
"/path/to/project1"
|
|
96
|
+
"/path/to/project2"
|
|
97
|
+
)
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
*(Note: If `GITLAB_URL` and `GITLAB_TOKEN` are not provided in the configuration, the watcher will attempt to extract them from your git remotes automatically.)*
|
|
101
|
+
|
|
102
|
+
Each monitored project directory must have a `PROJECT.md`, `AGENTS.md`, or `CLAUDE.md` file with a corresponding Project ID:
|
|
103
|
+
|
|
104
|
+
```markdown
|
|
105
|
+
Project ID: 31
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Supported AI Tools
|
|
109
|
+
|
|
110
|
+
The watcher supports multiple AI tools:
|
|
111
|
+
|
|
112
|
+
| Mode | Description |
|
|
113
|
+
|------|-------------|
|
|
114
|
+
| `ollama` | Launches Claude via Ollama (requires both `ollama` and `claude`) (default) |
|
|
115
|
+
| `direct` | Direct Claude CLI execution (`claude`) |
|
|
116
|
+
| `opencode` | Opencode CLI execution (`opencode`) |
|
|
117
|
+
| `custom` | Custom command for any AI tool |
|
|
118
|
+
|
|
119
|
+
Configure in `config.conf`:
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
AI_TOOL_MODE="ollama" # or "direct", "opencode", "custom"
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
## Development
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
# Install dev dependencies
|
|
129
|
+
pip install -e ".[dev]"
|
|
130
|
+
|
|
131
|
+
# Run tests
|
|
132
|
+
pytest
|
|
133
|
+
|
|
134
|
+
# Run tests with coverage
|
|
135
|
+
pytest --cov=gitlab_watcher
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## Support & Donations
|
|
139
|
+
|
|
140
|
+
If you find this tool helpful and would like to support its continued development, crypto donations are very much appreciated!
|
|
141
|
+
|
|
142
|
+
- **Bitcoin (BTC):** `bc1qx4q5epl7nsyu9mum8edrvp2my8tut0enrz7kcn`
|
|
143
|
+
- **Dogecoin (DOGE):** `DS62HBswTfAJLadRcMyrUJq6CAE8XV6SqC`
|
|
144
|
+
- **EVM (ETH/BSC/Polygon):** `0x9F0a70A7306DF3fc072446cAF540F6766a4CC4E8`
|
|
145
|
+
- **Web3 Domain:** `gyengus.sendme1satoshi.wallet`
|
|
146
|
+
|
|
147
|
+
Thank you for your support!
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "gitlab-watcher"
|
|
7
|
+
version = "1.0.0"
|
|
8
|
+
description = "Monitor GitLab projects and automatically process issues and merge requests"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
requires-python = ">=3.11"
|
|
12
|
+
authors = [
|
|
13
|
+
{name = "Gyengus"}
|
|
14
|
+
]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Development Status :: 4 - Beta",
|
|
17
|
+
"Environment :: Console",
|
|
18
|
+
"Intended Audience :: Developers",
|
|
19
|
+
"Operating System :: OS Independent",
|
|
20
|
+
"Programming Language :: Python :: 3",
|
|
21
|
+
"Programming Language :: Python :: 3.11",
|
|
22
|
+
"Programming Language :: Python :: 3.12",
|
|
23
|
+
"Programming Language :: Python :: 3.13",
|
|
24
|
+
"Topic :: Software Development :: Bug Tracking",
|
|
25
|
+
"Topic :: Software Development :: Version Control :: Git",
|
|
26
|
+
]
|
|
27
|
+
dependencies = [
|
|
28
|
+
"click>=8.0.0",
|
|
29
|
+
"requests>=2.28.0",
|
|
30
|
+
"charset-normalizer>=3.0.0",
|
|
31
|
+
]
|
|
32
|
+
|
|
33
|
+
[project.optional-dependencies]
|
|
34
|
+
dev = [
|
|
35
|
+
"pytest>=7.0.0",
|
|
36
|
+
"pytest-cov>=4.0.0",
|
|
37
|
+
]
|
|
38
|
+
|
|
39
|
+
[project.scripts]
|
|
40
|
+
gitlab-watcher = "gitlab_watcher.cli:main"
|
|
41
|
+
|
|
42
|
+
[project.urls]
|
|
43
|
+
Homepage = "https://github.com/gyengus/gitlab-watcher"
|
|
44
|
+
Repository = "https://github.com/gyengus/gitlab-watcher.git"
|
|
45
|
+
Issues = "https://github.com/gyengus/gitlab-watcher/issues"
|
|
46
|
+
|
|
47
|
+
[tool.setuptools.packages.find]
|
|
48
|
+
where = ["src"]
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"""Simple time-based cache implementation."""
|
|
2
|
+
|
|
3
|
+
from datetime import datetime, timedelta
|
|
4
|
+
from typing import Any, Generic, Optional, TypeVar
|
|
5
|
+
|
|
6
|
+
T = TypeVar('T')
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class TimedCache(Generic[T]):
|
|
10
|
+
"""Simple time-based cache that expires entries after a TTL.
|
|
11
|
+
|
|
12
|
+
This cache stores values with timestamps and automatically invalidates
|
|
13
|
+
entries that exceed the time-to-live duration.
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
def __init__(self, ttl_seconds: float = 30.0) -> None:
|
|
17
|
+
"""Initialize the cache.
|
|
18
|
+
|
|
19
|
+
Args:
|
|
20
|
+
ttl_seconds: Time-to-live in seconds for cache entries
|
|
21
|
+
"""
|
|
22
|
+
self._cache: dict[str, tuple[datetime, T]] = {}
|
|
23
|
+
self._ttl = timedelta(seconds=ttl_seconds)
|
|
24
|
+
|
|
25
|
+
def get(self, key: str) -> Optional[T]:
|
|
26
|
+
"""Get a value from cache if not expired.
|
|
27
|
+
|
|
28
|
+
Args:
|
|
29
|
+
key: Cache key
|
|
30
|
+
|
|
31
|
+
Returns:
|
|
32
|
+
Cached value if found and not expired, None otherwise
|
|
33
|
+
"""
|
|
34
|
+
if key not in self._cache:
|
|
35
|
+
return None
|
|
36
|
+
|
|
37
|
+
timestamp, value = self._cache[key]
|
|
38
|
+
|
|
39
|
+
# Check if entry has expired
|
|
40
|
+
if datetime.now() - timestamp > self._ttl:
|
|
41
|
+
del self._cache[key]
|
|
42
|
+
return None
|
|
43
|
+
|
|
44
|
+
return value
|
|
45
|
+
|
|
46
|
+
def set(self, key: str, value: T) -> None:
|
|
47
|
+
"""Store a value in cache.
|
|
48
|
+
|
|
49
|
+
Args:
|
|
50
|
+
key: Cache key
|
|
51
|
+
value: Value to cache
|
|
52
|
+
"""
|
|
53
|
+
self._cache[key] = (datetime.now(), value)
|
|
54
|
+
|
|
55
|
+
def invalidate(self, key: str) -> None:
|
|
56
|
+
"""Remove a specific entry from cache.
|
|
57
|
+
|
|
58
|
+
Args:
|
|
59
|
+
key: Cache key to invalidate
|
|
60
|
+
"""
|
|
61
|
+
self._cache.pop(key, None)
|
|
62
|
+
|
|
63
|
+
def clear(self) -> None:
|
|
64
|
+
"""Remove all entries from cache."""
|
|
65
|
+
self._cache.clear()
|
|
66
|
+
|
|
67
|
+
def size(self) -> int:
|
|
68
|
+
"""Return number of entries in cache (including expired ones).
|
|
69
|
+
|
|
70
|
+
Returns:
|
|
71
|
+
Number of cached entries
|
|
72
|
+
"""
|
|
73
|
+
return len(self._cache)
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
__all__ = ["TimedCache"]
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"""Click CLI entry point."""
|
|
2
|
+
|
|
3
|
+
import click
|
|
4
|
+
|
|
5
|
+
from .config import DEFAULT_CONFIG_PATH
|
|
6
|
+
from .watcher import Watcher
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@click.command()
|
|
10
|
+
@click.option(
|
|
11
|
+
"--config",
|
|
12
|
+
"-c",
|
|
13
|
+
default=DEFAULT_CONFIG_PATH,
|
|
14
|
+
help="Path to config file",
|
|
15
|
+
)
|
|
16
|
+
@click.option("--verbose", "-v", is_flag=True, help="Verbose output")
|
|
17
|
+
def main(config: str, verbose: bool) -> None:
|
|
18
|
+
"""GitLab Watcher - Monitor projects and process issues/MRs."""
|
|
19
|
+
watcher = Watcher(config_path=config, verbose=verbose)
|
|
20
|
+
watcher.run()
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
if __name__ == "__main__":
|
|
24
|
+
main()
|