forked from nodegit/nodegit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrebase.js
More file actions
78 lines (68 loc) · 2.45 KB
/
Copy pathrebase.js
File metadata and controls
78 lines (68 loc) · 2.45 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
var NodeGit = require("../");
var Rebase = NodeGit.Rebase;
var normalizeOptions = NodeGit.Utils.normalizeOptions;
var shallowClone = require("./utils/shallow_clone");
/**
* Initializes a rebase
* @async
* @param {Repository} repo The repository to perform the rebase
* @param {AnnotatedCommit} branch The terminal commit to rebase, or NULL to
* rebase the current branch
* @param {AnnotatedCommit} upstream The commit to begin rebasing from, or NULL
* to rebase all reachable commits
* @param {AnnotatedCommit} onto The branch to rebase onto, or NULL to rebase
* onto the given upstream
* @param {RebaseOptions} options Options to specify how rebase is performed,
* or NULL
* @param {Function} callback
* @return {Remote}
*/
var init = Rebase.init;
Rebase.init = function(repository, branch, upstream, onto, options) {
var checkoutOptions;
if (options) {
options = shallowClone(options);
checkoutOptions = options.checkoutOptions;
delete options.checkoutOptions;
options = normalizeOptions(options, NodeGit.RebaseOptions);
} else {
options = normalizeOptions({}, NodeGit.RebaseOptions);
checkoutOptions = {
checkoutStrategy: NodeGit.Checkout.STRATEGY.FORCE
};
}
if (checkoutOptions) {
options.checkoutOptions =
normalizeOptions(checkoutOptions, NodeGit.CheckoutOptions);
}
return init(repository, branch, upstream, onto, options);
};
/**
* Opens an existing rebase that was previously started by either an invocation
* of Rebase.open or by another client.
* @async
* @param {Repository} repo The repository that has a rebase in-progress
* @param {RebaseOptions} options Options to specify how rebase is performed
* @param {Function} callback
* @return {Remote}
*/
var rebaseOpen = Rebase.open;
Rebase.open = function(repository, options) {
var checkoutOptions;
if (options) {
options = shallowClone(options);
checkoutOptions = options.checkoutOptions;
delete options.checkoutOptions;
options = normalizeOptions(options, NodeGit.RebaseOptions);
} else {
options = normalizeOptions({}, NodeGit.RebaseOptions);
checkoutOptions = {
checkoutStrategy: NodeGit.Checkout.STRATEGY.SAFE
};
}
if (checkoutOptions) {
options.checkoutOptions =
normalizeOptions(checkoutOptions, NodeGit.CheckoutOptions);
}
return rebaseOpen(repository, options);
};