FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
nodegit/test/convenience-commit.js at v0.0.76 · nodegit/nodegit · GitHub
nodegit
nodegit
Repository navigation
Code
Issues
344
(344)
Pull requests
21
(21)
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
nodegit
/
test
/
convenience-commit.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
172 lines (150 loc) · 4.96 KB
Breadcrumbs
nodegit
/
test
/
convenience-commit.js
Copy path
File metadata and controls
172 lines (150 loc) · 4.96 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
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
var
git
=
require
(
'../'
)
;
var
rimraf
=
require
(
'rimraf'
)
;
var
fs
=
require
(
'fs'
)
;
// Helper functions
var
helper
=
{
// Test if obj is a true function
testFunction
:
function
(
test
,
obj
,
label
)
{
// The object reports itself as a function
test
(
typeof
obj
,
'function'
,
label
+
' reports as a function.'
)
;
// This ensures the repo is actually a derivative of the Function [[Class]]
test
(
toString
.
call
(
obj
)
,
'[object Function]'
,
label
+
' [[Class]] is of type function.'
)
;
}
,
// Test code and handle exception thrown
testException
:
function
(
test
,
fun
,
label
)
{
try
{
fun
(
)
;
test
(
false
,
label
)
;
}
catch
(
ex
)
{
test
(
true
,
label
)
;
}
}
}
;
/**
* Test that the commit object is present.
*/
exports
.
method
=
function
(
test
)
{
test
.
expect
(
2
)
;
helper
.
testFunction
(
test
.
equals
,
git
.
commit
,
'Commmit'
)
;
test
.
done
(
)
;
}
;
/**
* Test that improper commit ID's result in an error message
*/
exports
.
improperCommitId
=
function
(
test
)
{
test
.
expect
(
1
)
;
git
.
repo
(
'../.git'
,
function
(
error
,
repository
)
{
repository
.
commit
(
'not a proper commit sha'
,
function
(
error
,
commit
)
{
test
.
notEqual
(
error
,
null
,
'Error should occur'
)
;
test
.
done
(
)
;
}
)
;
}
)
;
}
;
var
historyCountKnownSHA
=
'fce88902e66c72b5b93e75bdb5ae717038b221f6'
;
/**
* Test that retreiving walking a given commit's history works as expected.
*
*
@param
{
Object
} test
*/
exports
.
history
=
function
(
test
)
{
test
.
expect
(
368
)
;
git
.
repo
(
'../.git'
,
function
(
error
,
repository
)
{
repository
.
commit
(
historyCountKnownSHA
,
function
(
error
,
commit
)
{
test
.
equals
(
null
,
error
,
'Getting latest branch commit should not error'
)
;
var
historyCount
=
0
;
var
expectedHistoryCount
=
364
;
commit
.
history
(
)
.
on
(
'commit'
,
function
(
error
,
commit
)
{
test
.
equals
(
null
,
error
,
'There should be no errors'
)
;
historyCount
++
;
}
)
.
on
(
'end'
,
function
(
error
,
commits
)
{
test
.
equals
(
null
,
error
,
'There should be no errors'
)
;
test
.
equals
(
historyCount
,
expectedHistoryCount
,
'Manual count does not match expected'
)
;
test
.
equals
(
commits
.
length
,
expectedHistoryCount
,
'"end" count does not match expected'
)
;
test
.
done
(
)
;
}
)
;
}
)
;
}
)
;
}
;
/**
* Test that retreiving master branch's HEAD commit works as expected.
*/
exports
.
masterHead
=
function
(
test
)
{
test
.
expect
(
2
)
;
git
.
repo
(
'../.git'
,
function
(
error
,
repository
)
{
repository
.
branch
(
'master'
,
function
(
error
,
branch
)
{
test
.
equals
(
error
,
null
,
'Getting branch should not error'
)
;
repository
.
commit
(
branch
.
sha
,
function
(
error
,
commit
)
{
test
.
equals
(
error
,
null
,
'Getting latest branch commit should not error'
)
;
test
.
done
(
)
;
}
)
;
}
)
;
}
)
;
}
;
/**
* Test that retreiving parent works as expected.
*
*
@param
{
Object
} test
*/
exports
.
parentSync
=
function
(
test
)
{
test
.
expect
(
2
)
;
git
.
repo
(
'../.git'
,
function
(
error
,
repository
)
{
repository
.
commit
(
'2d71044741412280370cb0326c96d3a5a7b5dca1'
,
function
(
error
,
commit
)
{
test
.
equals
(
commit
.
parentCount
,
1
,
'Commit has exactly one parent'
)
;
var
parent
=
commit
.
parentSync
(
0
)
;
test
.
equals
(
parent
.
sha
,
'e8876707938abf94d5cc02b0c4017c4fec2aa44e'
,
'Parent SHA should match expected value'
)
;
test
.
done
(
)
;
}
)
;
}
)
;
}
;
/**
* Test that retreiving parent works as expected.
*
*
@param
{
Object
} test
*/
exports
.
parent
=
function
(
test
)
{
test
.
expect
(
2
)
;
git
.
repo
(
'../.git'
,
function
(
error
,
repository
)
{
repository
.
commit
(
'2d71044741412280370cb0326c96d3a5a7b5dca1'
,
function
(
error
,
commit
)
{
test
.
equals
(
commit
.
parentCount
,
1
,
'Commit has exactly one parent'
)
;
commit
.
parent
(
0
,
function
(
error
,
parent
)
{
if
(
error
)
throw
error
;
test
.
equals
(
parent
.
sha
,
'e8876707938abf94d5cc02b0c4017c4fec2aa44e'
,
'Parent SHA should match expected value'
)
;
test
.
done
(
)
;
}
)
;
}
)
;
}
)
;
}
;
/**
* Test that retrieving and walking a commit's tree works as expected.
*/
exports
.
tree
=
function
(
test
)
{
test
.
expect
(
2
)
;
git
.
repo
(
'../.git'
,
function
(
error
,
repository
)
{
repository
.
commit
(
historyCountKnownSHA
,
function
(
error
,
commit
)
{
test
.
equals
(
error
,
null
,
'Getting latest branch commit should not error'
)
;
var
commitTreeEntryCount
=
0
;
var
expectedCommitTreeEntryCount
=
200
;
commit
.
tree
(
)
.
walk
(
)
.
on
(
'entry'
,
function
(
commit
)
{
commitTreeEntryCount
++
;
}
)
.
on
(
'end'
,
function
(
commits
)
{
test
.
equals
(
commitTreeEntryCount
,
expectedCommitTreeEntryCount
,
'Commit tree entry count does not match expected'
)
;
test
.
done
(
)
;
}
)
;
}
)
;
}
)
;
}
;
/**
* Test that parentsDiffTrees works as expected.
*/
exports
.
parentsDiffTrees
=
function
(
test
)
{
test
.
expect
(
1
)
;
git
.
repo
(
'../.git'
,
function
(
error
,
repository
)
{
repository
.
commit
(
historyCountKnownSHA
,
function
(
error
,
commit
)
{
commit
.
parentsDiffTrees
(
function
(
error
,
parentsDiffTrees
)
{
test
.
equals
(
parentsDiffTrees
.
length
,
1
,
'Should be one item in parents diff trees'
)
;
test
.
done
(
)
;
}
)
;
}
)
;
}
)
;
}
;
Back
|
FazBrowse Home
|
New Git URL