https://github.com/aakira/git_info_plus
Get git information from within the Flutter application
https://github.com/aakira/git_info_plus
Last synced: about 2 months ago
JSON representation
Get git information from within the Flutter application
- Host: GitHub
- URL: https://github.com/aakira/git_info_plus
- Owner: AAkira
- License: apache-2.0
- Created: 2021-11-10T09:41:08.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2024-03-22T05:16:30.000Z (over 1 year ago)
- Last Synced: 2025-04-06T14:37:11.572Z (6 months ago)
- Language: Dart
- Size: 333 KB
- Stars: 7
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# git_info_plus
[](https://pub.dev/packages/git_info_plus)
Get git information from within the Flutter application.
![screenshot-android][screenshot-android] ![screenshot-ios][screenshot-ios]
## Usage
### Dart
```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.
#### Optional
* Read environment valus if git command is null
### 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.
```
GitBranchName
undefined
GitCommitDate
undefined
GitCommitHash
undefined
GitCommitHashShort
undefined
GitCommitMessage
undefined
```![setup-ios-1][setup-ios-1]
#### 2. Enable Processes Info.plist File
`BuildSettings > Processes Info.plist File`
Change to YES![setup-ios-2][setup-ios-2]
#### 3-A. Add Run Script
`BuildPhase >`
Add new Run Script and paste these lines.
```bash
plistBuddy="/usr/libexec/PlistBuddy"
infoPlistFile="${TEMP_DIR}/Preprocessed-Info.plist"branchName=$(git branch --show-current)
commitDate=$(git --no-pager log -1 --format="%ai")
commitHash=$(git rev-parse HEAD)
commitHashShort=$(git rev-parse --short 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
```![setup-ios-3][setup-ios-3]
#### 3-B. Add Input Files.
`${TEMP_DIR}/Preprocessed-Info.plist`
[screenshot-android]: https://raw.githubusercontent.com/AAkira/git_info_plus/master/arts/screenshot-android.png
[screenshot-ios]: https://raw.githubusercontent.com/AAkira/git_info_plus/master/arts/screenshot-ios.png
[setup-ios-1]: https://raw.githubusercontent.com/AAkira/git_info_plus/master/arts/setup-ios-1.jpg
[setup-ios-2]: https://raw.githubusercontent.com/AAkira/git_info_plus/master/arts/setup-ios-2.jpg
[setup-ios-3]: https://raw.githubusercontent.com/AAkira/git_info_plus/master/arts/setup-ios-3.jpg