@netlify/git-utils 1.0.11 → 3.0.0
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/package.json +4 -4
- package/src/commits.js +24 -8
- package/src/exec.js +9 -2
- package/CHANGELOG.md +0 -36
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netlify/git-utils",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "Utility for dealing with modified, created, deleted files since a git commit",
|
|
5
5
|
"main": "src/main.js",
|
|
6
6
|
"files": [
|
|
@@ -43,16 +43,16 @@
|
|
|
43
43
|
},
|
|
44
44
|
"license": "MIT",
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"execa": "^
|
|
46
|
+
"execa": "^5.1.1",
|
|
47
47
|
"map-obj": "^4.0.0",
|
|
48
48
|
"micromatch": "^4.0.2",
|
|
49
49
|
"moize": "^6.0.0",
|
|
50
50
|
"path-exists": "^4.0.0"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"ava": "^
|
|
53
|
+
"ava": "^3.15.0"
|
|
54
54
|
},
|
|
55
55
|
"engines": {
|
|
56
|
-
"node": ">=
|
|
56
|
+
"node": "^12.20.0 || ^14.14.0 || >=16.0.0"
|
|
57
57
|
}
|
|
58
58
|
}
|
package/src/commits.js
CHANGED
|
@@ -5,17 +5,33 @@ const { git } = require('./exec')
|
|
|
5
5
|
// Return information on each commit since the `base` commit, such as SHA,
|
|
6
6
|
// parent commits, author, committer and commit message
|
|
7
7
|
const getCommits = function (base, head, cwd) {
|
|
8
|
-
const stdout = git(['log', `--pretty
|
|
9
|
-
const commits =
|
|
8
|
+
const stdout = git(['log', `--pretty=${GIT_PRETTY_FORMAT}`, `${base}...${head}`], cwd)
|
|
9
|
+
const commits = stdout.split('\n').map(getCommit)
|
|
10
10
|
return commits
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
parents
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
// Parse the commit output from a string to a JavaScript object
|
|
14
|
+
const getCommit = function (line) {
|
|
15
|
+
const [sha, parents, authorName, authorEmail, authorDate, committerName, committerEmail, committerDate, message] =
|
|
16
|
+
line.split(GIT_PRETTY_SEPARATOR)
|
|
17
|
+
return {
|
|
18
|
+
sha,
|
|
19
|
+
parents,
|
|
20
|
+
author: { name: authorName, email: authorEmail, date: authorDate },
|
|
21
|
+
committer: { name: committerName, email: committerEmail, date: committerDate },
|
|
22
|
+
message,
|
|
23
|
+
}
|
|
19
24
|
}
|
|
20
25
|
|
|
26
|
+
// `git log --pretty` does not have any way of separating tokens, except for
|
|
27
|
+
// commits being separated by newlines. Since some tokens (like the commit
|
|
28
|
+
// message or the committer name) might contain a wide range of characters, we
|
|
29
|
+
// need a specific separator.
|
|
30
|
+
// We choose RS (Record separator) which is a rarely used control character
|
|
31
|
+
// intended for this very purpose: separating records. It is used by some
|
|
32
|
+
// formats such as JSON text sequences (RFC 7464).
|
|
33
|
+
const GIT_PRETTY_SEPARATOR = '\u001E'
|
|
34
|
+
// List of commit fields we want to retrieve
|
|
35
|
+
const GIT_PRETTY_FORMAT = ['%H', '%p', '%an', '%ae', '%ai', '%cn', '%ce', '%ci', '%f'].join(GIT_PRETTY_SEPARATOR)
|
|
36
|
+
|
|
21
37
|
module.exports = { getCommits }
|
package/src/exec.js
CHANGED
|
@@ -9,8 +9,15 @@ const pathExists = require('path-exists')
|
|
|
9
9
|
// Fires the `git` binary. Memoized.
|
|
10
10
|
const mGit = function (args, cwd) {
|
|
11
11
|
const cwdA = safeGetCwd(cwd)
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
try {
|
|
13
|
+
const { stdout } = execa.sync('git', args, { cwd: cwdA })
|
|
14
|
+
return stdout
|
|
15
|
+
} catch (error) {
|
|
16
|
+
// The child process `error.message` includes stderr and stdout output which most of the times contains duplicate
|
|
17
|
+
// information. We rely on `error.shortMessage` instead.
|
|
18
|
+
error.message = error.shortMessage
|
|
19
|
+
throw error
|
|
20
|
+
}
|
|
14
21
|
}
|
|
15
22
|
|
|
16
23
|
// eslint-disable-next-line no-magic-numbers
|
package/CHANGELOG.md
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
### [1.0.11](https://www.github.com/netlify/build/compare/git-utils-v1.0.10...git-utils-v1.0.11) (2021-05-03)
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
### Bug Fixes
|
|
7
|
-
|
|
8
|
-
* **deps:** update dependency map-obj to v4 ([#2721](https://www.github.com/netlify/build/issues/2721)) ([17559dc](https://www.github.com/netlify/build/commit/17559dcc75dd9f9a73f2a604c9f8ef3140a91b42))
|
|
9
|
-
|
|
10
|
-
### [1.0.10](https://www.github.com/netlify/build/compare/git-utils-v1.0.9...git-utils-v1.0.10) (2021-04-26)
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
### Bug Fixes
|
|
14
|
-
|
|
15
|
-
* **deps:** update dependency map-obj to v3.1.0 ([#2656](https://www.github.com/netlify/build/issues/2656)) ([89e497a](https://www.github.com/netlify/build/commit/89e497a37a892f203a601a510e0e24ae037ad146))
|
|
16
|
-
|
|
17
|
-
### [1.0.9](https://www.github.com/netlify/build/compare/git-utils-v1.0.8...git-utils-v1.0.9) (2021-04-23)
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
### Bug Fixes
|
|
21
|
-
|
|
22
|
-
* fix `utils.git` for repositories with `main` branch ([#2638](https://www.github.com/netlify/build/issues/2638)) ([5f80961](https://www.github.com/netlify/build/commit/5f80961e25387deee9b37bba07379adc1fed44c3))
|
|
23
|
-
|
|
24
|
-
### [1.0.8](https://www.github.com/netlify/build/compare/v1.0.7...v1.0.8) (2021-02-18)
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
### Bug Fixes
|
|
28
|
-
|
|
29
|
-
* fix `files` in `package.json` with `npm@7` ([#2278](https://www.github.com/netlify/build/issues/2278)) ([e9df064](https://www.github.com/netlify/build/commit/e9df0645f3083a0bb141c8b5b6e474ed4e27dbe9))
|
|
30
|
-
|
|
31
|
-
### [1.0.7](https://www.github.com/netlify/build/compare/git-utils-v1.0.6...v1.0.7) (2021-02-01)
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
### Bug Fixes
|
|
35
|
-
|
|
36
|
-
* **deps:** update dependency moize to v6 ([#2231](https://www.github.com/netlify/build/issues/2231)) ([e34454c](https://www.github.com/netlify/build/commit/e34454c633bbc541c4074bdaa15361c84f0c8f04))
|