| 1 | /** |
| 2 | * Copyright (c) Meta Platforms, Inc. and affiliates. |
| 3 | * |
| 4 | * This source code is licensed under the MIT license found in the |
| 5 | * LICENSE file in the root directory of this source tree. |
| 6 | */ |
| 7 | |
| 8 | import type {ExactRevset, OptimisticRevset, SucceedableRevset} from '../types'; |
| 9 | |
| 10 | import {Operation} from './Operation'; |
| 11 | |
| 12 | export class PushOperation extends Operation { |
| 13 | static opName = 'Push'; |
| 14 | |
| 15 | constructor( |
| 16 | private topOfStackRev: SucceedableRevset | ExactRevset | OptimisticRevset, |
| 17 | private toBranchName: string, |
| 18 | private destination?: string, |
| 19 | ) { |
| 20 | super('PushOperation'); |
| 21 | } |
| 22 | |
| 23 | getArgs() { |
| 24 | const args = ['push', '--rev', this.topOfStackRev, '--to', this.toBranchName]; |
| 25 | if (this.destination) { |
| 26 | args.push(this.destination); |
| 27 | } |
| 28 | return args; |
| 29 | } |
| 30 | } |
| 31 | |