Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

To get Git commit information



  • Hi All,

    I want to add my Git commit information as a text with my "About software" section.
    Is there an easy way to get this information in Qt?



  • Are you using qmake or CMake?

    The general idea is to have the makefile generator run git log -1 --pretty=%B (or whatever other git command) during the config step and save the output to a header file that you can include



  • @VRonin Thank you. I'm using qmake.

    @VRonin said in To get Git commit information:

    The general idea is to have the makefile generator run git log -1 --pretty=%B (or whatever other git command) during the config step and save the output to a header file that you can include

    Can you show me an example?



  • something like:

    beforebuild.commands = git log -1 --pretty=%B > commitmessage.h
    QMAKE_EXTRA_TARGETS += beforebuild
    

    of course you'll need to format the output better and use depends on your main program to make sure this target is run first


Log in to reply