{"id":17146160,"url":"https://github.com/drew2a/git-insights","last_synced_at":"2025-09-03T03:38:27.426Z","repository":{"id":256219719,"uuid":"854595783","full_name":"drew2a/git-insights","owner":"drew2a","description":"A collection of scripts for analyzing and visualizing Git repositories. Explore commit history, contributor activity, code changes, and more with easy-to-use tools designed to help you gain insights into your codebase.","archived":false,"fork":false,"pushed_at":"2024-10-06T12:14:09.000Z","size":57,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-24T10:32:03.994Z","etag":null,"topics":["analytics","branch-age","code-insights","commit-activity","contributor-analysis","data-visualization","developer-tools","git","git-analytics","git-data","git-history","github-issues","project-metrics","python","repository-analysis","scripts","visualization"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/drew2a.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-09T13:04:32.000Z","updated_at":"2025-02-15T00:25:40.000Z","dependencies_parsed_at":"2024-12-02T02:16:04.325Z","dependency_job_id":null,"html_url":"https://github.com/drew2a/git-insights","commit_stats":null,"previous_names":["drew2a/git-insights"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/drew2a/git-insights","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drew2a%2Fgit-insights","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drew2a%2Fgit-insights/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drew2a%2Fgit-insights/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drew2a%2Fgit-insights/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/drew2a","download_url":"https://codeload.github.com/drew2a/git-insights/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drew2a%2Fgit-insights/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273386479,"owners_count":25096244,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-03T02:00:09.631Z","response_time":76,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["analytics","branch-age","code-insights","commit-activity","contributor-analysis","data-visualization","developer-tools","git","git-analytics","git-data","git-history","github-issues","project-metrics","python","repository-analysis","scripts","visualization"],"created_at":"2024-10-14T21:07:59.285Z","updated_at":"2025-09-03T03:38:27.401Z","avatar_url":"https://github.com/drew2a.png","language":"Python","readme":"# git-insights\n\n\u003e **Disclaimer:** This repository was entirely created by AI using [aider.chat](https://aider.chat/). All visualization ideas belong to @drew2a, but the code and documentation were written by ChatGPT-4 and Claude-3.5-Sonnet.\n\nA collection of scripts for analyzing and visualizing Git repositories. Explore commit history, contributor activity,\ncode changes, and more with easy-to-use tools designed to help you gain insights into your codebase.\n\n## Table of Contents\n\n- [Prerequisites](#prerequisites)\n- [plot_number_of_contributors.py](#plot_number_of_contributorspy)\n    - [Configurable Parameters](#configurable-parameters)\n    - [Examples](#examples)\n- [calculate_branch_age.py](#calculate_branch_agepy)\n- [plot_open_issues.py](#plot_open_issuespy)\n    - [Configurable Parameters](#configurable-parameters-1)\n    - [Examples](#examples-1)\n- [plot_open_issues.py](#plot_open_issuespy)\n    - [Configurable Parameters](#configurable-parameters-2)\n    - [Examples](#examples-2)\n\n## Prerequisites\n\nYou can install the required Python packages using:\n\n```bash\npip install -r requirements.txt\n```\n\n## plot_number_of_contributors.py\n\n`plot_number_of_contributors.py` is a versatile script designed to analyze and visualize contributor activity within a\nGit repository. By examining commit history, it identifies continuous contribution periods and aggregates contributor\ndata over time, providing insights into both individual and collective engagement patterns. The script offers\nconfigurable parameters to tailor the analysis, such as specifying the branch, excluding certain contributors, and\ndefining the time window for activity periods. It generates visualizations that highlight both all contributors and\nthose with sustained activity, making it a valuable tool for understanding contributor dynamics in a project.\n\nThe original work for this script was done\nhere: [GitHub Issue Comment](https://github.com/drew2a/ivory-tower/issues/1#issuecomment-1884614714).\n\n### Configurable Parameters\n\nThe script `plot_number_of_contributors.py` accepts the following configurable parameters:\n\n- `--repo_path`: Path to the repository. Default is the current directory (`.`).\n- `--branch`: Branch to analyze. Default is `main`.\n- `--exclusions`: List of contributors to exclude. Default is `[\"dependabot\", \"snyk\"]`.\n- `--delta_days`: Number of days to look back for commits. Default is 30 years (`365 * 30` days).\n- `--window_days`: The maximum allowed gap between consecutive commits to be considered as part of the same activity\n  period. For example, a 7-day window means that if the gap between two commits is less than or equal to 7 days, they\n  are considered part of a continuous contribution period. Default is 90 days.\n- `--granularity_days`: The minimum length of time that a contribution period must be to be considered. For instance, a\n  1-day granularity means that any period shorter than 1 day is extended to 1 day. Default is 15 days.\n- `--contribution_duration`: The minimum total number of days a contributor must have contributed to be included in the\n  analysis. For example, a filter of \"at least two days in total\" means that only contributors who have made commits on\n  two or more separate days throughout the entire period are included. Default is 1 day.\n- `--less_than_year`: Use less frequent date ticks on x-axis. This is a flag, so it has no default value.\n- `--activity_plot_file`: File name for the activity plot. Default is `out/activity_plot.png`.\n- `--contributor_count_plot_file`: File name for the contributor count plot. Default is\n  `out/contributor_count_plot.png`.\n\n### Examples\n\nTo generate the graphs, follow these steps:\n\n```bash\ngit clone \u003crepository-url\u003e\n```\n\nThen, use the following commands:\n\n#### All Contributors\n\nThis example visualizes all contributors over time with a window of 90 days, granularity of 15 days, and a minimum\ncontribution duration of 1 day. This setting captures all contributors who have made at least one commit within any\n90-day period, providing a broad view of contributor activity.\n\n```bash\npython plot_number_of_contributors.py --repo_path /path/to/repo --branch main --window_days 90 --granularity_days 15 --contribution_duration 1 --activity_plot_file all_contributors.png\n```\n\n![all_contributors](https://github.com/user-attachments/assets/59c44c57-ea72-4974-881a-f6a720ed57ff)\n\n#### Continuous Contributors\n\nThis example focuses on continuous contributors, using a window of 90 days, granularity of 1 day, and a minimum\ncontribution duration of 30 days. It highlights contributors who have been consistently active, making contributions\nover a longer period, thus offering insights into sustained engagement.\n\n```bash\npython plot_number_of_contributors.py --repo_path /path/to/repo --branch main --window_days 90 --granularity_days 1 --contribution_duration 30 --contributor_count_plot_file continuous_contributors.png\n```\n\n![ccontributors2](https://github.com/user-attachments/assets/bb11ab72-791a-46f6-9058-bb526f95bad6)\n\n## calculate_branch_age.py\n\n`calculate_branch_age.py` is a script designed to calculate and visualize the age of branches in a Git\nrepository. It fetches all branches, determines the fork and latest commit dates for each branch, and calculates\nthe age in days. The script then generates a horizontal bar plot showing the age of each branch, with additional labels\nfor the start and end dates of each branch's age.\n\n### Configurable Parameters\n\nThe script `calculate_branch_age.py` accepts the following configurable parameters:\n\n- `--repo_path`: Path to the repository. This parameter is required.\n- `--output_file`: File name for the branch age plot. Default is `out/branch_ages.png`.\n- `--branch_regex`: Regex pattern to filter branches. Default is `.+`.\n- `--min_age`: Minimum age of branches to include in days. Default is `0`.\n- `--main_branch`: Name of the main branch to compare against. Default is `main`.\n\n### Examples\n\nTo generate the branch age plot, follow these steps:\n\nClone the target repository:\n\n```bash\ngit clone \u003crepository-url\u003e\n```\n\nThen, use the following command to plot all branches older than 100 days for https://github.com/arvidn/libtorrent\n\n```bash\npython calculate_branch_age.py --repo_path ../../arvidn/libtorrent --main_branch master --min_age 100\n```\n\n![libtorrent_branch_ages](https://github.com/user-attachments/assets/1774e42f-fe64-40c3-b755-ebc5eda36309)\n\n## plot_open_issues.py\n\n`plot_open_issues.py` is a script designed to fetch and visualize open issues from a GitHub repository over time. It\nallows you to analyze the trend of open issues and visualize release periods with optional coloring and timestamp\ndisplay.\n\nDue to the limitations of the public GitHub REST API, the number of requests is restricted. To avoid frequent requests\nto GitHub, the script operates in two stages: first, it fetches all issues and releases and saves them to files; then,\nit analyzes these files.\n\n### Configurable Parameters\n\nThe script `plot_open_issues.py` accepts the following configurable parameters:\n\n- `--repo`: GitHub repository in the format \"owner/repo\". Default is `Tribler/tribler`.\n- `--issues_file`: File to save issues data. Default is `out/issues.json`.\n- `--releases_file`: File to save releases data. Default is `out/releases.json`.\n- `--state`: State of issues to fetch (e.g., open, closed, all). Default is `all`.\n- `--labels`: Labels to filter issues by. Default is `type: bug`.\n- `--override`: Override existing files and fetch new data. This is a flag, so it has no default value.\n- `--output_plot`: Output file for the plot. Default is `out/open_issues_plot.png`.\n- `--show_release_timestamps`: Display release timestamps on the plot. This is a flag, so it has no default value.\n- `--color_releases`: Color the release periods on the plot. This is a flag, so it has no default value.\n\n### Examples\n\nTo generate the plot, use the following command:\n\n```bash\npython plot_open_issues.py --repo Tribler/tribler --labels \"type: bug\" --output_plot out/open_issues_plot.png --show_release_timestamps --color_releases\n```\n\nThis command will fetch issues and releases from the specified repository, save the data to JSON files, and generate a\nplot of open bugs over time with colored release periods and timestamps.\n\n![open_issues_plot](https://github.com/user-attachments/assets/a2af5be3-35c1-4572-88ec-cca4f016b9ea)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdrew2a%2Fgit-insights","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdrew2a%2Fgit-insights","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdrew2a%2Fgit-insights/lists"}