{"id":23171705,"url":"https://github.com/smarthypercube/git-date-truncate","last_synced_at":"2025-04-04T23:42:54.724Z","repository":{"id":127489413,"uuid":"395259036","full_name":"SmartHypercube/git-date-truncate","owner":"SmartHypercube","description":"Truncate dates and drop timezone in git commits.","archived":false,"fork":false,"pushed_at":"2024-06-06T04:29:18.000Z","size":5,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-10T08:16:28.352Z","etag":null,"topics":[],"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/SmartHypercube.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}},"created_at":"2021-08-12T09:06:14.000Z","updated_at":"2024-12-11T03:37:57.000Z","dependencies_parsed_at":null,"dependency_job_id":"f1a5e1fd-3102-4767-a5e9-c215328b7dae","html_url":"https://github.com/SmartHypercube/git-date-truncate","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/SmartHypercube%2Fgit-date-truncate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SmartHypercube%2Fgit-date-truncate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SmartHypercube%2Fgit-date-truncate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SmartHypercube%2Fgit-date-truncate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SmartHypercube","download_url":"https://codeload.github.com/SmartHypercube/git-date-truncate/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247266479,"owners_count":20910832,"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-12-18T04:19:18.096Z","updated_at":"2025-04-04T23:42:54.710Z","avatar_url":"https://github.com/SmartHypercube.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Truncate dates and drop timezones in git commits\n\nThese hooks modify the author date and committer date of any commit. An example:\n\n```bash\n$ git commit -m 'tmp'\ndate-truncate: 885c484 -\u003e 546299f (truncated author date and committer date)\n  (use \"git reset 885c484\" to undo)\n[master 885c484] tmp\n 1 file changed, 5 insertions(+)\n create mode 100644 tmp-file\n```\n\nWhen a commit is made, the author date and committer date are automatically truncated to the date part only, and the timezone information is dropped. The commit hash is changed as a result.\n\nThe old commit: (which will not be published if you run `git push`)\n\n```bash\n$ git show --format=fuller 885c484\ncommit 885c484cfc724dd7f4f087c08859b14019eaf3f9\nAuthor:     Hypercube \u003chypercube@0x01.me\u003e\nAuthorDate: Mon Apr 1 11:01:44 2024 +0800\nCommit:     Hypercube \u003chypercube@0x01.me\u003e\nCommitDate: Mon Apr 1 11:01:44 2024 +0800\n\n    tmp\n```\n\nThe new commit:\n\n```bash\n$ git show --format=fuller 546299f\ncommit 546299f946aac739d9ec6a8229434fb0be35963d (HEAD -\u003e master)\nAuthor:     Hypercube \u003chypercube@0x01.me\u003e\nAuthorDate: Mon Apr 1 00:00:00 2024 +0000\nCommit:     Hypercube \u003chypercube@0x01.me\u003e\nCommitDate: Mon Apr 1 00:00:00 2024 +0000\n\n    tmp\n```\n\n## How it works\n\nThe `git-date-truncate` script inspects the last commit, if its author name and author email matches `user.name` and `user.email` in the git configuration, it drops the time and timezone information from the author date. The same is done for the committer.\n\nThe hooks call the script after a commit is made. By default, it will output the old and new commit hashes, and a command to undo the operation, in case the user wants to revert the changes.\n\n## Installation\n\n1. Copy the `git-date-truncate` script to somewhere in your `$PATH`.\n2. Copy the files in `hooks` directory to `.config/git/template/hooks` or `~/.git-template/hooks`. If you only want to enable the hooks for a single repository, copy the files to `.git/hooks` in the repository.\n3. For all existing repositories, run `git init` in the repository to apply the hooks in the template directory.\n\n## Disclaimer\n\nThis script is not tested with all possible edge cases. Use at your own risk. In rare cases like complex rebases, the script may not work as expected.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmarthypercube%2Fgit-date-truncate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsmarthypercube%2Fgit-date-truncate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmarthypercube%2Fgit-date-truncate/lists"}