Skip to content

Commit 9eb9053

Browse files
committed
Merge branch 'hooks'
2 parents f2f5089 + 9440844 commit 9eb9053

File tree

4 files changed

+22
-27
lines changed

4 files changed

+22
-27
lines changed

src/assets/post-receive

-8
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,6 @@ fi
1414

1515
################################################################################
1616

17-
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)"
18-
if [ $? -eq 0 ]; then
19-
# Hooks disabled
20-
exit 0
21-
fi
22-
23-
################################################################################
24-
2517
sign=1
2618
publish=1
2719

src/assets/pre-receive

-6
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,6 @@ fi
1313

1414
################################################################################
1515

16-
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)"
17-
if [ $? -eq 0 ]; then
18-
# Hooks disabled
19-
exit 0
20-
fi
21-
2216
if test -n "$GIT_PUSH_OPTION_COUNT"
2317
then
2418
i=0

src/js/git.js

+20-12
Original file line numberDiff line numberDiff line change
@@ -1053,6 +1053,26 @@ class Git {
10531053
.catch(() => []);
10541054
}
10551055

1056+
changeHooks(hooks) {
1057+
if(hooks) {
1058+
return Promise.all([
1059+
this.zeroFS.readFile("assets/pre-receive")
1060+
.then(preReceive => {
1061+
return this.zeroFS.writeFile(this.root + "/hooks/pre-receive", preReceive);
1062+
}),
1063+
this.zeroFS.readFile("assets/post-receive")
1064+
.then(postReceive => {
1065+
return this.zeroFS.writeFile(this.root + "/hooks/post-receive", postReceive);
1066+
})
1067+
]);
1068+
} else {
1069+
return Promise.all([
1070+
this.zeroFS.deleteFile(this.root + "/hooks/pre-receive"),
1071+
this.zeroFS.deleteFile(this.root + "/hooks/post-receive")
1072+
]);
1073+
}
1074+
}
1075+
10561076
toString() {
10571077
return "<Git " + this.root + ">";
10581078
}
@@ -1095,17 +1115,5 @@ Git.init = (root, zeroPage, name, email) => {
10951115
.then(id => {
10961116
return git.setRef("refs/heads/master", id);
10971117
})
1098-
.then(() => {
1099-
return zeroFS.readFile("assets/post-receive");
1100-
})
1101-
.then(postReceive => {
1102-
return zeroFS.writeFile(root + "/hooks/post-receive", postReceive);
1103-
})
1104-
.then(() => {
1105-
return zeroFS.readFile("assets/pre-receive");
1106-
})
1107-
.then(preReceive => {
1108-
return zeroFS.writeFile(root + "/hooks/pre-receive", preReceive);
1109-
})
11101118
.then(() => git);
11111119
};

src/js/repo.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,8 @@ class Repository {
415415

416416
// Adds or removes hooks from repository
417417
changeHooks(hooks) {
418-
return this.getContent()
418+
return this.git.changeHooks(hooks)
419+
.then(() => this.getContent())
419420
.then(content => {
420421
content.hooks = hooks;
421422
return this.setContent(content);

0 commit comments

Comments
 (0)