Commit 479fc0af authored by Ivanq's avatar Ivanq

Merge branch 'master' into hg

parents 0d793f3b 9eb90537
......@@ -14,14 +14,6 @@ fi
################################################################################
cat "$GIT_DIR/../content.json" | "$python_path" -c "import sys, json; content = json.load(sys.stdin); sys.exit(1 if content.get('hooks', False) else 0)"
if [ $? -eq 0 ]; then
# Hooks disabled
exit 0
fi
################################################################################
sign=1
publish=1
......
......@@ -13,12 +13,6 @@ fi
################################################################################
cat "$GIT_DIR/../content.json" | "$python_path" -c "import sys, json; content = json.load(sys.stdin); sys.exit(1 if content.get('hooks', False) else 0)"
if [ $? -eq 0 ]; then
# Hooks disabled
exit 0
fi
if test -n "$GIT_PUSH_OPTION_COUNT"
then
i=0
......
......@@ -977,6 +977,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 + ">";
}
......@@ -1019,17 +1039,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
......@@ -424,7 +424,8 @@ class Repository {
// Adds or removes hooks from repository
changeHooks(hooks) {
return this.getContent()
return this.git.changeHooks(hooks)
.then(() => this.getContent())
.then(content => {
content.hooks = hooks;
return this.setContent(content);
......
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