git
git copied to clipboard
Add ahead-behind
Hey! Thanks for a great tool.
Having an ability to get commits ahead\behind would also be great.
Rough implementation would be something like (git_dir.dart
)
static final RegExp _aheadRegExp = RegExp(r'^\*.*[\[| \,].*ahead (.*?)[\]|\,]');
static final RegExp _behindRegExp = RegExp(r'^\*.*[\[| \,].*behind (.*?)[\]|\,]');
Future<List<int>> commitsAheadBehind() async {
final pr = await runCommand(['branch', '-v']);
var output = pr.stdout as String;
var ahead = _aheadRegExp.hasMatch(output)? int.parse(_aheadRegExp.firstMatch(output)?.group(1) ?? "0") : 0;
var behind = _behindRegExp.hasMatch(output)? int.parse(_behindRegExp.firstMatch(output)?.group(1) ?? "0") : 0;
return [ahead, behind];
}