Skip to content

also add gitlab contributions - AI generated - #1

Open
individual-it wants to merge 1 commit into
generateGiftsfrom
gitlab
Open

also add gitlab contributions - AI generated#1
individual-it wants to merge 1 commit into
generateGiftsfrom
gitlab

Conversation

@individual-it

Copy link
Copy Markdown
Member

add also contributions to a GitLab instance to the chart

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 thread src/utils/api/gitlab.js
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);
Comment thread src/utils/export.js
}

export function cleanGitlabUsername(username) {
return username.trim().replace(/^(http|https):\/\/[^/]+\//, "");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants