{"thread":{"id":"51126","subject":"improvement to pre-commit hook","startedAt":"2019-05-19T17:18:42Z","lastAt":"2019-05-20T23:45:17Z","messageCount":2,"participants":["Olegzandr von Denman (ORESoftware)","brian m. carlson"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"375877","messageId":"CAMsBkhmt0Xxe7EHSXJjxeZa4-CmF8oVgJiTFo2uHQOMcyKfCvw@mail.gmail.com","threadId":"51126","inReplyTo":null,"subject":"improvement to pre-commit hook","fromName":"Olegzandr von Denman (ORESoftware)","fromEmail":"alex@oresoftware.com","sentAt":"2019-05-19T06:03:11Z","receivedAt":"2019-05-19T17:18:42Z","isPatch":false,"sender":{"key":"alex@oresoftware.com","avatar":null},"body":"I was expected an env var like:\n\nGIT_DESIRED_COMMIT_MESSAGE\n\nto show up when .git/hooks/pre-commit is run\n\nbut as described here, there doesn't appear to be any args to the\nscript and the environment variable isn't there?\n\nhttps://stackoverflow.com/questions/56205170/retrieving-desired-git-commit-message-in-pre-commit-hook\n\n-alex\n\n-- \nAlexander Mills\nORESoftware (inc.)\n"},{"id":"375968","messageId":"20190520234509.GB8616@genre.crustytoothpaste.net","threadId":"51126","inReplyTo":"CAMsBkhmt0Xxe7EHSXJjxeZa4-CmF8oVgJiTFo2uHQOMcyKfCvw@mail.gmail.com","subject":"Re: improvement to pre-commit hook","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2019-05-20T23:45:09Z","receivedAt":"2019-05-20T23:45:17Z","isPatch":false,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On 2019-05-19 at 06:03:11, Olegzandr von Denman (ORESoftware) wrote:\n> I was expected an env var like:\n> \n> GIT_DESIRED_COMMIT_MESSAGE\n> \n> to show up when .git/hooks/pre-commit is run\n> \n> but as described here, there doesn't appear to be any args to the\n> script and the environment variable isn't there?\n> \n> https://stackoverflow.com/questions/56205170/retrieving-desired-git-commit-message-in-pre-commit-hook\n\nIn general, the pre-commit hook isn't the right place to inspect the\ncommit message. If the user hasn't specified the commit message on the\ncommand line, then they will be prompted for it using their editor, and\nthere will be nothing to process.\n\nFurthermore, since the prepare-commit-msg hook hasn't run, there could\nbe arbitrary changes to the commit message after the pre-commit hook\nruns. You'd want to use the prepare-commit-msg hook to modify the commit\nmessage and then use the commit-msg hook to accept or reject it. Despite\nthe name, the commit-msg hook can be used to perform arbitrary analysis\nof the commit and reject it for any reason if you require the commit\nmessage to do so.\n-- \nbrian m. carlson: Houston, Texas, US\nOpenPGP: https://keybase.io/bk2204\n"}]}