jvcs 1.1.3 → 1.1.5
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/controllers/revert.js +19 -15
- package/package.json +1 -1
package/controllers/revert.js
CHANGED
|
@@ -39,25 +39,29 @@ function cleanCWD() {
|
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
function
|
|
43
|
-
|
|
44
|
-
let toDelete = []
|
|
45
|
-
|
|
46
|
-
while(currentCommit && currentCommit !== targetCommit) {
|
|
42
|
+
function buildCommitMap(commitFolder) {
|
|
47
43
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
toDelete.push(currentCommit)
|
|
53
|
-
|
|
54
|
-
let parent = null
|
|
44
|
+
const map = {}
|
|
45
|
+
const dirs = fs.readdirSync(commitFolder)
|
|
46
|
+
for(const dir of dirs) {
|
|
47
|
+
const metaPath = path.join(commitFolder,dir,"meta.json")
|
|
55
48
|
if(fs.existsSync(metaPath)) {
|
|
56
49
|
const data = JSON.parse(fs.readFileSync(metaPath,"utf-8"))
|
|
57
|
-
|
|
50
|
+
map[dir] = data.parent
|
|
58
51
|
}
|
|
52
|
+
}
|
|
59
53
|
|
|
60
|
-
|
|
54
|
+
return map
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function getCommitsToDelete(commitFolder,currentCommit,targetCommit) {
|
|
58
|
+
|
|
59
|
+
const commitMap = buildCommitMap(commitFolder)
|
|
60
|
+
const toDelete = []
|
|
61
|
+
|
|
62
|
+
while(currentCommit && currentCommit !== targetCommit) {
|
|
63
|
+
toDelete.push(currentCommit)
|
|
64
|
+
currentCommit = commitMap[currentCommit] || null
|
|
61
65
|
}
|
|
62
66
|
|
|
63
67
|
return toDelete
|
|
@@ -87,7 +91,7 @@ async function deleteCommitsFromDrive(ids) {
|
|
|
87
91
|
folderName = `commit_${id}`
|
|
88
92
|
|
|
89
93
|
const res = await drive.files.list({
|
|
90
|
-
q: `name
|
|
94
|
+
q: `name='${folderName}' and trashed=false`,
|
|
91
95
|
fields: "files(id,name)"
|
|
92
96
|
})
|
|
93
97
|
|