also add gitlab contributions - AI generated - #1
Open
individual-it wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
Adds optional GitLab contribution data into the existing GitHub contributions chart flow by collecting GitLab connection details in the UI, passing them to the Next.js API route, fetching GitLab’s calendar.json server-side, and merging counts/levels into the returned contribution dataset.
Changes:
- Extend client/API request plumbing to pass optional GitLab URL/username and a token (via header).
- Implement server-side GitLab calendar fetching and merge GitLab daily counts into GitHub days (recompute intensity/color when needed).
- Update UI styling and documentation to support the new GitLab inputs.
Reviewed changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/utils/export.js | Adds GitLab params/header support to fetchData() and introduces GitLab-specific input cleaning helpers. |
| src/utils/api/gitlab.js | New helper to fetch GitLab calendar.json and convert it to a YYYY-MM-DD -> count map. |
| src/utils/api/fetch.js | Merges GitLab contributions into parsed GitHub day data and recalculates intensities/colors when GitLab data is present. |
| src/pages/api/v1/[username].js | Accepts GitLab query params + token header and passes them through to the fetch layer with error handling. |
| src/pages/index.js | Adds GitLab form fields and sends GitLab details to the API; updates the hard-coded date range. |
| src/styles/App.css | Adjusts form layout to accommodate additional inputs (column layout, shared sizing). |
| README.md | Documents how to include GitLab instance contributions and how the data is fetched/combined. |
| .gitignore | Ignores IDE metadata and package-lock.json. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+17
to
+20
| const baseUrl = gitlabUrl.trim().replace(/\/+$/, ""); | ||
| const url = `${baseUrl}/users/${encodeURIComponent( | ||
| username | ||
| )}/calendar.json`; |
Comment on lines
+4
to
+14
| const { username, format, gitlabUsername, gitlabUrl } = req.query; | ||
| // the token is sent in a header so that it does not end up in URLs / logs | ||
| const gitlabToken = req.headers['x-gitlab-token']; | ||
| try { | ||
| const data = await fetchDataForAllYears( | ||
| username, | ||
| format, | ||
| gitlabUsername, | ||
| gitlabUrl, | ||
| gitlabToken | ||
| ); |
Comment on lines
+15
to
+16
| res.setHeader('Cache-Control', 's-maxage=3600, stale-while-revalidate') | ||
| res.json(data); |
| } | ||
|
|
||
| export function cleanGitlabUsername(username) { | ||
| return username.trim().replace(/^(http|https):\/\/[^/]+\//, ""); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
add also contributions to a GitLab instance to the chart