0

I am looking for a way to map a deployed software with its corresponding commit. The user clicks on help -> info and the dialog contains the hash number.

Is there a way to do this?

To be honest, I don't think so. So how are you setting up a link between your commits and your deployed software?

schotter
  • 13
  • 2
  • Do you use a build server? – dubes May 09 '16 at 07:45
  • @schotter It's most certainly possible, in a number of ways. E.g. embed the hash at compile time. But without knowing more about your setup it's hard to answer which way would be best for you. – Biffen May 09 '16 at 07:50
  • No mapping needed. Use tags. – choroba May 09 '16 at 07:51
  • @Biffen While writing I got the idea to put this into a Makefile. My target is a microcontroller and at the moment I think it's best to add something like "put hash as char string at flash position 0x1234". – schotter May 09 '16 at 08:06
  • @schotter since you don't use a build server, perhaps the answers on this [thread](http://stackoverflow.com/questions/3442874/in-git-how-can-i-write-the-current-commit-hash-to-a-file-in-the-same-commit) may be of help, I also updated my answer with a reference. – dubes May 09 '16 at 08:48

2 Answers2

1

This is very simple to do.

During the deploy or build step, you would need some way of querying git on the command line and extracting the latest commit hash. The same process would need to store the hash in some file that your application code is programmed to read. Good luck!

Venkat Naidu
  • 105
  • 6
0

tags are your friend, but manually maintaining them is painful. Since Git or any SCM tool would ideally be tracking your source code and not the deployable artifact, we will need some sort of external help to inject this. The good way is to use a build tool or a build server (details below), but as with almost anything with git, there is a hack (see this answer)

Releasing

Look for any "release" plugins so that they can maintain it for you, in my current project we are using the Axion Release Plugin for maintaining the versions.

Displaying the version

In our webapp we display the "version" in footer and also the git commit hash which is hidden in the page. These can be easily injected into manifest or properties file by a build server like Bamboo or Jenkins, or even with build tools Maven or Gradle.

Community
  • 1
  • 1
dubes
  • 5,324
  • 3
  • 34
  • 47