forked from vhaudiquet/weekly-activity
Add GitLab source for gitlab.com and self-hosted instances (Salsa)
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# weekly-activity
|
||||
|
||||
Aggregate weekly activity across development platforms (Launchpad, GitHub) into a single text report.
|
||||
Aggregate weekly activity across development platforms (Launchpad, GitHub, GitLab) into a single text report.
|
||||
|
||||
## Usage
|
||||
|
||||
@@ -13,21 +13,37 @@ uv run weekly-activity launchpad --anonymous <username>
|
||||
uv run weekly-activity github <username>
|
||||
uv run weekly-activity github --token ghp_xxx <username>
|
||||
|
||||
# GitLab (gitlab.com by default; any self-hosted instance via --url, e.g. Debian Salsa;
|
||||
# uses GITLAB_TOKEN / SALSA_TOKEN env vars, anonymous works but rate-limited)
|
||||
uv run weekly-activity gitlab <username>
|
||||
uv run weekly-activity gitlab --url https://salsa.debian.org <username>
|
||||
uv run weekly-activity gitlab --url https://salsa.debian.org --token glpat-xxx <username>
|
||||
|
||||
# Custom date range (ISO dates, UTC)
|
||||
uv run weekly-activity launchpad --since 2025-08-01 --until 2025-08-15 <username>
|
||||
uv run weekly-activity github --since 2025-08-01 --until 2025-08-15 <username>
|
||||
uv run weekly-activity gitlab --since 2025-08-01 --until 2025-08-15 <username>
|
||||
```
|
||||
|
||||
### GitLab instances
|
||||
|
||||
Any GitLab instance works via `--url`. Token discovery order:
|
||||
|
||||
1. `--token` flag
|
||||
2. env var named by `--token-env`
|
||||
3. `<HOST>_TOKEN` derived from the instance host (e.g. `SALSA_TOKEN` for `salsa.debian.org`)
|
||||
4. `GITLAB_TOKEN`
|
||||
|
||||
## What it reports
|
||||
|
||||
| Section | Launchpad | GitHub |
|
||||
|---|---|---|
|
||||
| Merge proposals / PRs authored | `getMergeProposals` (created in range) | `/search/issues` (`author:` + `type:pr`) |
|
||||
| Review requests received | `getRequestedReviews` (filtered by `date_review_requested`) | `/search/issues` (`reviewed-by:` + `type:pr`) |
|
||||
| Reviews performed | `getRequestedReviews` (filtered by `date_reviewed`) | (same query) |
|
||||
| Issues / Bugs | `searchTasks` (reporter, commenter, assignee) | `/search/issues` (author, commenter, assignee) |
|
||||
| Repositories modified | `git_repositories.getRepositories` (`modified_since_date`) | `/users/{user}/repos` (filtered by `pushed_at`) |
|
||||
| Commits pushed | — (not in Launchpad REST API) | `/repos/{owner}/{repo}/commits` (per active repo) |
|
||||
| Section | Launchpad | GitHub | GitLab |
|
||||
|---|---|---|---|
|
||||
| Merge proposals / PRs authored | `getMergeProposals` (created in range) | `/search/issues` (`author:` + `type:pr`) | `/merge_requests` (`author_id`, created range) |
|
||||
| Review requests received | `getRequestedReviews` (filtered by `date_review_requested`) | `/search/issues` (`reviewed-by:` + `type:pr`) | — |
|
||||
| Reviews performed | `getRequestedReviews` (filtered by `date_reviewed`) | (same query) | events (`action=approved`) |
|
||||
| Issues / Bugs | `searchTasks` (reporter, commenter, assignee) | `/search/issues` (author, commenter, assignee) | `/issues` (`author_id`, `assignee_id`) |
|
||||
| Repositories modified | `git_repositories.getRepositories` (`modified_since_date`) | `/users/{user}/repos` (filtered by `pushed_at`) | — (covered by push events) |
|
||||
| Commits pushed | — (not in Launchpad REST API) | `/repos/{owner}/{repo}/commits` (per active repo) | events (`action=pushed`) |
|
||||
|
||||
### Default time window
|
||||
|
||||
@@ -39,11 +55,12 @@ Rolling 7 days ending today (inclusive). Override with `--since` / `--until` (IS
|
||||
src/weekly_activity/
|
||||
model.py ActivityReport, Section, last_week_window
|
||||
report.py format_report() — source-agnostic text renderer
|
||||
cli.py subcommand dispatch (launchpad | github)
|
||||
cli.py subcommand dispatch (launchpad | github | gitlab)
|
||||
sources/
|
||||
__init__.py ActivitySource protocol
|
||||
launchpad.py LaunchpadSource (launchpadlib)
|
||||
github.py GitHubSource (httpx)
|
||||
gitlab.py GitLabSource (httpx, REST v4 — gitlab.com or self-hosted)
|
||||
```
|
||||
|
||||
Each source implements `ActivitySource` — a `name` and a `collect(username, since, until) -> ActivityReport` method. Sources keep their own dataclasses internally; the shared contract is `Section` (title + pre-formatted lines) and `ActivityReport` (metadata + sections + warnings). The report formatter (`report.py`) is source-agnostic.
|
||||
@@ -62,6 +79,6 @@ uv run ty check # type check
|
||||
## Dependencies
|
||||
|
||||
- **launchpadlib** — Launchpad REST API client
|
||||
- **httpx** — GitHub REST API client
|
||||
- **httpx** — GitHub & GitLab REST API client
|
||||
- **ruff** — format + lint (dev)
|
||||
- **ty** — type check (dev)
|
||||
|
||||
Reference in New Issue
Block a user