initialize method

  1. @override
List<UndoableCommand> initialize()
override

Implementation

@override
List<UndoableCommand> initialize() {
  if (pattern.isEmpty) {
    debugPrintToConsole(message: "Pattern not provided");
    return [ShowErrorCommand("Pattern required")];
  }

  //Read current state
  Repository repository = Repository(Directory.current.path);
  State state = State(repository);
  Branch? currentBranch = state.getCurrentBranch();
  if (currentBranch == null) {
    debugPrintToConsole(message: "Branch not provided");

    return [
      ShowErrorCommand("Unable to get current branch info"),
    ];
  }

  Staging staging = Staging(currentBranch);

  return [
    StageFilesCommand(staging, pattern),
  ];
}