uprava gitAdd

master
David Zálešák 4 years ago
parent 641c58e419
commit fa92f12f78

@ -241,7 +241,7 @@ class Controller {
} }
loading.style.display = "block"; loading.style.display = "block";
this.model.gitAddAll().then( this.model.gitAdd().then(
function (value) { function (value) {
this.model.gitCommit(msg.value).then( this.model.gitCommit(msg.value).then(
function (value) { function (value) {
@ -261,9 +261,7 @@ class Controller {
} }
openPublish() { openPublish() {
this.model this.model.getChangedFiles().then(
.getChangedFiles(this.model.dirTree, this.model.gitDirTreeStat)
.then(
function (v) { function (v) {
this.view.openPublish(v); this.view.openPublish(v);
}.bind(this) }.bind(this)

@ -77,12 +77,18 @@ class Model {
return statList; return statList;
} }
async getChangedFiles(dirTree, statTree) { async getChangedFiles() {
this.chFiles = await this.changedFiles(this.dirTree, this.gitDirTreeStat);
return this.chFiles;
}
async changedFiles(dirTree, statTree) {
var changedFiles = []; var changedFiles = [];
for (let i = 1; i < dirTree.length; i++) { for (let i = 1; i < dirTree.length; i++) {
if (Array.isArray(dirTree[i])) { if (Array.isArray(dirTree[i])) {
var vnorena = await this.getChangedFiles(dirTree[i], statTree[i]); var vnorena = await this.changedFiles(dirTree[i], statTree[i]);
if (vnorena.length != 0) { if (vnorena.length != 0) {
for (let i = 0; i < vnorena.length; i++) { for (let i = 0; i < vnorena.length; i++) {
changedFiles.push(vnorena[i]); changedFiles.push(vnorena[i]);
@ -116,6 +122,8 @@ class Model {
delete window.fs; delete window.fs;
window.fs = new LightningFS("fs", { wipe: true }); window.fs = new LightningFS("fs", { wipe: true });
await this.getDirTree(); await this.getDirTree();
localStorage.setItem("pushError", "false")
} }
async cloneRep() { async cloneRep() {
@ -169,6 +177,32 @@ class Model {
}); });
} }
async gitAdd() {
let filesToAdd = this.chFiles;
for (let i = 0; i < filesToAdd.length; i++) {
console.log(filesToAdd[i])
await git.add({
fs,
dir,
filepath: filesToAdd[i].substring(1),
});
}
/* for (let i = 1; i < dirTree.length; i++) {
if (Array.isArray(dirTree[i])) {
await this.gitAddAll(dirTree[i]);
} else {
await git.add({
fs,
dir,
filepath: dirTree[0].substring(1) + dirTree[i],
});
console.log(dirTree[0].substring(1) + dirTree[i]);
}
} */
}
async gitCommit(msg) { async gitCommit(msg) {
await git.commit({ await git.commit({
fs, fs,