https://github.com/adam014/commit-sync
Synchronizes GitLab and GitHub commit activity into a single contribution heatmap.
https://github.com/adam014/commit-sync
Last synced: 10 months ago
JSON representation
Synchronizes GitLab and GitHub commit activity into a single contribution heatmap.
- Host: GitHub
- URL: https://github.com/adam014/commit-sync
- Owner: Adam014
- License: mit
- Created: 2025-04-13T09:38:47.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-06-27T18:54:09.000Z (12 months ago)
- Last Synced: 2025-07-07T00:08:44.189Z (11 months ago)
- Language: TypeScript
- Homepage: https://commit-sync.vercel.app
- Size: 111 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# commit-sync
# Overview
The Heatmap API generates a self‑contained SVG representing your activity for the current month, combining: - GitHub commits (via the Search API) - GitLab events - A GitHub‑style calendar grid - A month/year header, total‑event count, and a “Less … More” legend
All you need is to call:
```http
GET /api/heatmap?github=&gitlab=&mode=&bg=%
```
To get SVG image of your git heatmap.
## Endpoint
```http
GET /api/heatmap
Host: your-domain.com
```
Response:
- 200 OK
- `Content-Type: image/svg+xml`
- No caching (headers: `Cache-Control: no-cache, no store, must-revalidate)¨
## Query Parameters
| Parameter | Type | ?Required | Default | Description |
| --------- | ------ | --------- | -------------- | ----------------- |
| github | string | No | "" | Github username |
| gitlab | string | No | "" | Gitlab username |
| mode | string | No | "light" | "light" or "dark" |
| bg | hex | No | Light: #f4f8d3 |
| | | | Dark: #0a0a0a |
At least one of `github` or `gitlab` must be non-empty for any activity to appear. Empty names simply skip the corresponding service.
## How it works
1. Date range
- Automatically set to the first day of this month throught today
2. Github Commits
- Uses the Search Commits API:
```http
GET https://api.github.com/search/commits
?q=author: committer-date:..
&per_page=100
Accept: application/vnd.github.cloak-preview
Authorization: token YOUR_GITHUB_API_KEY
```
- Counts each returned commit
3. Gitlab Events
- Fetches the user by name, then their `/events?per_page=100` feed
- Counts each event occurrence
4. Aggregation
- Creates a day-keyed map (`YYYY-MM-DD`) initialized to zero for every day of the month.
- Increments the count for each commit/event
5. SVG Rendering
- Header: `April 2025 37 events`
- Legend: Less [□][□][□][□][□] More
- Grid: Weeks \* 7, each cell sized 30x30 pixels (with 2 pixels gaps), colored via `getColor(count, darkMode)` and labeled with the day number.
## Usage examples
### Light mode (default bg)
```html
```
### Dark mode with custom background
```html
alt="My April Activity (dark)"
/>
```
### Only GitHub
```html
```
###### Thanks if you read this far, I really appreciate it. It means a lot to me.