Skip to content

Add ahead-behind #28

Description

@Jamminroot

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];
  }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions