androidiosgitreact-nativegit-describe

How to show git-describe in React Native app?


I generally like to automatically bake-in the results of a git describe --always --dirty in any website, app, etc I am developing so that I can easily trace behaviors. Right now, I can't figure out a way to get this in a React Native app.

I am using Android, but am certainly looking for a solution to both Android and iOS.


Solution

  • I found a way using a mix of other existing answers:

    1. Call git-describe during the build to access from gradle
    2. Call PackageManager to access the gradle config from Java
    3. Then use a React NativeModule in Java to access from JS

    Update (3 years later): Here's a minimal diff that shows how to implement in Android.