javagitspring-bootwar

Retrive hash number, git compiled war


Is it posible to retrive the hash number commit out of a compiled war? i have to make changes to a war file working on production server with a springboot api.

(The owner was a provider we can't contact anymore)

Is there a way to find out the commit hash number to clone a repository? Thank you very much!


Solution

  • Generally, when you build a war (or jar) file the id of your Git commit is not (!) stored into the war (or jar) file. The war (or jar) file, is simply a an archive with your Java classes and some additional meta information.

    If I was in your situation, I'd would open the war file using WinRAR (or some alternative packaging tool) and then proceed as follows:

    0) Check for build-info.properties

    If the person who build the WAR-file used the [spring-boot-maven-plugin][1] and its build-info goal, there might be a file META-INF\build-info.properties. It's not going to tell you the commit ID, but at least additional information on the version. If you find version information here and it is in the Git repository as well, this is likely your version.

    1) Check out manifest file

    The manifest file (/META-INF/MANIFEST.MF) sometimes contains information on the package's version (if it's set during build).

    2) Check out other files

    In the same archive, potentially in the root folder, there might be other text files (like for example a README) that could give you information on the version

    3) WAR-File Meta Data

    I'd check out the meta data of the WAR-file (if possible on the server it was downloaded from). Is there any information on when the file was created? This might give you hints about which commit (or commits) are candidates for the commit you are looking for.