From b9200c6cf69fea0101127dbe4aca435df0e183c0 Mon Sep 17 00:00:00 2001 From: Rick Staa Date: Wed, 7 Jun 2023 10:21:28 +0200 Subject: [PATCH] feat: remove 'include_private' (#2736) * feat: remove 'include_private' As explained in #2517 the 'include_private' flag is confusing and doesn't work as expected. This commit therefore removes this flag. * fix: fix tests * docs: remove redundant private deploy note --- api/index.js | 2 -- readme.md | 6 ++++-- src/fetchers/stats-fetcher.js | 8 -------- tests/fetchStats.test.js | 4 ++-- 4 files changed, 6 insertions(+), 14 deletions(-) diff --git a/api/index.js b/api/index.js index 29ff87f..21448f9 100644 --- a/api/index.js +++ b/api/index.js @@ -19,7 +19,6 @@ export default async (req, res) => { card_width, hide_rank, show_icons, - count_private, include_all_commits, line_height, title_color, @@ -52,7 +51,6 @@ export default async (req, res) => { try { const stats = await fetchStats( username, - parseBoolean(count_private), parseBoolean(include_all_commits), parseArray(exclude_repo), ); diff --git a/readme.md b/readme.md index e50d4fc..8e1a09f 100644 --- a/readme.md +++ b/readme.md @@ -111,7 +111,7 @@ Change the `?username=` value to your GitHub username. ``` > **Warning** -> By default, the stats card shows contributions only from public repositories. To show your private contributions, you should [deploy your own instance](#deploy-on-your-own) using your own GitHub API token, allowing you to see your private data. +> By default, the stats card only shows statistics like stars, commits and pull requests from public repositories. To show private statistics on the stats card, you should [deploy your own instance](#deploy-on-your-own) using your own GitHub API token. > **Note** > Available ranks are S+ (top 1%), S (top 25%), A++ (top 45%), A+ (top 60%), and B+ (everyone). The values are calculated by using the [cumulative distribution function](https://en.wikipedia.org/wiki/Cumulative_distribution_function) using commits, contributions, issues, stars, pull requests, followers, and owned repositories. The implementation can be investigated at [src/calculateRank.js](./src/calculateRank.js). @@ -276,7 +276,6 @@ You can provide multiple comma-separated values in the bg_color option to render - `rank_icon` - Shows alternative rank icon (i.e. `github` or `default`). Default: `default`. - `show_icons` - _(boolean)_. Default: `false`. - `include_all_commits` - Count total commits instead of just the current year commits _(boolean)_. Default: `false`. -- `count_private` - Count private contributions _(boolean)_. Default: `false`. - `line_height` - Sets the line height between text _(number)_. Default: `25`. - `exclude_repo` - Exclude stars from specified repositories _(Comma-separated values)_. Default: `[] (blank array)`. - `custom_title` - Sets a custom title for the card. Default: ` GitHub Stats`. @@ -352,6 +351,9 @@ Use [show_owner](#customization) variable to include the repo's owner username The top languages card shows a GitHub user's most frequently used top language. +> **Warning** +> By default, the language card shows language results only from public repositories. To include languages used in private repositories, you should [deploy your own instance](#deploy-on-your-own) using your own GitHub API token. + > **Note** > Top Languages does not indicate the user's skill level or anything like that; it's a GitHub metric to determine which languages have the most code on GitHub. It is a new feature of github-readme-stats. diff --git a/src/fetchers/stats-fetcher.js b/src/fetchers/stats-fetcher.js index 8fecffa..9ae23df 100644 --- a/src/fetchers/stats-fetcher.js +++ b/src/fetchers/stats-fetcher.js @@ -173,13 +173,11 @@ const totalCommitsFetcher = async (username) => { * Fetch stats for a given username. * * @param {string} username GitHub username. - * @param {boolean} count_private Include private contributions. * @param {boolean} include_all_commits Include all commits. * @returns {Promise} Stats data. */ const fetchStats = async ( username, - count_private = false, include_all_commits = false, exclude_repo = [], ) => { @@ -229,12 +227,6 @@ const fetchStats = async ( stats.totalCommits = user.contributionsCollection.totalCommitContributions; } - // if count_private, add private contributions to totalCommits. - if (count_private) { - stats.totalCommits += - user.contributionsCollection.restrictedContributionsCount; - } - stats.totalPRs = user.pullRequests.totalCount; stats.totalIssues = user.openIssues.totalCount + user.closedIssues.totalCount; stats.contributedTo = user.repositoriesContributedTo.totalCount; diff --git a/tests/fetchStats.test.js b/tests/fetchStats.test.js index 3b27e8a..5466f66 100644 --- a/tests/fetchStats.test.js +++ b/tests/fetchStats.test.js @@ -166,7 +166,7 @@ describe("Test fetchStats", () => { .onGet("https://api.github.com/search/commits?q=author:anuraghazra") .reply(200, { total_count: 1000 }); - let stats = await fetchStats("anuraghazra", false, true); + let stats = await fetchStats("anuraghazra", true); const rank = calculateRank({ all_commits: true, commits: 1000, @@ -193,7 +193,7 @@ describe("Test fetchStats", () => { .onGet("https://api.github.com/search/commits?q=author:anuraghazra") .reply(200, { total_count: 1000 }); - let stats = await fetchStats("anuraghazra", false, true, ["test-repo-1"]); + let stats = await fetchStats("anuraghazra", true, ["test-repo-1"]); const rank = calculateRank({ all_commits: true, commits: 1000,