This repository has been archived by the owner on Jan 31, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
merge.ts
56 lines (44 loc) · 1.2 KB
/
merge.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import {Command, flags} from '@oclif/command'
import {
askForBranch,
askForVersion,
getSvnBranchTypeFromString,
versionRequired
} from '../command-utils'
import {branchFlag, quietFlag, versionFlag} from '../flags'
import {mergeFromVersion, SvnVersion} from '../svn'
export default class Merge extends Command {
static description = 'merge from another version'
static aliases = ['m']
static flags = {
branch: branchFlag,
version: versionFlag,
quiet: quietFlag,
help: flags.help({char: 'h'})
}
static args = [{name: 'path', default: '.'}]
static examples = [
'$ svn-helper merge -b trunk',
'$ svn-helper merge -b branches -v 1.2.3'
]
async run() {
const {args, flags} = this.parse(Merge)
const path = args.path
let branch = flags.branch
let version = flags.version
if (!branch) {
branch = await askForBranch()
}
const branchType = getSvnBranchTypeFromString(branch)
if (versionRequired(branchType) && !version) {
version = await askForVersion(path, branchType)
}
const output = await mergeFromVersion(
path,
new SvnVersion(branchType, version)
)
if (!flags.quiet) {
this.log(output)
}
}
}