git-er-done 0.1.19 → 0.1.20
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
CHANGED
|
@@ -9,6 +9,10 @@ module.exports.diffToGitJSONDSL = (diff, commits) => {
|
|
|
9
9
|
const fileDiffs = parseDiff(diff)
|
|
10
10
|
const addedDiffs = fileDiffs.filter(diff => diff['new'])
|
|
11
11
|
const removedDiffs = fileDiffs.filter(diff => diff['deleted'])
|
|
12
|
+
// Renames have both from and to, but no new/deleted flag, and paths differ
|
|
13
|
+
const renamedDiffs = fileDiffs.filter(
|
|
14
|
+
diff => diff.from && diff.to && !diff['new'] && !diff['deleted'] && diff.from !== diff.to
|
|
15
|
+
)
|
|
12
16
|
const modifiedDiffs = fileDiffs.filter(
|
|
13
17
|
diff => !includes(addedDiffs, diff) && !includes(removedDiffs, diff)
|
|
14
18
|
)
|
|
@@ -19,6 +23,8 @@ module.exports.diffToGitJSONDSL = (diff, commits) => {
|
|
|
19
23
|
),
|
|
20
24
|
created_files: addedDiffs.map(d => d.to),
|
|
21
25
|
deleted_files: removedDiffs.map(d => d.from),
|
|
26
|
+
// Renamed files with old and new paths
|
|
27
|
+
renamed_files: renamedDiffs.map(d => ({ from: d.from, to: d.to })),
|
|
22
28
|
commits: commits
|
|
23
29
|
}
|
|
24
30
|
}
|
|
@@ -223,6 +223,7 @@ module.exports.gitJSONToGitDSL = (gitJSONRep, config) => {
|
|
|
223
223
|
modifiedFiles: gitJSONRep.modified_files,
|
|
224
224
|
createdFiles: gitJSONRep.created_files,
|
|
225
225
|
deletedFiles: gitJSONRep.deleted_files,
|
|
226
|
+
renamedFiles: gitJSONRep.renamed_files || [],
|
|
226
227
|
commits: gitJSONRep.commits,
|
|
227
228
|
lastCommit: gitJSONRep.commits && gitJSONRep.commits[0] && gitJSONRep.commits[0].sha,
|
|
228
229
|
dir: config.repo,
|
package/src/types.js
CHANGED
|
@@ -35,12 +35,19 @@
|
|
|
35
35
|
* @property {function(): Object<string, string[]>} getKeyedPaths - Returns an object with keys (modified, created, deleted, edited) mapped to their matching file arrays
|
|
36
36
|
*/
|
|
37
37
|
|
|
38
|
+
/**
|
|
39
|
+
* @typedef {Object} RenamedFile
|
|
40
|
+
* @property {string} from - Original file path before rename
|
|
41
|
+
* @property {string} to - New file path after rename
|
|
42
|
+
*/
|
|
43
|
+
|
|
38
44
|
/**
|
|
39
45
|
* @typedef {Object} GitDetails
|
|
40
46
|
* @property {function(...(string|string[])): FileMatchResult} fileMatch - Function to match files by glob pattern(s). Accepts multiple strings, arrays of strings, or a mix using rest parameters. Supports negation patterns with '!' prefix
|
|
41
47
|
* @property {string[]} modifiedFiles - Array of modified file paths
|
|
42
48
|
* @property {string[]} createdFiles - Array of created file paths
|
|
43
49
|
* @property {string[]} deletedFiles - Array of deleted file paths
|
|
50
|
+
* @property {RenamedFile[]} renamedFiles - Array of renamed files with from/to paths
|
|
44
51
|
* @property {CommitInfo[]} commits - Array of commits between base and head
|
|
45
52
|
* @property {string} lastCommit - SHA of the last commit
|
|
46
53
|
* @property {string} dir - Root path of the git repository
|
package/types/types.d.ts
CHANGED
|
@@ -92,6 +92,16 @@ export type FileMatchResult = {
|
|
|
92
92
|
[x: string]: string[];
|
|
93
93
|
};
|
|
94
94
|
};
|
|
95
|
+
export type RenamedFile = {
|
|
96
|
+
/**
|
|
97
|
+
* - Original file path before rename
|
|
98
|
+
*/
|
|
99
|
+
from: string;
|
|
100
|
+
/**
|
|
101
|
+
* - New file path after rename
|
|
102
|
+
*/
|
|
103
|
+
to: string;
|
|
104
|
+
};
|
|
95
105
|
export type GitDetails = {
|
|
96
106
|
/**
|
|
97
107
|
* - Function to match files by glob pattern(s). Accepts multiple strings, arrays of strings, or a mix using rest parameters. Supports negation patterns with '!' prefix
|
|
@@ -109,6 +119,10 @@ export type GitDetails = {
|
|
|
109
119
|
* - Array of deleted file paths
|
|
110
120
|
*/
|
|
111
121
|
deletedFiles: string[];
|
|
122
|
+
/**
|
|
123
|
+
* - Array of renamed files with from/to paths
|
|
124
|
+
*/
|
|
125
|
+
renamedFiles: RenamedFile[];
|
|
112
126
|
/**
|
|
113
127
|
* - Array of commits between base and head
|
|
114
128
|
*/
|