headBranchName property
branch name of HEAD
or null
Implementation
Future<String?> get headBranchName async {
final name = await _git('symbolic-ref --short -q HEAD', emptyResultIsError: false);
if (name == null) return null;
// empty branch names can't exits this means no branch name
if (name.isEmpty) return null;
assert(
() {
if (name.split('\n').length != 1) throw ArgumentError("branch name is multiline '$name'");
return true;
}(),
);
return name;
}