{"id":17037154,"url":"https://github.com/bast/git-bisect-exercise","last_synced_at":"2025-04-12T12:51:24.455Z","repository":{"id":20405520,"uuid":"23681642","full_name":"bast/git-bisect-exercise","owner":"bast","description":"Git bisect exercise.","archived":false,"fork":false,"pushed_at":"2019-03-29T15:23:18.000Z","size":129,"stargazers_count":8,"open_issues_count":0,"forks_count":50,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-26T07:36:20.222Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bast.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}},"created_at":"2014-09-04T22:28:16.000Z","updated_at":"2024-10-07T15:14:54.000Z","dependencies_parsed_at":"2022-07-31T18:48:11.941Z","dependency_job_id":null,"html_url":"https://github.com/bast/git-bisect-exercise","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bast%2Fgit-bisect-exercise","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bast%2Fgit-bisect-exercise/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bast%2Fgit-bisect-exercise/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bast%2Fgit-bisect-exercise/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bast","download_url":"https://codeload.github.com/bast/git-bisect-exercise/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248571381,"owners_count":21126517,"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":"2024-10-14T08:53:00.352Z","updated_at":"2025-04-12T12:51:24.421Z","avatar_url":"https://github.com/bast.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![License](https://img.shields.io/badge/license-%20BSD--3-blue.svg)](../master/LICENSE)\n\n\n## Git bisect exercise\n\n### Motivation\n\nThe motivation for this exercise is to be able to do archaeology with Git on a\nsource code where the bug is difficult to see visually. **Finding the offending\ncommit is often more than half the debugging**.\n\n\n### Background\n\nThe script `get_pi.py` approximates pi using terms of the Nilakantha series. It\nshould produce 3.14 but it does not. The script broke at some point and\nproduces 3.57 using the last commit:\n\n```\n$ python get_pi.py\n\n3.57\n```\n\nAt some point within the 500 first commits, an error was introduced. The only\nthing we know is that the first commit worked correctly.\n\n\n### Your task\n\nClone or fork this repository and use `git bisect` to find the commit which\nbroke the computation.\n\n\n### How to find the first commit\n\n```\n$ git log --oneline | tail -n 1\n```\n\n\n### Bonus exercise\n\nWrite a script that checks for a correct result and use `git bisect run` to\nfind the offending commit automatically.\n\n\n### Solutions (spoiler alert!)\n\nThe offending commit is commit number 137.\n\nAnd here is a Python script which can be used together with `git bisect run`\nto find the offending commit automatically:\n\n```python\nimport subprocess\nimport math\nimport sys\n\noutput = subprocess.check_output(['python', 'get_pi.py'])\nresult = float(output)\n\nif math.isclose(result, 3.14):\n    sys.exit(0)\nelse:\n    sys.exit(1)\n```\n\nBut you can also try to solve this using a shell script or a script\nin your favourite language.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbast%2Fgit-bisect-exercise","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbast%2Fgit-bisect-exercise","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbast%2Fgit-bisect-exercise/lists"}