{"id":26480767,"url":"https://github.com/andyg2/estimate-repo-hours","last_synced_at":"2026-04-15T06:36:23.620Z","repository":{"id":282344826,"uuid":"947905912","full_name":"andyg2/estimate-repo-hours","owner":"andyg2","description":null,"archived":false,"fork":false,"pushed_at":"2025-03-14T03:52:26.000Z","size":10,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-14T04:29:13.566Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/andyg2.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2025-03-13T12:40:03.000Z","updated_at":"2025-03-14T03:52:30.000Z","dependencies_parsed_at":"2025-03-14T04:39:15.367Z","dependency_job_id":null,"html_url":"https://github.com/andyg2/estimate-repo-hours","commit_stats":null,"previous_names":["andyg2/estimate-repo-hours"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andyg2%2Festimate-repo-hours","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andyg2%2Festimate-repo-hours/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andyg2%2Festimate-repo-hours/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andyg2%2Festimate-repo-hours/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andyg2","download_url":"https://codeload.github.com/andyg2/estimate-repo-hours/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244541807,"owners_count":20469240,"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","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":[],"created_at":"2025-03-20T02:45:54.746Z","updated_at":"2026-04-15T06:36:18.045Z","avatar_url":"https://github.com/andyg2.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Estimate Repository Hours\n\nA PHP script to estimate the total man-hours required to develop a project based on the commit history of a Git repository. The script analyzes the number of lines added and deleted, weights them by file type, and adjusts the estimate based on commit messages and developer experience.\n\n## Repository\n\n\u003chttps://github.com/andyg2/estimate-repo-hours\u003e\n\n## Features\n\n- Lines of Code (LOC) Analysis: Uses additions and deletions to calculate weighted changes.\n- File Type Weighting: Different file types (e.g., .php, .js, .html) are assigned weights based on complexity.\n- Commit Message Analysis: Adjusts time estimates based on the type of work (e.g., bug fixes, refactoring).\n- Developer Experience: Adjusts estimates based on developer skill level (junior, mid, senior).\n- Detailed Statistics: Outputs commit-level and file-level details for transparency.\n- Minimum Time Threshold: Ensures small commits are assigned a reasonable minimum time (15 minutes).\n- CLI Support: Accepts repository URL and developer experience level as command-line arguments.\n\n## Installation\n\n### Prerequisites\n\n- PHP (version 7.4 or higher)\n- Git\n\n### Steps\n\n1. Clone the repository:\n\n```bash\ngit clone https://github.com/andyg2/estimate-repo-hours.git\ncd estimate-repo-hours\n```\n\n2. Ensure PHP and Git are installed and accessible from the command line.\n\n## Usage\n\n### Basic Usage\n\nRun the script with the repository URL and optional developer experience level:\n\n```bash\nphp estimate-repo-hours.php \u003crepository-url\u003e [developer-experience]\n```\n\n- `\u003crepository-url\u003e`: The URL of the Git repository to analyze.\n- `[developer-experience]`: Optional. Developer experience level (junior, mid, or senior). Defaults to mid.\n\n### Example\n\n```bash\nphp estimate-repo-hours.php https://github.com/andyg2/recamera-sscma-node-protocol-mqtt junior\n```\n\n### Output\n\nThe script outputs detailed statistics for each commit, including:\n\n- Commit hash\n- Timestamp\n- Lines added and deleted\n- File type weight\n- Weighted changes\n- Adjusted time (hours)\n- Cumulative total hours\n\nIt also provides a summary of total commits, lines added/deleted, weighted changes, and estimated man-hours.\n\n## How It Works\n\n### Algorithm\n\n1. Clone Repository: The script clones the repository into a temporary directory.\n2. Fetch Git Log: It retrieves the commit history, including additions, deletions, and filenames.\n3. Calculate Weighted Changes:\n   - Each file type is assigned a weight based on complexity (e.g., .php = 1.2, .js = 1.0).\n   - Weighted changes = (additions + deletions) × file type weight.\n4. Adjust Time Estimate:\n   - Baseline time: 1 minute per line of code.\n   - Adjust based on commit message (e.g., bug fixes take less time, refactoring takes more).\n   - Adjust based on developer experience (junior developers take longer, senior developers take less time).\n5. Output Statistics: Detailed commit and file-level statistics are displayed, along with a summary.\n\n### Example Calculation\n\nFor a commit with:\n\n- 100 additions and 50 deletions in a PHP file (weight = 1.2).\n- Commit message: \"Fix bug in user authentication.\"\n- Developer: Junior.\n\n- Net changes: 100 + 50 = 150 lines.\n- Weighted changes: 150 × 1.2 = 180.\n- Baseline time: 180 × 1 minute = 180 minutes.\n- Adjust for bug fix: 180 × 0.8 = 144 minutes.\n- Adjust for junior developer: 144 × 1.5 = 216 minutes (3.6 hours).\n\n## Customization\n\n### File Type Weights\n\nYou can modify the getLanguageWeight function in the script to adjust weights for specific file types:\n\n```php\nfunction getLanguageWeight($filename) {\n  $weights = [\n    'html' =\u003e 0.5,\n    'css' =\u003e 0.7,\n    'js' =\u003e 1.0,\n    'php' =\u003e 1.2,\n    // Add or modify weights as needed\n  ];\n  $extension = pathinfo($filename, PATHINFO_EXTENSION);\n  return isset($weights[$extension]) ? $weights[$extension] : 1.0;\n}\n```\n\n### Commit Message Analysis\n\nYou can customize the analyzeCommitMessage function to adjust time estimates based on commit messages:\n\n```php\nfunction analyzeCommitMessage($message) {\n  $message = strtolower($message);\n  if (strpos($message, 'fix') !== false || strpos($message, 'bug') !== false) {\n    return 0.8; // Bug fixes take less time\n  } elseif (strpos($message, 'refactor') !== false) {\n    return 1.3; // Refactoring takes more time\n  }\n  return 1.0; // Default multiplier\n}\n```\n\n## Contributing\n\nContributions are welcome! If you'd like to improve the script, please:\n\n1. Fork the repository.\n2. Create a new branch for your feature or bug fix.\n3. Submit a pull request with a detailed description of your changes.\n\n## License\n\nThis project is licensed under the MIT License. See the LICENSE file for details.\n\n## Acknowledgments\n\n- Inspired by the need to estimate development effort for open-source projects.\n- Thanks to the PHP and Git communities for providing the tools to make this possible.\n\n## Support\n\nIf you have any questions or issues, please open an issue on the GitHub repository.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandyg2%2Festimate-repo-hours","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandyg2%2Festimate-repo-hours","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandyg2%2Festimate-repo-hours/lists"}