Search code examples
gitreleasegit-pushfastlanerelease-management

How do I auto edit a .txt file with usual git push command?


I have a release-notes.txt file in my git project. I want to remove the old content of the file and put the name of the current branch into the file every time I use "git push". How do I do that?

Thanks in advance.


Solution

  • You really have do not want it, because

    1. Changing content of repo in the middle of transaction is The Bad Idea (tm)
    2. You'll get an infinitive loop as a result of content-manipulation in hook - "fired hook" -> "changed WT" -> "commit" -> "push" -> loop to start

    You try to perform deploy (sub)task in wrong place and time - information about last "last commit branch" is totally useless inside repo or Working tree and may have sense inside deployed and detached from repo project. But "how to put some data in some file on deploy" is another and different question.

    As last resort, if you still want to see this sort of crap in Working Tree, you can use smudge|clean fiters and do not mock logic and common sense. Just to remember - these filters are local tools and cannot be easily distributed as they are not part of the repository.