How to display git sha in my ionic application

Is there a predefined template for entering a git hash during build in an ionic application?

I use https://www.npmjs.com/package/cordova-plugin-appversion to show the version of the assembly, but I would also like to show a short hash (first 7 characters).

Is hacky writing it to the properties file in the gulp assembly (putting this file in .gitignore) and then, if the file is present, displaying it in the application?

+5
source share
1 answer

Id says that using your build system (i.e. gulp) for this job is exactly what you need for this, not hacks at all.

Instead of including only the hash in your version string, you can include the output of git describe , which also contains the name of the last tag and how many changes have passed since then.

However, if your Gulpfile displays release assets that are version-controlled, you will have a small problem: if you create a commit with the released version (and possibly tag it), the hash that you built into the application before you point to commit with assets that you actually created for this version, but before the version in front of it. This is why most people use tags and version numbers, rather than hashes, to cross-reference a version of a binary application with the state of the original repository during build.

0
source

Source: https://habr.com/ru/post/1242589/


All Articles