| 1 | <?php |
||
| 16 | class ResetCommand extends BaseCommand |
||
| 17 | { |
||
| 18 | public const GIT_RESET_COMMAND = 'reset'; |
||
| 19 | |||
| 20 | public const OPTION_HARD = '--hard'; |
||
| 21 | public const OPTION_MERGE = '--merge'; |
||
| 22 | public const OPTION_SOFT = '--soft'; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * constructor |
||
| 26 | * |
||
| 27 | * @param \GitElephant\Repository $repo The repository object this command |
||
| 28 | * will interact with |
||
| 29 | */ |
||
| 30 | 3 | public function __construct(Repository $repo = null) |
|
| 34 | |||
| 35 | /** |
||
| 36 | * @param TreeishInterface|Commit|string $arg |
||
| 37 | * @param array $options |
||
| 38 | * |
||
| 39 | * @throws \RuntimeException |
||
| 40 | * @return string |
||
| 41 | */ |
||
| 42 | 3 | public function reset($arg = null, array $options = []): string |
|
| 43 | { |
||
| 44 | 3 | $this->clearAll(); |
|
| 45 | 3 | $this->addCommandName(self::GIT_RESET_COMMAND); |
|
| 46 | // if there are options add them. |
||
| 47 | 3 | foreach ($options as $option) { |
|
| 48 | 3 | $this->addCommandArgument($option); |
|
| 49 | } |
||
| 50 | |||
| 51 | 3 | if ($arg != null) { |
|
|
|
|||
| 52 | 3 | $this->addCommandSubject2($arg); |
|
| 53 | } |
||
| 54 | |||
| 55 | 3 | return $this->getCommand(); |
|
| 56 | } |
||
| 57 | |||
| 58 | /** |
||
| 59 | * @param Repository $repository |
||
| 60 | * @return ResetCommand |
||
| 61 | */ |
||
| 62 | 3 | public static function getInstance(Repository $repository = null): \GitElephant\Command\ResetCommand |
|
| 66 | } |
||
| 67 |