createBranch method

Future<GitHash?> createBranch(
  1. String name, {
  2. GitHash? hash,
  3. bool overwrite = false,
})

Implementation

Future<GitHash?> createBranch(
  String name, {
  GitHash? hash,
  bool overwrite = false,
}) async {
  hash ??= await headHash();
  if (hash == null) {
    return null;
  }

  var branch = ReferenceName.branch(name);
  var ref = await refStorage.reference(branch);
  if (!overwrite && ref != null) {
    return null;
  }

  await refStorage.saveRef(Reference.hash(branch, hash));
  return hash;
}