branchLocalOrRemote method

Stream<String> branchLocalOrRemote(
  1. String branchName
)

returns a Stream of branchNames with prepended remotes where branchName exists

git branch --all --list "*$rev"

Implementation

Stream<String> branchLocalOrRemote(String branchName) async* {
  final String? text = await _git("branch --all --list *$branchName", emptyResultIsError: false);
  if (text == null || text.isEmpty) {
    return;
  }
  final branches = text
      .split('\n')
      // remove asterisk marking the current branch
      .map((it) => it.replaceFirst("* ", ""))
      .map((it) => it.trim());

  for (final branch in branches) {
    yield branch;
  }
}