git_info_plus
get git information from within the flutter application.
usage
dart
final string branchname = await gitinfo.branchname;
final datetime lastcommitdate = await gitinfo.lastcommitdate;
final string lastcommithash = await gitinfo.lastcommithash;
final string lastcommithashshort = await gitinfo.lastcommithashshort;
final string lastcommitmessage = await gitinfo.lastcommitmessage;
setup
android
you do not need to set this up.
ios
in order to use this library on ios, you have to do some settings.
1. add values in your info.plist
|key|type|value|
|gitbranchname|string|undefined|
|gitcommitdate|string|undefined|
|gitcommithash|string|undefined|
|gitcommithashshort|string|undefined|
|gitcommitmessage|string|undefined|
you can also copy and paste these lines.
<key>gitbranchname</key>
<string>undefined</string>
<key>gitcommitdate</key>
<string>undefined</string>
<key>gitcommithash</key>
<string>undefined</string>
<key>gitcommithashshort</key>
<string>undefined</string>
<key>gitcommitmessage</key>
<string>undefined</string>
2. enable processes info.plist file
buildsettings > processes info.plist file
change to yes
3. add run script
buildphase >
add new run script and paste these lines.
plistbuddy="/usr/libexec/plistbuddy"
infoplistfile="${temp_dir}/preprocessed-info.plist"
branchname=$(git rev-parse --abbrev-ref head)
commitdate=$(git --no-pager log -1 --format="%ai")
commithash=$(git rev-parse --short head)
commithashshort=$(git rev-parse head)
commitmessage=$(git log -1 --pretty=%s)
$plistbuddy -c "set :gitbranchname $branchname" $infoplistfile
$plistbuddy -c "set :gitcommitdate $commitdate" $infoplistfile
$plistbuddy -c "set :gitcommithash $commithash" $infoplistfile
$plistbuddy -c "set :gitcommithashshort $commithashshort" $infoplistfile
$plistbuddy -c "set :gitcommitmessage $commitmessage" $infoplistfile
4. add input files.
${temp_dir}/preprocessed-info.plist
Comments are closed.