getCurrentBranch static method

Future<String> getCurrentBranch(
  1. String pathRep
)

获取当前分支

pathRep 仓库

Implementation

static Future<String> getCurrentBranch(String pathRep) async {
  const cmdBranch = 'git rev-parse --abbrev-ref HEAD';
  final res = await ProcessUtil.runCmdWait(
    cmd: cmdBranch,
    workingDirectory: pathRep,
  );
  if (res.stdout is String) {
    Logger.log('stdout: ${res.stdout}');
    return formatStrFromCli(res.stdout as String);
  } else {
    throw Exception('Run command failed');
  }
}