Commit d832561d authored by Ivanq's avatar Ivanq

Change hooks via removing/adding files, not editing content.json

parent f2f5089b
......@@ -1053,6 +1053,26 @@ class Git {
.catch(() => []);
}
changeHooks(hooks) {
if(hooks) {
return Promise.all([
this.zeroFS.readFile("assets/pre-receive")
.then(preReceive => {
return this.zeroFS.writeFile(this.root + "/hooks/pre-receive", preReceive);
}),
this.zeroFS.readFile("assets/post-receive")
.then(postReceive => {
return this.zeroFS.writeFile(this.root + "/hooks/post-receive", postReceive);
})
]);
} else {
return Promise.all([
this.zeroFS.deleteFile(this.root + "/hooks/pre-receive"),
this.zeroFS.deleteFile(this.root + "/hooks/post-receive")
]);
}
}
toString() {
return "<Git " + this.root + ">";
}
......@@ -1095,17 +1115,5 @@ Git.init = (root, zeroPage, name, email) => {
.then(id => {
return git.setRef("refs/heads/master", id);
})
.then(() => {
return zeroFS.readFile("assets/post-receive");
})
.then(postReceive => {
return zeroFS.writeFile(root + "/hooks/post-receive", postReceive);
})
.then(() => {
return zeroFS.readFile("assets/pre-receive");
})
.then(preReceive => {
return zeroFS.writeFile(root + "/hooks/pre-receive", preReceive);
})
.then(() => git);
};
\ No newline at end of file
......@@ -420,6 +420,9 @@ class Repository {
content.hooks = hooks;
return this.setContent(content);
})
.then(() => {
return this.git.changeHooks(hooks);
})
.then(() => this.sign());
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment