@apexdevtools/git-ops 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/README.md +1 -1
- package/lib/src/Git/Git.js +4 -1
- package/lib/test/Git/Git.spec.js +37 -12
- package/package.json +1 -2
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ Library to do git operations to find changed files in a given git repository.
|
|
|
4
4
|
|
|
5
5
|
## Prerequisite
|
|
6
6
|
|
|
7
|
-
Minimum `git` version of `2.
|
|
7
|
+
Minimum `git` version of `2.20.0` must already be installed on the host machine.
|
|
8
8
|
|
|
9
9
|
## Getting Started
|
|
10
10
|
|
package/lib/src/Git/Git.js
CHANGED
|
@@ -38,6 +38,9 @@ class Git {
|
|
|
38
38
|
const isSupported = version.major >= this.MIN_GIT_VERSION_MAJOR &&
|
|
39
39
|
version.minor >= this.MIN_GIT_VERSION_MINOR &&
|
|
40
40
|
version.patch >= this.MIN_GIT_VERSION_PATCH;
|
|
41
|
+
if (!version.installed) {
|
|
42
|
+
throw new Error('"git" is not installed or available on the PATH');
|
|
43
|
+
}
|
|
41
44
|
if (!isSupported)
|
|
42
45
|
throw new Error(`Unsupported version of git. Min version must be ${this.MIN_GIT_VERSION_MAJOR}.${this.MIN_GIT_VERSION_MINOR}.${this.MIN_GIT_VERSION_PATCH}`);
|
|
43
46
|
});
|
|
@@ -105,5 +108,5 @@ class Git {
|
|
|
105
108
|
}
|
|
106
109
|
exports.Git = Git;
|
|
107
110
|
Git.MIN_GIT_VERSION_MAJOR = 2;
|
|
108
|
-
Git.MIN_GIT_VERSION_MINOR =
|
|
111
|
+
Git.MIN_GIT_VERSION_MINOR = 20;
|
|
109
112
|
Git.MIN_GIT_VERSION_PATCH = 0;
|
package/lib/test/Git/Git.spec.js
CHANGED
|
@@ -28,37 +28,62 @@ describe('Git', () => {
|
|
|
28
28
|
yield repoManager.tearDown();
|
|
29
29
|
}));
|
|
30
30
|
describe('version check', () => {
|
|
31
|
-
it('does not fail when Git version is equal to 2.
|
|
31
|
+
it('does not fail when Git version is equal to 2.20.0', () => {
|
|
32
32
|
//Given/When
|
|
33
33
|
const mock = {
|
|
34
|
-
version: jest.fn().mockReturnValue({
|
|
34
|
+
version: jest.fn().mockReturnValue({
|
|
35
|
+
installed: true,
|
|
36
|
+
major: 2,
|
|
37
|
+
minor: 20,
|
|
38
|
+
patch: 0,
|
|
39
|
+
}),
|
|
35
40
|
};
|
|
36
41
|
expect(Git_1.Git.versionCheck(mock)).resolves;
|
|
37
42
|
});
|
|
38
|
-
it('
|
|
43
|
+
it('does not fail when Git version is higher', () => {
|
|
44
|
+
//Given/When
|
|
45
|
+
const mock = {
|
|
46
|
+
version: jest.fn().mockReturnValue({
|
|
47
|
+
installed: true,
|
|
48
|
+
major: 2,
|
|
49
|
+
minor: 30,
|
|
50
|
+
patch: 2,
|
|
51
|
+
}),
|
|
52
|
+
};
|
|
53
|
+
//Then
|
|
54
|
+
expect(Git_1.Git.versionCheck(mock)).resolves;
|
|
55
|
+
});
|
|
56
|
+
it('fails when Git is not installed', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
39
57
|
//Given/When
|
|
40
58
|
const mock = {
|
|
41
|
-
version: jest.fn().mockReturnValue({
|
|
59
|
+
version: jest.fn().mockReturnValue({ installed: false }),
|
|
42
60
|
};
|
|
43
61
|
//Then
|
|
44
|
-
yield expect(Git_1.Git.versionCheck(mock)).rejects.toThrow(Error('
|
|
62
|
+
yield expect(Git_1.Git.versionCheck(mock)).rejects.toThrow(Error('"git" is not installed or available on the PATH'));
|
|
45
63
|
}));
|
|
46
|
-
it('fails when Git
|
|
64
|
+
it('fails when Git major version is lower', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
47
65
|
//Given/When
|
|
48
66
|
const mock = {
|
|
49
|
-
version: jest.fn().mockReturnValue({
|
|
67
|
+
version: jest.fn().mockReturnValue({
|
|
68
|
+
installed: true,
|
|
69
|
+
major: 1,
|
|
70
|
+
}),
|
|
50
71
|
};
|
|
51
72
|
//Then
|
|
52
|
-
yield expect(Git_1.Git.versionCheck(mock)).rejects.toThrow(Error('Unsupported version of git. Min version must be 2.
|
|
73
|
+
yield expect(Git_1.Git.versionCheck(mock)).rejects.toThrow(Error('Unsupported version of git. Min version must be 2.20.0'));
|
|
53
74
|
}));
|
|
54
|
-
it('fails when Git
|
|
75
|
+
it('fails when Git minor version is lower', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
55
76
|
//Given/When
|
|
56
77
|
const mock = {
|
|
57
|
-
version: jest.fn().mockReturnValue({
|
|
78
|
+
version: jest.fn().mockReturnValue({
|
|
79
|
+
installed: true,
|
|
80
|
+
major: 2,
|
|
81
|
+
minor: 19,
|
|
82
|
+
}),
|
|
58
83
|
};
|
|
59
84
|
//Then
|
|
60
|
-
expect(Git_1.Git.versionCheck(mock)).
|
|
61
|
-
});
|
|
85
|
+
yield expect(Git_1.Git.versionCheck(mock)).rejects.toThrow(Error('Unsupported version of git. Min version must be 2.20.0'));
|
|
86
|
+
}));
|
|
62
87
|
});
|
|
63
88
|
describe('rev parse', () => {
|
|
64
89
|
it('get git root', () => __awaiter(void 0, void 0, void 0, function* () {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apexdevtools/git-ops",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "Library to do git operations to find changed files in a given git repository",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Apex Dev Tools Team",
|
|
@@ -50,7 +50,6 @@
|
|
|
50
50
|
"typescript": "^4.9.5"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"install": "^0.13.0",
|
|
54
53
|
"simple-git": "^3.16.0"
|
|
55
54
|
},
|
|
56
55
|
"config": {
|