1

I am working on a post receive hook to stop commits if the file extension doesn't respect the naming convention (extension need to be in upperCase/ and necessarily .PSK or .PBK), the problem I am facing : when I change test.txt to test.PSK by

git mv -f test.txt test.PSK
git commit --amend
git push -u origin master

GIT doesn't recognize that the extension changed and the hook returns the same error. because git commit --amend understand that test.txt is deleted and that there's a new file test.PSK

AILY
  • 345
  • 2
  • 3
  • 16
  • 1
    What you try is not a really good idea ;) some systems don't recognize the case. So if you run that commands on windows or OSX it's possible that it's not working. – René Höhle Oct 31 '17 at 17:06
  • what should i do ? – AILY Oct 31 '17 at 17:10
  • Don't change the file extension to uppercase what is in my eyes very useless. Lowercase make much more sense and it's not working on all systems. When you change the case on a linux system the Windows system won't recognize that and you get a lot of problems. – René Höhle Oct 31 '17 at 17:13
  • It's very important , it's a naming convention used to treat some issues from database – AILY Oct 31 '17 at 17:15
  • I don't know what you're trying but that doesn't sound like an application for git. – René Höhle Oct 31 '17 at 17:19
  • 3
    Don't change it in the hook. Just have your hooks check the convention and fail if it doesn't match. Pass the problem back to the developers to FIX THEIR CRAP if they aren't following the convention. – Paul Hodges Oct 31 '17 at 17:23
  • Wait, is the code shown your post-receive hook, or is an unspecified hook triggered by the `push` command in your question? – chepner Oct 31 '17 at 17:23
  • 2
    Git hooks should generally just fail with a message explaining why. You should really try to avoid *changing* the commit, because a dumb machine isn't going to handle exceptional cases well. Plus, by adding an extra commit, you've modified the history, which is just a pain for developers who now have re-merge from master before they can keep working. Believe me... after a few failed pushes, the devs will learn what to do/not do. – JDB Oct 31 '17 at 17:29
  • @JDB I'm not handling that in my hook , the hook only stops the push. I'm just testing with the commands in the question and i found that when i change the extension nothing happens . Guit doesn't recognize it. – AILY Oct 31 '17 at 17:47
  • @ILY - you're missing the `git add .` – JDB Oct 31 '17 at 17:49
  • @JBD OP is using `git mv` which stages the move, add is not needed. – 1615903 Nov 01 '17 at 04:22
  • More specifically, [this answer should work](https://stackoverflow.com/a/19956280/1615903) – 1615903 Nov 01 '17 at 04:26
  • @1615903 it's not the same I'm not having a problem with the filename but with the extension – AILY Nov 01 '17 at 09:43
  • File extension IS part of the filename. – 1615903 Nov 01 '17 at 09:48

0 Answers0