git-asgi 0.1__tar.gz → 0.2__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.
- {git_asgi-0.1 → git_asgi-0.2}/CHANGELOG.md +16 -0
- {git_asgi-0.1 → git_asgi-0.2}/PKG-INFO +42 -3
- {git_asgi-0.1 → git_asgi-0.2}/README.md +41 -2
- {git_asgi-0.1 → git_asgi-0.2}/src/git_asgi/app.py +2 -0
- {git_asgi-0.1 → git_asgi-0.2}/src/git_asgi/middleware.py +1083 -156
- git_asgi-0.2/src/git_asgi/pktline.py +923 -0
- git_asgi-0.2/src/git_asgi/receive.py +1867 -0
- {git_asgi-0.1 → git_asgi-0.2}/src/git_asgi/utils.py +7 -4
- {git_asgi-0.1 → git_asgi-0.2}/src/git_asgi.egg-info/PKG-INFO +42 -3
- {git_asgi-0.1 → git_asgi-0.2}/src/git_asgi.egg-info/SOURCES.txt +1 -0
- {git_asgi-0.1 → git_asgi-0.2}/src/git_asgi.egg-info/scm_file_list.json +1 -0
- git_asgi-0.2/src/git_asgi.egg-info/scm_version.json +8 -0
- git_asgi-0.1/src/git_asgi/pktline.py +0 -242
- git_asgi-0.1/src/git_asgi.egg-info/scm_version.json +0 -8
- {git_asgi-0.1 → git_asgi-0.2}/.gitignore +0 -0
- {git_asgi-0.1 → git_asgi-0.2}/.python-version +0 -0
- {git_asgi-0.1 → git_asgi-0.2}/LICENSE +0 -0
- {git_asgi-0.1 → git_asgi-0.2}/cliff.toml +0 -0
- {git_asgi-0.1 → git_asgi-0.2}/prek.toml +0 -0
- {git_asgi-0.1 → git_asgi-0.2}/pyproject.toml +0 -0
- {git_asgi-0.1 → git_asgi-0.2}/ruff.toml +0 -0
- {git_asgi-0.1 → git_asgi-0.2}/setup.cfg +0 -0
- {git_asgi-0.1 → git_asgi-0.2}/src/git_asgi/__init__.py +0 -0
- {git_asgi-0.1 → git_asgi-0.2}/src/git_asgi/py.typed +0 -0
- {git_asgi-0.1 → git_asgi-0.2}/src/git_asgi.egg-info/dependency_links.txt +0 -0
- {git_asgi-0.1 → git_asgi-0.2}/src/git_asgi.egg-info/requires.txt +0 -0
- {git_asgi-0.1 → git_asgi-0.2}/src/git_asgi.egg-info/top_level.txt +0 -0
- {git_asgi-0.1 → git_asgi-0.2}/uv.lock +0 -0
|
@@ -12,6 +12,22 @@ Instead of [Semantic Versioning (SemVer)](https://semver.org/), the project adhe
|
|
|
12
12
|
Here, attention mainly refers to the impact of new features or the effort to the new version.
|
|
13
13
|
|
|
14
14
|
|
|
15
|
+
## 0.2 - 2026-11-25
|
|
16
|
+
|
|
17
|
+
### Added
|
|
18
|
+
|
|
19
|
+
- Add support for object querying
|
|
20
|
+
- Add support for `pre_receive` and `update` hooks
|
|
21
|
+
- Add support for `post_receive` and `post_update` hooks
|
|
22
|
+
- Add `pktline` codec
|
|
23
|
+
|
|
24
|
+
### Changed
|
|
25
|
+
|
|
26
|
+
- Improve logging when waiting on free resources for a process
|
|
27
|
+
- Replace the `base` path in the output of the `POST` service
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
15
31
|
## 0.1 - 2026-11-06
|
|
16
32
|
|
|
17
33
|
### Added
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: git-asgi
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.2
|
|
4
4
|
Summary: Git HTTP server as ASGI middleware according to spec.
|
|
5
5
|
Author-email: Jakob Zahn <jakob.zahn@mailbox.org>
|
|
6
6
|
Maintainer-email: Jakob Zahn <jakob.zahn@mailbox.org>
|
|
@@ -44,7 +44,7 @@ Dynamic: license-file
|
|
|
44
44
|
- [x] enabling and disabling of reading, writing or archiving
|
|
45
45
|
- [x] compatible with both SHA1 and SHA256 repositories
|
|
46
46
|
- [x] flexible and attachable logging formatting
|
|
47
|
-
- [
|
|
47
|
+
- [x] custom server-side Git hooks
|
|
48
48
|
- [ ] fully tested
|
|
49
49
|
- [x] fully documented
|
|
50
50
|
- [x] fully typed
|
|
@@ -65,6 +65,7 @@ The ASGI application is named `app`, located in the [`git_asgi.app`](./src/git_a
|
|
|
65
65
|
|
|
66
66
|
```sh
|
|
67
67
|
GIT_ASGI_BASE=/path/to/repos \
|
|
68
|
+
GIT_ASGI_TMP=/path/to/temporary/quarantines \
|
|
68
69
|
GIT_ASGI_LOGGER=base.logger.name \
|
|
69
70
|
GIT_ASGI_LEVEL=git-logger-logging-level \
|
|
70
71
|
GIT_ASGI_FORMAT=git-request-logger-str-format \
|
|
@@ -111,6 +112,44 @@ Please refer to the documentation of your ASGI framework of choice on how to inc
|
|
|
111
112
|
|
|
112
113
|
If you need to align the app routes with the ones `GitMiddleware` uses, you will find them defined as regular expressions in the same [`git_asgi.middleware`](./src/git_asgi/middleware.py) Python module as well.
|
|
113
114
|
|
|
115
|
+
The `GitMiddleware` also features custom pre-receive, update, post-receive and post-update hooks as asynchronous generators alongside object information lookup.
|
|
116
|
+
Subclass `GitMiddleware` and define the corresponding method to your needs:
|
|
117
|
+
|
|
118
|
+
```python
|
|
119
|
+
from git_asgi.middleware import GitMiddleware, Reject
|
|
120
|
+
from git_asgi.receive import Action, ObjectType
|
|
121
|
+
|
|
122
|
+
class MyGitMiddleware(GitMiddleware):
|
|
123
|
+
async def pre_receive(self, repo, client):
|
|
124
|
+
# instantiate object query generator
|
|
125
|
+
objects = await self.objects(repo, client)
|
|
126
|
+
|
|
127
|
+
# prime and advance the infinite generator
|
|
128
|
+
async for _ in objects:
|
|
129
|
+
# receive a command from middleware
|
|
130
|
+
command = yield
|
|
131
|
+
|
|
132
|
+
# yield a report message for the client
|
|
133
|
+
yield b"run checks for %b" % command.ref
|
|
134
|
+
|
|
135
|
+
# check for pushed tags
|
|
136
|
+
if command.ref.startswith(b"refs/tags"):
|
|
137
|
+
match command.action:
|
|
138
|
+
case: Action.CREATE | Action.UPDATE:
|
|
139
|
+
obj = await objects.asend(command.new)
|
|
140
|
+
|
|
141
|
+
if obj.type is ObjectType.COMMIT:
|
|
142
|
+
raise Reject("pushing unannotated tags not allowed")
|
|
143
|
+
case Action.DELETE:
|
|
144
|
+
raise Reject("deleting tags not allowed")
|
|
145
|
+
|
|
146
|
+
# yield a report message for the client
|
|
147
|
+
yield b"checks passed for %b" % command.ref
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
Refer to the docstrings of the `pre_receive`, `update`, `post_receive` and `post_update` hook methods for detailed insights.
|
|
151
|
+
Also, the `objects` query method and possibly the `run` context manager method might be useful for you custom hooks.
|
|
152
|
+
|
|
114
153
|
|
|
115
154
|
## Development
|
|
116
155
|
|
|
@@ -159,7 +198,7 @@ If you think that your changes will be a beneficial contribution to the project,
|
|
|
159
198
|
|
|
160
199
|
## Changelog
|
|
161
200
|
|
|
162
|
-
Project changes are documented in [CHANGELOG.md](./CHANGELOG.md)
|
|
201
|
+
Project changes are documented in [CHANGELOG.md](./CHANGELOG.md).
|
|
163
202
|
|
|
164
203
|
|
|
165
204
|
## License
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
- [x] enabling and disabling of reading, writing or archiving
|
|
15
15
|
- [x] compatible with both SHA1 and SHA256 repositories
|
|
16
16
|
- [x] flexible and attachable logging formatting
|
|
17
|
-
- [
|
|
17
|
+
- [x] custom server-side Git hooks
|
|
18
18
|
- [ ] fully tested
|
|
19
19
|
- [x] fully documented
|
|
20
20
|
- [x] fully typed
|
|
@@ -35,6 +35,7 @@ The ASGI application is named `app`, located in the [`git_asgi.app`](./src/git_a
|
|
|
35
35
|
|
|
36
36
|
```sh
|
|
37
37
|
GIT_ASGI_BASE=/path/to/repos \
|
|
38
|
+
GIT_ASGI_TMP=/path/to/temporary/quarantines \
|
|
38
39
|
GIT_ASGI_LOGGER=base.logger.name \
|
|
39
40
|
GIT_ASGI_LEVEL=git-logger-logging-level \
|
|
40
41
|
GIT_ASGI_FORMAT=git-request-logger-str-format \
|
|
@@ -81,6 +82,44 @@ Please refer to the documentation of your ASGI framework of choice on how to inc
|
|
|
81
82
|
|
|
82
83
|
If you need to align the app routes with the ones `GitMiddleware` uses, you will find them defined as regular expressions in the same [`git_asgi.middleware`](./src/git_asgi/middleware.py) Python module as well.
|
|
83
84
|
|
|
85
|
+
The `GitMiddleware` also features custom pre-receive, update, post-receive and post-update hooks as asynchronous generators alongside object information lookup.
|
|
86
|
+
Subclass `GitMiddleware` and define the corresponding method to your needs:
|
|
87
|
+
|
|
88
|
+
```python
|
|
89
|
+
from git_asgi.middleware import GitMiddleware, Reject
|
|
90
|
+
from git_asgi.receive import Action, ObjectType
|
|
91
|
+
|
|
92
|
+
class MyGitMiddleware(GitMiddleware):
|
|
93
|
+
async def pre_receive(self, repo, client):
|
|
94
|
+
# instantiate object query generator
|
|
95
|
+
objects = await self.objects(repo, client)
|
|
96
|
+
|
|
97
|
+
# prime and advance the infinite generator
|
|
98
|
+
async for _ in objects:
|
|
99
|
+
# receive a command from middleware
|
|
100
|
+
command = yield
|
|
101
|
+
|
|
102
|
+
# yield a report message for the client
|
|
103
|
+
yield b"run checks for %b" % command.ref
|
|
104
|
+
|
|
105
|
+
# check for pushed tags
|
|
106
|
+
if command.ref.startswith(b"refs/tags"):
|
|
107
|
+
match command.action:
|
|
108
|
+
case: Action.CREATE | Action.UPDATE:
|
|
109
|
+
obj = await objects.asend(command.new)
|
|
110
|
+
|
|
111
|
+
if obj.type is ObjectType.COMMIT:
|
|
112
|
+
raise Reject("pushing unannotated tags not allowed")
|
|
113
|
+
case Action.DELETE:
|
|
114
|
+
raise Reject("deleting tags not allowed")
|
|
115
|
+
|
|
116
|
+
# yield a report message for the client
|
|
117
|
+
yield b"checks passed for %b" % command.ref
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Refer to the docstrings of the `pre_receive`, `update`, `post_receive` and `post_update` hook methods for detailed insights.
|
|
121
|
+
Also, the `objects` query method and possibly the `run` context manager method might be useful for you custom hooks.
|
|
122
|
+
|
|
84
123
|
|
|
85
124
|
## Development
|
|
86
125
|
|
|
@@ -129,7 +168,7 @@ If you think that your changes will be a beneficial contribution to the project,
|
|
|
129
168
|
|
|
130
169
|
## Changelog
|
|
131
170
|
|
|
132
|
-
Project changes are documented in [CHANGELOG.md](./CHANGELOG.md)
|
|
171
|
+
Project changes are documented in [CHANGELOG.md](./CHANGELOG.md).
|
|
133
172
|
|
|
134
173
|
|
|
135
174
|
## License
|
|
@@ -155,6 +155,7 @@ end = Application()
|
|
|
155
155
|
try:
|
|
156
156
|
# read environment variables
|
|
157
157
|
base = environ.get("GIT_ASGI_BASE", ".")
|
|
158
|
+
tmp = environ.get("GIT_ASGI_TMP")
|
|
158
159
|
logger = environ.get("GIT_ASGI_LOGGER")
|
|
159
160
|
level = environ.get("GIT_ASGI_LEVEL")
|
|
160
161
|
fmt = environ.get("GIT_ASGI_FORMAT")
|
|
@@ -171,6 +172,7 @@ try:
|
|
|
171
172
|
app = GitMiddleware(
|
|
172
173
|
end,
|
|
173
174
|
base=base,
|
|
175
|
+
tmp=tmp,
|
|
174
176
|
logger=logger,
|
|
175
177
|
level=level,
|
|
176
178
|
fmt=fmt,
|