FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
nodegit/lib/merge.js at master · codercatdev/nodegit · GitHub
codercatdev
nodegit
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
nodegit
/
lib
/
merge.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
47 lines (41 loc) · 1.8 KB
Breadcrumbs
nodegit
/
lib
/
merge.js
Copy path
File metadata and controls
47 lines (41 loc) · 1.8 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
var
NodeGit
=
require
(
"../"
)
;
var
normalizeOptions
=
NodeGit
.
Utils
.
normalizeOptions
;
var
Merge
=
NodeGit
.
Merge
;
var
_commits
=
Merge
.
commits
;
var
_merge
=
Merge
.
merge
;
/**
* Merge 2 commits together and create an new index that can
* be used to create a merge commit.
*
*
@param
{
Repository
} repo Repository that contains the given commits
*
@param
{
Commit
} ourCommit The commit that reflects the destination tree
*
@param
{
Commit
} theirCommit The commit to merge into ourCommit
*
@param
{
MergeOptions
} [options] The merge tree options (null for default)
*/
Merge
.
commits
=
function
(
repo
,
ourCommit
,
theirCommit
,
options
)
{
options
=
normalizeOptions
(
options
,
NodeGit
.
MergeOptions
)
;
return
Promise
.
all
(
[
repo
.
getCommit
(
ourCommit
)
,
repo
.
getCommit
(
theirCommit
)
]
)
.
then
(
function
(
commits
)
{
return
_commits
.
call
(
this
,
repo
,
commits
[
0
]
,
commits
[
1
]
,
options
)
;
}
)
;
}
;
/**
* Merge a commit into HEAD and writes the results to the working directory.
*
*
@param
{
Repository
} repo Repository that contains the given commits
*
@param
{
AnnotatedCommit
} theirHead The annotated commit to merge into HEAD
*
@param
{
MergeOptions
} [mergeOpts] The merge tree options (null for default)
*
@param
{
CheckoutOptions
} [checkoutOpts] The checkout options
* (null for default)
*/
Merge
.
merge
=
function
(
repo
,
theirHead
,
mergeOpts
,
checkoutOpts
)
{
mergeOpts
=
normalizeOptions
(
mergeOpts
||
{
}
,
NodeGit
.
MergeOptions
)
;
checkoutOpts
=
normalizeOptions
(
checkoutOpts
||
{
}
,
NodeGit
.
CheckoutOptions
)
;
// Even though git_merge takes an array of annotated_commits, it expects
// exactly one to have been passed in or it will throw an error... ¯\_(ツ)_/¯
var
theirHeads
=
[
theirHead
]
;
return
_merge
.
call
(
this
,
repo
,
theirHeads
,
theirHeads
.
length
,
mergeOpts
,
checkoutOpts
)
;
}
;
Back
|
FazBrowse Home
|
New Git URL