Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
EXCLUDED: ${{ secrets.EXCLUDED }}
EXCLUDED_LANGS: ${{ secrets.EXCLUDED_LANGS }}
EXCLUDE_FORKED_REPOS: true
EXCLUDE_CONTRIB_REPOS: true

# Commit all changed files to the repository
- name: Commit to the repo
Expand Down
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,14 @@ For more information on inaccuracies, see issue
- To ignore certain languages, add them (separated by commas) to a new
secret called `EXCLUDED_LANGS`. For example, to exclude HTML and TeX you
could set the value to `html,tex`.
- To show statistics only for "owned" repositories and not forks with
contributions, add an environment variable (under the `env` header in the
[main
workflow](https://github.com/jstrieb/github-stats/blob/master/.github/workflows/main.yml))
called `EXCLUDE_FORKED_REPOS` with a value of `true`.
- By default, statistics include your owned repositories (non-forks) AND
repositories you've contributed to. Note: Contributed repositories count
their entire stars/forks/languages (not proportional to your contributions);
only "lines changed" reflects your actual contributions. To exclude
contributed repositories, set `EXCLUDE_CONTRIB_REPOS: true` in the `env`
section of the [main
workflow](https://github.com/jstrieb/github-stats/blob/master/.github/workflows/main.yml).
Your forked repositories are never counted as "owned".
- These other values are added as secrets by default to prevent leaking
information about private repositories. If you're not worried about that,
you can change the values directly [in the Actions workflow
Expand Down
16 changes: 11 additions & 5 deletions generate_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,16 @@ async def main() -> None:
{x.strip() for x in exclude_langs.split(",")} if exclude_langs else None
)
# Convert a truthy value to a Boolean
raw_ignore_forked_repos = os.getenv("EXCLUDE_FORKED_REPOS")
ignore_forked_repos = (
not not raw_ignore_forked_repos
and raw_ignore_forked_repos.strip().lower() != "false"
# Try new name first, fall back to old name for backward compatibility
raw_exclude_contrib_repos = os.getenv("EXCLUDE_CONTRIB_REPOS")
if raw_exclude_contrib_repos is None:
raw_exclude_contrib_repos = os.getenv("EXCLUDE_FORKED_REPOS")
if raw_exclude_contrib_repos is not None:
print("WARNING: EXCLUDE_FORKED_REPOS is deprecated. Please use EXCLUDE_CONTRIB_REPOS instead.")

exclude_contrib_repos = (
not not raw_exclude_contrib_repos
and raw_exclude_contrib_repos.strip().lower() != "false"
)
async with aiohttp.ClientSession() as session:
s = Stats(
Expand All @@ -127,7 +133,7 @@ async def main() -> None:
session,
exclude_repos=excluded_repos,
exclude_langs=excluded_langs,
ignore_forked_repos=ignore_forked_repos,
exclude_contrib_repos=exclude_contrib_repos,
)
await asyncio.gather(generate_languages(s), generate_overview(s))

Expand Down
6 changes: 3 additions & 3 deletions github_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,10 +257,10 @@ def __init__(
session: aiohttp.ClientSession,
exclude_repos: Optional[Set] = None,
exclude_langs: Optional[Set] = None,
ignore_forked_repos: bool = False,
exclude_contrib_repos: bool = False,
):
self.username = username
self._ignore_forked_repos = ignore_forked_repos
self._exclude_contrib_repos = exclude_contrib_repos
self._exclude_repos = set() if exclude_repos is None else exclude_repos
self._exclude_langs = set() if exclude_langs is None else exclude_langs
self.queries = Queries(username, access_token, session)
Expand Down Expand Up @@ -334,7 +334,7 @@ async def get_stats(self) -> None:
)

repos = owned_repos.get("nodes", [])
if not self._ignore_forked_repos:
if not self._exclude_contrib_repos:
repos += contrib_repos.get("nodes", [])

for repo in repos:
Expand Down